Abstract: This article is based on homebrew to build the nginx+mysql+php-fpm environment. I am also a newbie. If there is anything wrong with the settings, I hope you can correct me.
Install homebrew
homebrew is a very easy-to-use package manager for mac. It will automatically install related dependency packages, freeing you from tedious software dependency installation.
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
brew update #更新可安装包的最新信息,建议每次安装前都运行下 brew search pkg_name #搜索相关的包信息 brew install pkg_name #安装包
Install nginx
Install
brew search nginx brew install nginx
Configuration
cd /usr/local/etc/nginx/ mkdir conf.d vim ./conf.d/default.conf
server { listen 8080; server_name localhost; root /Users/user_name/nginx_sites/; # 该项要修改为你准备存放相关网页的路径 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; } }
cd /usr/local/etc/nginx/ vim nginx.conf
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 system comes with PHP and php-fpm, eliminating the need to install php-fpm trouble.
You need to simply modify the configuration of php-fpm here, otherwise an error will be reported when running
sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf vim /private/etc/php-fpm.conf
Install mysql
Install
brew install mysql
mysql.server start #启动mysql服务 mysql.server stop #关闭mysql服务
Test the nginx service
Create the test file index.php in the folder corresponding to the
<?php phpinfo(); ?>
Enter
References
The above introduces the establishment of nginx+mysql+php-fpm environment on Mac OSX 1010, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.