Ubuntu 17.04 (Zesty Zapus) 에 Nginx, Php, MariaDB 설치
/** * 설치전 업데이트 */ sudo apt-get update && sudo apt-get dist-upgrade && sudo apt-get autoremove
- 엔진엑스(Nginx) 설치
/** * Nginx 설치 */ sudo apt-get install nginx /** * nginx 서비스 등록 */ sudo systemctl stop nginx.service sudo systemctl start nginx.service sudo systemctl enable nginx.service
2. MariaDB 설치
/** * MariaDB 설치 */ sudo apt-get install mariadb-server mariadb-client /** * MariaDB 비밀번호 설정 */ sudo mysql_secure_installation Enter current password for root (enter for none): (비밀번호 입력) Set root password? [Y/n] Y (비밀번호 저장) Remove anonymous users? [Y/n] Y (익명 사용자 금지) Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y /** * MariaDB 서비스 활성화 */ sudo systemctl stop mariadb.service sudo systemctl start mariadb.service sudo systemctl enable mariadb.service
3. PHP 설치 및 설정
/** * php 설치 */ sudo apt-get install php php-fpm php-mysql php-curl php-gd php-pear php-imagick php-imap php-mcrypt php-recode php-tidy php-xmlrpc
4. Nginx default site 설정
/** * nginx default site 설정 */ sudo nano /etc/nginx/sites-available/default /** * 아래 예제 처럼 30번 라인처럼 index.php 추가 * 42~43, 46 라인 추가 */ # Default server configuration # server { listen 80 default_server; listen [::]:80 default_server; # SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf; root /var/www/html; # Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html; server_name _; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } # pass PHP scripts to FastCGI server # location ~ \.php$ { include snippets/fastcgi-php.conf; # # With php-fpm (or other unix sockets): fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; } # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} }
5. 웹루트 퍼미션 변경
/** * /var/www/html 권한 www-data, 755 설정 */ sudo chown -R www-data:www-data /var/www/html/ sudo chmod -R 755 /var/www/html/
6. 모든 설정이 완료되었다면 Nginx 재시작
sudo systemctl restart nginx.service