The solution for mac nginx not parsing php: 1. cp a new file with the correct name; 2. Execute the command "php-fpm --fpm-config..."; 3. cp a file named www .conf file; 4. Kill the Solution process.
The operating environment of this article: macOS10.15 system, PHP7.1 version, MacBook Air 2019 computer
mac nginx does not parse php what to do?
The pitfalls encountered by mac when deploying php under nginx
I was asked by someone to help them deploy a website, and then I wanted to debug it in the local nginx first. At first, when I opened the page, it showed 403. I had seen this before, and it was a permission issue with nginx. After changing the permissions, I found that when I accessed the PHP page, I downloaded it directly without parsing. I remembered that my computer might not have a PHP environment, so I downloaded PHP. Then still the same problem. In short, because I am not very familiar with PHP (I used software such as xampp before), it took me a while to get it done.
The first thing to understand is that nginx itself cannot handle PHP. It is just a web server. When the front-end requests PHP, nginx needs to send the interface to the PHP interpreter for processing, and then return the result to the front-end. Generally, nginx sends the request to the fastcgi management process for processing. For example, the configuration in nginx:
location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;#这里原来不是$document_root,搞得我很蒙,还好网上查到改好了,不然会报file not found include fastcgi_params; }
So to start a fastcgi, php-fpm is used here. It is a php fastcgi manager and is only used for the php language (the old version of php needs to download php-fpm separately. The php-fpm I use has integrated this).
There are a lot of strange questions here.
First time running php-fpm
failed: /private/etc/php-fpm.conf file not found,
Solution: But there is a php-fpm.conf.default file in this directory, so cp a new file with the correct name
Run php-fpm for the second time
Failed: Cannot find /usr/var/log/php-fpm.log
Solution: There is no such directory at all. I changed it in the conf file but it has no effect. , I have no choice but to execute php-fpm through the following command (I will use this command to execute later)
php-fpm --fpm-config /private/etc/php-fpm.conf --prefix /usr/local/var
Run php-fpm for the third time
Failed: No pool defined. at least one pool section must be specified in config file
Solution: Go to the /etc/php-fpm.d/ directory and there is a file www.conf.default, cp a file named www.conf
Fourth Run php-fpm for the first time
Failed: The port is occupied
Solution: Kill this process
sudo lsof -i tcp:9000#Find the occupied port Process number of port 9000
kill -9 port#Kill!
Run php-fpm for the fifth time
fastcgi_pass 127.0.0.1:9000;in the php configuration on nginx to:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;to successfully run php
Recommended study: "
PHP Video Tutorial"
Continue to add
A very interesting thing, I want to upload a video of 27m, nginx directly reported 413 Request Entity Too Large, but I did not set it...Add it to the nginx configuration (set-enabled/default)server { ... client_max_body_size 80m; ... }Reread the configuration and restart the server
nginx -s reload service nginx restartThen you have to modify php.ini and modify two configurations in it
upload_max_filesize = 80M post_max_size = 80MThen turn off the php-fpm process and restart it~ps: Teacher He is really I haven’t researched it at all...mp4 cannot be uploaded, but this type is not added to the system. I have to find this myself...uncomfortable:(note: It is now more recommended to use apt under ubuntu. It’s not apt-get…so, it’s time to change!
The above is the detailed content of What should I do if mac nginx does not parse php?. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver CS6
Visual web development tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Linux new version
SublimeText3 Linux latest version

Zend Studio 13.0.1
Powerful PHP integrated development environment

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.
