Table of Contents
Install Nginx And PHP-FPM On Mac Lion" >Install Nginx And PHP-FPM On Mac Lion
自动启动" >自动启动
禁止自动启动" >禁止自动启动
下载源码" >下载源码
编译" >编译
Home Backend Development PHP Tutorial Mac Lion下安装配置Nginx PHP PHP-FPM

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

Jun 13, 2016 pm 01:25 PM
enable fastcgi gt lt nginx

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

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

z

KeepAlive

Label

org.nginx.nginx

LaunchOnlyOnce

NetworkState

ProgramArguments

/usr/local/nginx/sbin/nginx

RunAtLoad

ServiceDescription

Nginx web server

StandardErrorPath

/var/log/system.log

配置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

KeepAlive

Label

net.php.php-fpm

LaunchOnlyOnce

NetworkState

ProgramArguments

/usr/local/php/sbin/php-fpm

RunAtLoad

ServiceDescription

PHP FastCGI Process Manager

StandardErrorPath

/var/log/system.log

停止php-fpm

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

启动?php-fpm

sudo /usr/local/php/sbin/php-fpm.dSYM
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to allow external network access to tomcat server How to allow external network access to tomcat server Apr 21, 2024 am 07:22 AM

To allow the Tomcat server to access the external network, you need to: modify the Tomcat configuration file to allow external connections. Add a firewall rule to allow access to the Tomcat server port. Create a DNS record pointing the domain name to the Tomcat server public IP. Optional: Use a reverse proxy to improve security and performance. Optional: Set up HTTPS for increased security.

What are the nginx start and stop commands? What are the nginx start and stop commands? Apr 02, 2024 pm 08:45 PM

The start and stop commands of Nginx are nginx and nginx -s quit respectively. The start command starts the server directly, while the stop command gracefully shuts down the server, allowing all current requests to be processed. Other available stop signals include stop and reload.

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

Steps to run ThinkPHP Framework locally: Download and unzip ThinkPHP Framework to a local directory. Create a virtual host (optional) pointing to the ThinkPHP root directory. Configure database connection parameters. Start the web server. Initialize the ThinkPHP application. Access the ThinkPHP application URL and run it.

Welcome to nginx!How to solve it? Welcome to nginx!How to solve it? Apr 17, 2024 am 05:12 AM

To solve the "Welcome to nginx!" error, you need to check the virtual host configuration, enable the virtual host, reload Nginx, if the virtual host configuration file cannot be found, create a default page and reload Nginx, then the error message will disappear and the website will be normal show.

How to register phpmyadmin How to register phpmyadmin Apr 07, 2024 pm 02:45 PM

To register for phpMyAdmin, you need to first create a MySQL user and grant permissions to it, then download, install and configure phpMyAdmin, and finally log in to phpMyAdmin to manage the database.

How to deploy nodejs project to server How to deploy nodejs project to server Apr 21, 2024 am 04:40 AM

Server deployment steps for a Node.js project: Prepare the deployment environment: obtain server access, install Node.js, set up a Git repository. Build the application: Use npm run build to generate deployable code and dependencies. Upload code to the server: via Git or File Transfer Protocol. Install dependencies: SSH into the server and use npm install to install application dependencies. Start the application: Use a command such as node index.js to start the application, or use a process manager such as pm2. Configure a reverse proxy (optional): Use a reverse proxy such as Nginx or Apache to route traffic to your application

How to solve the problem of nginx when accessing the website How to solve the problem of nginx when accessing the website Apr 02, 2024 pm 08:39 PM

nginx appears when accessing a website. The reasons may be: server maintenance, busy server, browser cache, DNS issues, firewall blocking, website misconfiguration, network connection issues, or the website is down. Try the following solutions: wait for maintenance to end, visit during off-peak hours, clear your browser cache, flush your DNS cache, disable firewall or antivirus software, contact the site administrator, check your network connection, or use a search engine or web archive to find another copy of the site. If the problem persists, please contact the site administrator.

How to communicate between docker containers How to communicate between docker containers Apr 07, 2024 pm 06:24 PM

There are five methods for container communication in the Docker environment: shared network, Docker Compose, network proxy, shared volume, and message queue. Depending on your isolation and security needs, choose the most appropriate communication method, such as leveraging Docker Compose to simplify connections or using a network proxy to increase isolation.

See all articles