sudo apt-get update sudo apt-get install nginx sudo apt-get install mysql-server
設定MySQL安全性設定:
sudo mysql_secure_installation
安裝PHP:
sudo apt-get install php-fpm php-mysql php-json php-gd
設定 php.ini,編輯 /etc/php/7.2/fpm/php.ini,將cgi.fix_pathinfo設為0
;cgi.fix_pathinfo=1 cgi.fix_pathinfo=0
重新啟動PHP服務:
sudo service php7.2-fpm restart
設定一個新的nginx網站,以adia.cc為例。編輯 /etc/nginx/sites-available/adia.cc檔案:
server { listen 8080; root /var/www/adia.cc/html; index index.php index.html index.htm; access_log /var/log/nginx/adia.cc.access.log; error_log /var/log/nginx/adia.cc.error.log; server_name adia.cc www.adia.cc; location / { try_files $uri $uri/ =404; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php7.2-fpm.sock; } location ~ /\.ht { deny all; } }
建立adia.cc網站設定檔連結,並測試設定檔是否正確:
sudo ln -s /etc/nginx/sites-available/adia.cc /etc/nginx/sites-enabled/ sudo nginx -t
正確的話,應該會出現類似結果:
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
接著建立一個PHP測試網頁,編輯 /var/www/adia.cc/html/info.php:
<?php phpinfo(); ?>重新啟動 Nginx 服務:
sudo service nginx restart
接下來利用瀏覽器測試 http://YOUR_IP/ 和 http://YOUR_IP:8080/info.php是否正常~
phpinfo() 執行結果 |
#
沒有留言:
張貼留言