The PHPNginx environment configured for macos-mac accesses the php file and downloads the file instead of executing the php file.

Source: Internet
Author: User
Tags sendfile
{Code ...} {code ...} {code ...} {code ...} usrlocaletcnginxsites-availabledefault this file is configured with port 80, why Port 80 cannot be accessed, but Port 8080 can be accessed to port 80, there is a 404 error cannot be found
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 port 80, why Port 80 cannot be accessed, but Port 8080 can be accessed

Port 80 cannot be found due to 404 errors during access

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 port 80, why Port 80 cannot be accessed, but Port 8080 can be accessed

Port 80 cannot be found due to 404 errors during access

First, you need a php-fpm to run php, and then configure it to the correct position.

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;  }}

If you have any questions, you can search for keywords:Nginx connection to php-fpm
This is the http method that I provide. you can use the socket method with higher efficiency. keyword:socket nginx php-fpm

  • 404 error. you can check the error. log.

  • Have you found that php-fpm and nginx are not combined?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.