查看nginx/error.log
报错:primary script unknown nginx
修改nginx网站的配置
nginx的config启动文件:ps -ef | grep nginx
-v 显示 nginx 的版本
-V 显示 nginx 的版本,编译器版本和配置参数。
查找nginx地址:nginx -t
默认的情况下文件地址在:/etc/nginx/conf.d/default.conf
默认配置:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
将其修改为:
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
网上说 /scripts 改成 $document_root,不过还是没有识别到
php重启 sudo service php-fpm restart
nginx重启:service nginx restart
虚拟机host域名配置:
vi /etc/hosts
nginx指向域名,项目
vi /usr/local/nginx/conf/nginx.conf server同级再建一个server配置
server {
listen 80;
server_name test1.test;
location / {
root /work/html/;
index index.php index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location ~ \.php$ {
root /work/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
Linux 下hosts文件详解:https://www.cnblogs.com/xiaoit/p/3989026.html
物理机访问虚拟机host域名:https://jingyan.baidu.com/article/2d5afd690d7f6d85a2e28ec6.html
搭建docker+swoole+php7 的环境(没什么用):https://blog.csdn.net/yangqinjiang/article/details/78332682
搭建docker+swoole+php7 的环境 github(没什么用):https://github.com/cmptech/auto_cmp_php_docker_server
linux centos下安装docker:http://www.cnblogs.com/rookie404/p/5965518.html
基于Docker部署PHP7开发环境:http://www.mamicode.com/info-detail-2181927.html
Docker学习笔记:http://www.cnblogs.com/52fhy/p/5638571.html
实用github镜像:https://github.com/52fhy/docker-images/tree/master/php71-fpm-centos68-phalcon-withext