1.安裝nginx+php
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx
nginx -v
sudo apt-get install php
php -v
配置
-
配置Nginx的監(jiān)聽端口為8080(防止與apache2的80端口沖突)
-
配置Nginx和Php7.0-FPM 啟用php7.0-FPM服務(wù)并在Nginx中生效
-
找到
etc/nginx/sites-available/default location ~ \.php$ { include snippets/fastcgi-php.conf; #~ # With php7.0-cgi alone: #~ fastcgi_pass 127.0.0.1:9000; #~ # With php7.0-fpm: fastcgi_pass unix:/run/php/php7.0-fpm.sock; }
找到 /etc/php/7.0/fpm/php-fpm.conf俏橘,在文件末尾加:listen = /run/php/php7.0-fpm.sock
-
測試:
sudo service php7.0-fpm start
- (這里我會報錯:Failed to stop ngnix.service: Unit ngnix.service not loaded.)
- 附上參考鏈接:[https://zhidao.baidu.com/question/136266203275721205.html]
-
開啟服務(wù)
sudo service ngnix start
- 最后測試:127.0.0.1:8080/phpinfo.php
- 我的根目錄在于var/www/html