mkdir -p /usr/local/etc/nginx/logs mkdir -p /usr/local/etc/nginx/sites-available mkdir -p /usr/local/etc/nginx/sites-enabled mkdir -p /usr/local/etc/nginx/conf.d mkdir -p /usr/local/etc/nginx/ssl sudo mkdir -p /var/www sudo chown :staff /var/www sudo chmod 775 /var/www
然后修改nginx配置文件:
vim /usr/local/etc/nginx/nginx.conf
将内容替换为:
worker_processes 1; error_log /usr/local/etc/nginx/logs/error.log debug; events { worker_connections 1024; } 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/etc/nginx/logs/access.log main; sendfile on; keepalive_timeout 65; index index.html index.php; include /usr/local/etc/nginx/sites-enabled/*; }
然后创建php-fpm配置文件:
vim /usr/local/ect/nginx/conf.d/php-fpm
输入以下内容:
location ~ \.php$ { try_files $uri = 404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
然后加入站点配置文件:
vim /usr/local/ect/nginx/sites-enabled/default
输入以下内容:
server { listen 80; server_name localhost; root /var/www/; access_log /usr/local/etc/nginx/logs/default.access.log main; location / { 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; }
重启nginx,至此,配置完成,在www下写一个测试文件,进行测试即可
总结
以上就是在Mac OS上搭建LNMP开发环境的全部步骤了,尽情的享受在Mac OS开发PHP的快感吧!希望本文的内容对大家的学习或者工作能带来一定的帮助,如果有疑问大家可以留言交流,谢谢大家对脚本之家的支持。
您可能感兴趣的文章: