Configure nginx + php for mac
System: OS X Yosemite 10.10.1
The system comes with php and php-fpm
Path remarks:
Php. ini:/etc/
Php-fpm.conf:/etc/
Nginx. conf:/usr/local/etc/nginx. conf
Nginx Default root:/usr/local/opt/nginx/html
1. Install nginx. I used brew.
brew install nginx
2. Start php-fpm
sudo php-fpm
If an error is reported, copy the php-fpm.conf.default to modify the path or enabled port of the php-fpm.conf's error_log Storage
3. Open nginx. conf
Enable php annotations and configure your own root
location ~ \.php$ { root /Users/maming/php; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
Note:
SCRIPT_FILENAME /script$fastcgi_script_name;
Change
SCRIPT_FILENAME $document_root$fastcgi_script_name;
Otherwise, the returned file does not exist.
4. Enable nginx
sudo nginx
Or restart
sudo nginx -s reload