Install homebrew
Homebrew is a very useful Package manager under the Mac, and automatically installs the dependent packages to free you from the cumbersome software dependency installation.
Installing homebrew is also very simple, just enter in the terminal:
<!--Lang:shell-->
ruby-e "$ (curl-fssl https://raw.github.com/Homebrew/homebrew/go/install)"
Common commands for Homebrew:
<!--Lang:shell-->
Brew Update #更新可安装包的最新信息, it is recommended to run the
brew search Pkg_name #搜索相关的包信息 brew before each installation
install Pkg_name #安装包
For more information, please refer to homebrew
Install Nginx
Installation
<!--Lang:shell-->
Brew search Nginx
Brew Install Nginx
The current latest version is 1.4.4.
Configuration
<!--Lang:shell-->
cd/usr/local/etc/nginx/
mkdir conf.d
vim and
vim nginx.conf Default.conf
nginx.conf content,
<!--Lang:shell-->
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;
}
default.conf file content,
<!--Lang:shell-->
server {
listen 8080;
server_name localhost;
root/users/user_name/nginx_sites/; # The item to be modified for you 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
}
}
Install PHP-FPM
Mac OS 10.9 After the system has its own PHP, PHP-FPM, eliminating the trouble of installing PHP-FPM.
Here need to simply modify the configuration of the next php-fpm, otherwise run PHP-FPM will be an error.
<!--Lang:shell-->
sudo cp/private/etc/php-fpm.conf.default/private/etc/php-fpm.conf
vim/private /etc/php-fpm.conf
Modify the Error_log item in the php-fpm.conf file, which is commented out by default, and it needs to be annotated 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 have an error when running PHP-FPM.
installing MySQL
Installation
<!--Lang:shell-->
Brew install MySQL
Common commands
<!--Lang:shell-->
mysql.server start #启动mysql服务
mysql.server stop #关闭mysql服务
Configuration
Running the Mysql_secure_installation script at the terminal, the script prompts you to set a series of security-related parameters, including setting the root password, turning off anonymous access, not allowing root users to remotely access, and removing the test database. Of course, before running the script, remember to start the MySQL service first.
Testing Nginx Services
Create a test file under the folder corresponding to the root default.conf set in the Nginx configuration file index.php:
<!--~/nginx_sites/index.php-->
<?php phpinfo ();?>
Start the Nginx service,
Modify the configuration file, restart the Nginx service,
Start the PHP service,
Enter localhost:8080 in the browser address bar, and if configured correctly, you should be able to see the pages of PHP-related information.