`
cgzhang
  • 浏览: 73584 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Mac Lion上安装配置Nginx PHP PHP-FPM

阅读更多

<!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->

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

sudonginx 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

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">z

<dict>

<key>KeepAlive</key>

<true/>

<key>Label</key>

<string>org.nginx.nginx</string>

<key>LaunchOnlyOnce</key>

<true/>

<key>NetworkState</key>

<true/>

<key>ProgramArguments</key>

<array>

<string>/usr/local/nginx/sbin/nginx</string>

</array>

<key>RunAtLoad</key>

<true/>

<key>ServiceDescription</key>

<string>Nginx web server</string>

<key>StandardErrorPath</key>

<string>/var/log/system.log</string>

</dict>

</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

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">

<plist version="1.0">

<dict>

<key>KeepAlive</key>

<true/>

<key>Label</key>

<string>net.php.php-fpm</string>

<key>LaunchOnlyOnce</key>

<true/>

<key>NetworkState</key>

<true/>

<key>ProgramArguments</key>

<array>

<string>/usr/local/php/sbin/php-fpm</string>

</array>

<key>RunAtLoad</key>

<true/>

<key>ServiceDescription</key>

<string>PHP FastCGI Process Manager</string>

<key>StandardErrorPath</key>

<string>/var/log/system.log</string>

</dict>

</plist>

停止php-fpm

sudo kill `cat /usr/local/php/var/run/php-fpm.pid`

启动 php-fpm

sudo /usr/local/php/sbin/php-fpm.dSYM
分享到:
评论

相关推荐

    docker-compose-nginx-phpfpm-源码.rar

    docker-compose-nginx-phpfpm-源码.rar

    nginx-sticky-module-1.25.zip

    下载后,在编译安装nginx时,用--add-module选项,指到sticky所在目录。类似命令如下: ./configure --prefix=/usr/local/nginx-1.6.0 --add-module=../nginx-sticky-module-1.25 --without-...

    Debian系统安装nginx+php5-fpm

    在NanoPC-T2上安装Nginx和PHP5-FPM,你需要执行以下步骤: 1. 更新系统: ```bash sudo apt-get update sudo apt-get upgrade ``` 2. 安装依赖: 在安装Nginx和PHP5-FPM之前,确保系统拥有所有必要的依赖。这...

    docker-compose php7.3.4-fpm+nginx+mysql配置

    docker-compose php7.3.4-fpm+nginx+mysql配置

    nginx1.23.2-麒麟-aarch64

    - 通过配置`fastcgi_pass`指令,Nginx将PHP请求传递给PHP-FPM处理,然后返回结果给客户端。 7. **安全与日志管理** - Nginx的日志文件通常位于`/var/log/nginx/`,通过分析这些日志,可以监控服务器状态、识别...

    centos7+nginx+php php-fpm

    php-fpm。放到/etc/init.d/目录。然后执行:chmod a+x php-fpm 然后就可以/etc/init.d/php-fpm start 或者systemctl start php-fpm

    添加nginx-http-flv-module模块并重新编译后的nginx(windows版)

    6. 编译和安装:执行`make`和`make install`命令来编译和安装Nginx。对于Windows,你可能需要使用Visual Studio或其他Windows兼容的编译工具。 7. 测试和启动:编译完成后,你可以通过`./objs/nginx -t`测试配置...

    Fedora 15 安装 Nginx (PHP-FPM)+MySQL+PHP Web服务.docx

    以下是如何在Fedora 15上安装和配置这些组件的详细步骤: 1. **安装MySQL**: - 使用`yum`命令安装MySQL服务器和客户端:`yum install mysql mysql-server` - 配置MySQL随系统启动:`systemctl enable mysqld` -...

    nginx + nginx-http-flv-module-1.2.9

    通过在 Nginx 的 configure 脚本中添加模块路径,然后执行 `make` 和 `make install` 进行编译和安装。 4. **配置文件** 在 `conf` 目录下的 `nginx.conf` 文件是 Nginx 的主配置文件,其中需要添加或修改部分配置...

    nginx && php-fpm 停止脚本

    Windows 下使用 RunHiddenConsole 启动 nginx、php-fpm, https://www.nginx.com/resources/wiki/start/topics/examples/phpfastcgionwindows/

    windows平台nginx编译nginx-http-flv-module

    在Windows平台上编译Nginx并添加HTTP FLV模块是一项技术性较强的工作,涉及到网络服务器配置、编译环境搭建以及第三方模块集成等多个方面。这里我们将深入探讨如何在Windows上完成这个任务,以及与之相关的知识点。 ...

    nginx-php-fpm-docker

    nginx-php-fpm-docker

    基于alpine的php-fpm nginx docker一键环境

    基于alpine的php-fpm nginx docker一键环境 可以手动替换所有版本 通过修改dockerfile,支持容器加载代码,或者挂载代码 也可以支持k8s做为基础环境容器,整体已经经过优化

    nginx+php-fpm解决502 Bad Gateway.zip

    nginx+php-fpm解决502 Bad Gateway.zip

    Nginx安装配置、Resin安装配置说明文档

    a)在server1 上安装配置 nginx + nginx_upstream_jvm_route - 22 - b)分别在两台机器上 安装 resin - 22 - c)配置两台机器 的 resin - 23 - d)整合 ngxin resin - 24 - e)测试,打开浏览器,输入 ...

    php-fpm.rpm包

    【php-fpm.rpm包】是专门为Linux系统设计的一款软件包,它包含了PHP-FPM(FastCGI Process Manager)服务,是PHP的一个重要...正确安装和配置php-fpm,结合合适的Web服务器,可以构建出强大且高效的Web应用程序平台。

    nginx-http-flv-module(windows版)

    --&gt; nginx-1.21.6 ======================== 在网上查找半天都只有教程,没有可免费下载的版本,深知没有积分遍地找资源的痛苦,无奈之下只好自己按照教程一步一个坑编译出来的,供大家免费下载使用。(无毒放心使用...

    源码安装nginx+php-fpm+http push测试通过

    本教程将详细介绍如何在`CentOS 5.2`操作系统上,通过源码安装`Nginx`、`PHP-FPM`,并实现`HTTP Push`功能,以及如何进行测试验证。 首先,让我们了解这些技术的基本概念: 1. **Nginx**:Nginx是一款高性能的HTTP...

    nginx上传下载之nginx-upload-module-2.3.0

    将 Nginx Upload Module 的源代码复制到 Nginx 源代码目录,并配置、编译和安装: ```bash cp -r ../nginx-upload-module-2.3.0 nginx-1.21.x/ cd nginx-1.21.x/ ./configure --add-module=../nginx-upload-module...

    nginx1.16.1+nginx-upload-module-2.3.0.zip

    1. **Nginx 安装与配置**:首先,我们需要安装编译 Nginx 所需的依赖库,如 pcre, openssl, zlib 等。接着,解压 nginx-1.16.1.tar.gz,进入目录并执行 configure 脚本,配置编译选项,确保包含对 nginx-upload-...

Global site tag (gtag.js) - Google Analytics