Tutorial on building Nginx + PHP + MySQL development environment on MacOS, _ PHP Tutorial

Source: Internet
Author: User
Tags install homebrew
Build Nginx + PHP + MySQL development environment on MacOS ,. Build Nginx + PHP + MySQL development environment on MacOS. installing homebrewhomebrew is a very useful package manager in mac, and related dependent packages will be automatically installed, tutorial on building Nginx + PHP + MySQL development environment on Mac OS based on tedious software,

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.4.4.

Configuration

 cd /usr/local/etc/nginx/mkdir conf.dvim nginx.confvim ./conf.d/default.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;}

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 ;}}

Install php-fpm

After Mac OSX 10.9, the system comes with PHP and php-fpm, saving the trouble of installing php-fpm.
Modify the configuration of php-fpm. Otherwise, an error is returned when running php-fpm.

 sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.confvim /private/etc/php-fpm.conf

Modify the error_log entry in the php-fpm.conf file, which is commented out by default and needs to be commented out and changed to 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 the mysql_secure_installation script on the terminal. the script will prompt you to set a series of security-related parameters step by step, including setting the root password, disabling anonymous access, not allowing root users to remotely access and removing the test database. Before running the script, start the mysql service.

Test the nginx service

Create the test file index. php in the folder corresponding to the root item set in the nginx configuration file default. conf:


 <?php phpinfo(); ?>

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; 

Enter localhost: 8080 in the address bar of the browser. if the configuration is correct, you can see the PHP related information page.

Articles you may be interested in:
  • Install nginx and php on mac

Tutorial on setting up Nginx + PHP + MySQL development environment on OS, installing homebrew is a very useful package manager in mac, and relevant dependent packages will be automatically installed, according...

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.