MacOSX1010 build nginx + mysql + php-fpm environment

Source: Internet
Author: User
Tags install homebrew
: This article describes how to set up the nginx + mysql + php-fpm environment in MacOSX1010. For more information about PHP tutorials, see. Abstract: This article builds the nginx + mysql + php-fpm environment based on homebrew. I am also a newbie. I hope you can correct the settings.

Install homebrew

Homebrew is a very useful package manager in mac. it automatically installs related dependent packages and frees you from tedious software dependency installation.
Installing homebrew is also very simple, as long as you enter:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
Common commands of homebrew:

Brew update # update the latest information about the installable package. we recommend that you run brew search pkg_name # search for related package information before each installation. brew install pkg_name # installation package
For more information, see homebrew

Install nginx

Install

brew search nginxbrew install nginx
The latest version is 1.8.0.

Configuration

cd /usr/local/etc/nginx/mkdir conf.dvim ./conf.d/default.conf
Content of the default. conf file

Server {listen 8080; server_name localhost; root/Users/user_name/nginx_sites/; # Modify the location/{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  65;     include /usr/local/etc/nginx/conf.d/*.conf;}

Install php-fpm

Mac OSX 10.9 comes with PHP and php-fpm, saving the trouble of installing php-fpm.
Modify the configuration of php-fpm. Php-fpmAn error is reported.

sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.confvim /private/etc/php-fpm.conf
Modifying Error_logItem, which is commented out by default. you need to comment out and modify it Error_log =/usr/local/var/log/php-fpm.log. If this value is not modified, an error indicating that the log file output path does not exist will be prompted when you run php-fpm.

Install mysql

Install

brew install mysql
Common Commands

Mysql. server start # start mysql service mysql. server stop # Disable mysql service
Configuration
Run on the terminal Mysql_secure_installationScript, which will prompt you to set a series of security-related parameters step by step, including: Set root password, Disable anonymous access, Remote access by root users is not allowed, Remove database test. Before running the script, start the mysql service.

Test the nginx service

In the previous nginx configuration file default. conf RootCreate a test file index. php in the folder corresponding to the item:

        
Start the nginx service, Sudo nginx;
Modify the configuration file and restart the nginx service, Sudo nginx-s reload
Start the php service, Sudo php-fpm;

In the browser address bar, enter Localhost: 8080If the configuration is correct, you should be able to see the PHP-related information page.


References

  1. Chen Shan's blog post: Installing Nginx and PHP-FPM on Mac OS X
  2. Installing Nginx, PHP-FPM and APC on Mac OS X
  3. D. H.Q's blog post: installation and configuration of nginx, mysql, and php-fpm in Mac

Original article: build nginx + mysql + php-fpm environment on Mac OSX 10.9

Supplement:

Fast stop or stop Nginx: nginx-s stop

Stop or disable Nginx normally: nginx-s quit

Configuration file modification and reload command: nginx-s reload


The above section describes how to set up the nginx + mysql + php-fpm environment on Mac OSX 1010, including some content. if you are interested in the PHP Tutorial.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.