- 安装nginx+php
- sudo add-apt-repository ppa:nginx/stable
- sudo apt-get update
- sudo apt-get install nginx
- nginx -v(查看nginx版本)
- sudo apt-get install php
- php -v(查看php版本)
- 配置
- 配置Nginx的监听端口为8080(防止与apache2的80端口冲突)
- 配置Nginx和Php7.0-FPM 启用php7.0-FPM服务并在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
- 找到:etc/nginx/sites-available/default
- 测试:
- sudo service php7.0-fpm start
- (这里我会报错:Failed to stop ngnix.service: Unit ngnix.service not loaded.)
2. 附上参考链接https://zhidao.baidu.com/question/136266203275721205.html - sudo service ngnix start
- 最后测试:127.0.0.1:8080/phpinfo.php
- 我的根目录在于var/www/html
- (这里我会报错:Failed to stop ngnix.service: Unit ngnix.service not loaded.)
- sudo service php7.0-fpm start
ubuntu16.04下安装Nginx+php-fpm
最新推荐文章于 2022-06-24 18:24:52 发布