CentOS에 Nginx + PHP +MariaDB 설치
BACK-END 2021-07-18

계정생성

useradd {userid}
passwd {userid}

sudo 권한 부여

chmod +w /etc/sudoers
vi /etc/sudoers
root ALL=(ALL) 아래에 {userid} ALL=(ALL) 추가 후 저장
chmod -w /etc/sudoers

Nginx 설치

sudo yum install -y yum-utils curl gnupg2
sudo vi /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true



[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
sudo vi /etc/nginx/conf.d/default.conf
root 디렉토리를 변경합니다.
chcon -R -t httpd_sys_content_t ./{디렉토리}
sudo vi /etc/nginx/nginx.conf 
유저를 변경합니다.
sudo yum-config-manager --enable nginx-mainline
sudo yum -y install nginx
sudo systemctl enable nginx
sudo systemctl start nginx
sudo systemctl status nginx
sudo yum clean all

Maria DB 설치

sudo yum -y install libaio libaio-devel numactl-devel numactl 
ncurses ncurses-devel ncurses-libs ncurses-static 
openssl openssl-devel bison readline glibc 
gcc gcc-c++ cmake bash sysstat

sudo dnf install mariadb-server mariadb
sudo systemctl enable mariadb
sudo systemctl start mariadb
sudo systemctl status mariadb
sudo mysql_secure_installation

PHP 설치

sudo dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
sudo dnf install dnf-utils http://rpms.remirepo.net/enterprise/remi-release-8.rpm
sudo dnf module reset php
sudo dnf module enable php:remi-7.4
sudo dnf install php php-opcache php-gd php-curl php-mysqlnd
sudo systemctl enable php-fpm
sudo systemctl start php-fpm
sudo systemctl status php-fpm
sudo vi /etc/php-fpm.d/www.conf
user = {userid}
group = {userid}
sudo systemctl restart nginx
sudo systemctl restart php-fpm
sudo vi /etc/php-fpm.d/www.conf
listen = 127.0.0.1:9000
security.limit_extensions에 .html .htm 추가
sudo vi /etc/nginx/conf.d/default.conf
location ~ .(php|html|html)$ {
root /home/{userid}/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

rewrite ^/api/([^/]+)/([^/]+)/?$ /api.php?class=$1&method=$2? last;

VSFtp 설치

sudo yum install vsftpd
sudo vi /etc/vsftpd/vsftpd.conf
anonymous_enable=NO
chroot_local_user=YES
pasv_enable=YES
pasv_min_port=50001
pasv_max_port=50005
allow_writeable_chroot=YES
sudo setsebool -P allow_ftpd_full_access=1
sudo systemctl enable vsftpd
sudo systemctl start vsftpd

Composer 설치

sudo yum -y update
sudo yum install php-cli php-zip wget unzip
php -r  "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
php composer-setup.php --install-dir=/usr/local/bin --filename=composer