vim /usr/local/etc/nginx/sites-available/default
server { listen 80; server_name localhost; root /var/www/; access_log /usr/local/var/logs/nginx/default.access.log main; location / { index index.html index.htm index.php; autoindex on; include /usr/local/etc/nginx/conf.d/php-fpm; } location = /info { allow 127.0.0.1; deny all; rewrite (.*) /.info.php; } error_page 404 /404.html; error_page 403 /403.html;}
/usr/local/etc/nginx/nginx.conf
worker_processes 1;error_log /usr/local/var/logs/nginx/error.log debug;pid /usr/local/var/run/nginx.pid;events { worker_connections 256;}http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /usr/local/var/logs/access.log main; sendfile on; keepalive_timeout 65; port_in_redirect off; include /usr/local/etc/nginx/sites-enabled/*;}
/usr/local/etc/nginx/sites-available/default This file is configured with 80 ports, why 80 ports are inaccessible, but 8080 can be accessed
80 port access is a 404 error not Found
Reply content:
vim /usr/local/etc/nginx/sites-available/default
server { listen 80; server_name localhost; root /var/www/; access_log /usr/local/var/logs/nginx/default.access.log main; location / { index index.html index.htm index.php; autoindex on; include /usr/local/etc/nginx/conf.d/php-fpm; } location = /info { allow 127.0.0.1; deny all; rewrite (.*) /.info.php; } error_page 404 /404.html; error_page 403 /403.html;}
/usr/local/etc/nginx/nginx.conf
worker_processes 1;error_log /usr/local/var/logs/nginx/error.log debug;pid /usr/local/var/run/nginx.pid;events { worker_connections 256;}http { include mime.types; default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /usr/local/var/logs/access.log main; sendfile on; keepalive_timeout 65; port_in_redirect off; include /usr/local/etc/nginx/sites-enabled/*;}
/usr/local/etc/nginx/sites-available/default This file is configured with 80 ports, why 80 ports are inaccessible, but 8080 can be accessed
80 port access is a 404 error not Found
First you need a php-fpm to run PHP, and then you have to configure it to the correct location
Refer to my conf:
server { listen 80; server_name xxxxxx; index index.php; root /usr/www/web-sites/xxxxxx; error_log /var/log/nginx/xxxxxx.xxx.error.log; access_log /var/log/nginx/xxxxxx.xxx.access.log; location / { try_files $uri /index.php$is_args$args; } location ~ ^/.+\.php(/|$) { fastcgi_pass php_fpm:9000; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ { expires 1d; }}
There are questions to search for keywords:nginx 连接 php-fpm
I provide this is the HTTP way, you can swap with more efficient socket mode, keyword:socket nginx php-fpm