Mac Lion下安装配置Nginx PHP PHP-FPM
Install Nginx And PHP-FPM On Mac Lion
安装Nginx
方法1:使用brew.
brew install nginx
按提示操作,安装完成后nginx的配置文件在/usr/local/etc/nginx/nginx.conf。
启动nginx:
nginx?或者?sudo nginx
注意:若nginx的监听端口为1024以下,则需要使用sudo,否则会出现Permission denied.
停止?nginx
(sudo)nginx
-s
stop
自动启动
You can start nginx automatically on login running as your user with:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/nginx/1.0.8/org.nginx.nginx.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/org.nginx.nginx.plist
禁止自动启动
launchctl unload -w ~/Library/LaunchAgents/org.nginx.nginx.plist
rm ~/Library/LaunchAgents/org.nginx.nginx.plist
方法2:下载源码编译
cd ~/SourceCache
curl -O?http://nginx.org/download/nginx-1.0.4.tar.gz
tar -xzf nginx-1.0.4.tar.gz
cd nginx-1.0.4
brew install pcre
./configure --prefix=/usr/local/nginx --pid-path=/usr/local/nginx/var/run/nginx.pid --with-http_ssl_module
make
sudo make install
自动启动
sudo nano /Library/LaunchDaemons/org.nginx.nginx.plist
配置nginx
sudo mkdir /usr/local/etc/nginx/sites-available
sudo mkdir /usr/local/etc/nginx/sites-enable
sudo nano /usr/local/etc/nginx/nginx.conf
在
http{
…
server{
...
}
include sites-enabled/*.conf;
sudo nano /usr/local/nginx/conf/php.conf
fastcgi_intercept_errors on;
location ~ \.php$
{
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_read_timeout 600; # Set fairly high for debugging
fastcgi_pass 127.0.0.1:9001; # Non-default port
fastcgi_index index.php;
}
sudo nano /usr/local/nginx/conf/sites-available/example.conf
server
{
listen 80;
server_name?example.local;
root /Users/collin/Sites/example/public;
access_log /Users/collin/Sites/example/logs/access_log.txt;
error_log /Users/collin/Sites/example/logs/error_log.txt;
location /
{
index index.php;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
include php.conf;
}
安装PHP PHP-FPM
下载源码
curl -O?http://us2.php.net/distributions/php-5.3.6.tar.gz
tar -xzf php-5.3.6.tar.gz
cd php-5.3.6
编译
./configure --prefix=/usr/local/php \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--sysconfdir=/private/etc \
--enable-cli \
--with-config-file-path=/usr/local/php/etc \
--with-libxml-dir=/usr \
--enable-xml \
--with-openssl=/usr \
--with-kerberos=/usr \
--with-zlib=/usr \
--enable-bcmath \
--with-bz2=/usr \
--enable-calendar \
--with-curl=/usr \
--enable-exif \
--enable-ftp \
--with-gd \
--with-jpeg-dir=/usr/local/Cellar/jpeg/8c/lib \
--with-png-dir=/usr/X11 \
--enable-gd-native-ttf \
--with-ldap=/usr \
--with-ldap-sasl=/usr \
--enable-magic-quotes \
--enable-mbstring \
--enable-mbregex \
--enable-json \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysql-sock=/tmp/mysql.sock \
--with-iodbc=/usr \
--enable-shmop \
--with-snmp=/usr \
--enable-soap \
--enable-sockets \
--with-sqlite \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--enable-fpm \
--with-mhash \
--with-mcrypt \
--with-xmlrpc \
--enable-xmlwriter \
--enable-xmlreader \
--with-iconv-dir=/usr \
--with-xsl=/usr \
--enable-zend-multibyte \
--enable-zip \
--with-pcre-regex=/usr \
--with-pdo-sqlite \
--enable-pdo \
--enable-dba \
--with-freetype-dir=/usr/X11 \
--enable-dom \
--enable-gd-native-ttf \
--enable-posix \
--enable-fileinfo
make
sudo make install
配置PHP&PHP-FPM
sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf
sudo nano /private/etc/php-fpm.conf
[global]
pid = /usr/local/php/var/run/php-fpm.pid
daemonize = yes
[www]
listen = 127.0.0.1:9000
user = ray
group = staff
pm = dynamic
pm.max_children = 10
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 10
pm.max_requests = 500
sudo mkdir /usr/local/php/etc
sudo cp /private/etc/php.ini.default /usr/local/php/etc/php.ini
自动启动php-fpm
sudo nano /Library/LaunchDaemons/net.php.php-fpm.plist
停止php-fpm
sudo kill `cat /usr/local/php/var/run/php-fpm.pid`
启动?php-fpm
sudo /usr/local/php/sbin/php-fpm.dSYM相关文章
相关视频
专题推荐
-
独孤九贱-php全栈开发教程
全栈 170W+
主讲:Peter-Zhu 轻松幽默、简短易学,非常适合PHP学习入门
-
玉女心经-web前端开发教程
入门 80W+
主讲:灭绝师太 由浅入深、明快简洁,非常适合前端学习入门
-
天龙八部-实战开发教程
实战 120W+
主讲:西门大官人 思路清晰、严谨规范,适合有一定web编程基础学习
- 最新文章
- 热门排行
推荐阅读
-
CentOS7 下nginx与PHP的安装与配置
-
Mac下Nginx安装环境配置详解
-
Centos7下编译安装配置Nginx+PHP+MySql环境
-
基于ubuntu下nginx+php+mysql安装配置的具体操作步骤
-
详解Linux下安装php环境并且配置Nginx支持php-fpm模块
-
Mac下安装与配置nginx php7.1,apache和nginx解析PHP的原理
-
mac下安装nginx和php
-
Linux下安装PHP并在nginx服务器中进行配置的详细方法
-
Linux系统下PHP-FPM的安装和配置教程
-
Gentoo 下安装与配置Nginx+ MySQL + PHP (fastcgi) 环境步骤分享
网友评论
文明上网理性发言,请遵守 新闻评论服务协议
我要评论