Summary: This article is based on Homebrew to build NGINX+MYSQL+PHP-FPM environment. I am also a novice, what is wrong to set the place, but also hope that everyone correct.
Installing homebrew
Homebrew is a very easy-to-use Package Manager for Mac that automatically installs dependent packages and frees you from cumbersome software dependencies.
Installing the homebrew is also very simple, just enter it in the terminal:
Ruby-e "$ (curl-fssl https://raw.github.com/Homebrew/homebrew/go/install)"
Common commands for homebrew:
Brew Update #更新可安装包的最新信息, it is recommended that you run the brew search pkg_name #搜索相关的包信息brew install pkg_name before each installation #安装包
For more information, please refer to Homebrew
Installing Nginx
Installation
Brew Search Nginxbrew Install Nginx
The current latest version is 1.8.0
Configuration
Cd/usr/local/etc/nginx/mkdir Conf.dvim./conf.d/default.conf
default.conf File Contents
server { listen 8080; server_name localhost; root/users/user_name/nginx_sites/; # The item to be modified as you are ready to store the relevant page path location /{ index index.php; AutoIndex on; } #proxy the PHP scripts to php-fpm location ~ \.php$ { include/usr/local/etc/nginx/fastcgi.conf; Fastcgi_intercept_errors on; Fastcgi_pass 127.0.0.1:9000; } }
Configuration
Cd/usr/local/etc/nginx/vim nginx.conf
nginx.conf Content:
Worker_processes 1; Error_log /usr/local/var/log/nginx/error.log warn;pid /usr/local/var/run/nginx.pid;events { worker_ Connections 256;} 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/var/log/nginx/access.log main; Port_in_redirect off; Sendfile on ; Keepalive_timeout ; include/usr/local/etc/nginx/conf.d/*.conf;}
Installing PHP-FPM
Mac OSX 10.9 's system comes with PHP and PHP-FPM, eliminating the hassle of installing PHP-FPM.
Here you need to simply modify the next PHP-FPM configuration, or run PHP-FPM will error.
sudo cp/private/etc/php-fpm.conf.default/private/etc/php-fpm.confvim/private/etc/php-fpm.conf
Modify the php-fpm.conf file in the Error_log item, which is commented out by default, it needs to be commented and modified to Error_log =/usr/local/var/log/php-fpm.log . If you do not modify this value, the log file output path does not exist when you run PHP-FPM.
Install MySQL
Installation
Brew Install MySQL
Common Commands
Mysql.server start #启动mysql服务mysql. server Stop #关闭mysql服务
Configuration
run at Terminal Mysql_secure_installation script, which prompts you to set up a series of security-related parameters, including: Set Root password , Turn off anonymous access , Do not allow root user remote access , To remove the test database . Of course, remember to start the MySQL service before running the script.
Test Nginx Service
Create a test file under the folder corresponding to the root key set in the previous Nginx configuration file default.conf index.php:
Start the Nginx service, sudo nginx ;
Modify the configuration file, restart the Nginx service, sudo nginx-s reload
Start the PHP service, sudo php-fpm ;
in the browser address bar, enter localhost:8080 , if configured correctly, you should be able to see the PHP-related information page.
Resources
- Chen Shan's blog: Installing Nginx and PHP-FPM on Mac OS X
- English information: Installing Nginx, PHP-FPM and APC on Mac OS X
- D.H.Q's Blog: Installation configuration for Mac Nginx, MySQL, php-fpm
Original link: Mac OSX 10.9 build nginx+mysql+php-fpm Environment
Add:
Quick Stop or close nginx:nginx-s stop
Normal stop or close nginx:nginx-s quit
Configuration file Modification Reload command: Nginx-s Reload
The above describes the Mac OSX 1010 build NGINX+MYSQL+PHP-FPM environment, including the aspects of the content, I hope the PHP tutorial interested in a friend helpful.