Mac下用brew搭建LNMP和LAMP开发环境

 

Mac OS apache httpd 启动、关闭、重启的方法

apache 关闭开机启动

开机关闭: sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

开机启动: sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist

 

apache 命令脚本启动

重启apache:sudo /usr/sbin/apachectl restart

关闭apache:sudo /usr/sbin/apachectl stop

开启apache:sudo /usr/sbin/apachectl start

 

php-fpm 关闭开机启动

开机关闭:sudo launchctl unload -w /Library/LaunchDaemons/homebrew.mxcl.php-fpm.plist

开机启动: sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.php-fpm.plist

 

Apache中php.ini的设置方法

#LoadModule php5_module libexec/apache2/libphp5.so

改为

LoadModule php5_module /usr/local/php5/libphp5.so

 

 

nginx + php-fpm 无法访问 index.html

提示错误: 

FastCGI sent in stderr: "Access to the script '/usr/local/nginx/html/index.html' has been denied (see security.limit_extensions)" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /index.html HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "localhost:8080"

原因分析:

php-fpm 配置文件阻止了非 *.php 文件的访问,如 index.html 属于 html文件,不是php文件,因此无法访问

解决方案:

编辑 php-fpm 配置文件,添加允许html文件访问,并重启php-fpm进程,详细步骤:

1. 编辑 php-fpm 配置文件

sudo vim /usr/local/php5/etc/php-fpm.conf

;security.limit_extensions = .php .php3 .php4 .php5

修改为

security.limit_extensions = .php .php3 .php4 .php5 .html .htm

 

2. 重启 php-fpm 进程

ps -ef | grep php-fpm | grep -v grep | awk '{print $2}' | sudo xargs kill -9
sudo php-fpm

 

 

参考推荐

Mac OS X 安装 Nginx

LNMP(CentOS+Nginx+Mysql+PHP)服务器环境配置

Nginx和PHP-FPM的启动、重启、停止脚本