In fact, this process is similar to installation in Linux, but some commands are different.
Many tutorials on the Internet are installed using the brew package manager, but the Mac comes with php. Do you need to install another third-party one? Obsessive-compulsive disorder can't be tolerated, so I want to use the built-in php-fpm to build it. I didn't expect it to be set up for two hours. Here I will sort out the process and make it easy for people who need it.
Because it is a debugging environment, we do not pay attention to the security aspect. If chmod 777 is used directly for ws, modify it.
Download nginx source code and start compiling
tar zxvf nginx.tar.gzcd nginx−1.7.4./configure
Execution error:
./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using −−without−http_rewrite_moduleoption, or install the PCRE library into the system, or build the PCRE librarystatically from the source with nginx by using −−with−pcre=<path> option.
Rewrite requires support from the PCRE Library. Download The pcre Library and compile and install it.
tar xvzf pcre.tar.gzcd pcre-8.35./configuremakesudo make install
Recompile nginx
cd .../configuremakesudo make install
Creating a symbolic link makes the switch easier
sudo ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx
With the web service, try to start the built-in php-fpm
php-fpm
Execution error
ERROR: failed to open configuration file '/private/etc/php-fpm.conf': No such file or directory (2)
If the configuration file cannot be found, copy. default directly to save trouble and grant permissions to it.
sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.confsudo chmod 777 /private/etc/php-fpm.confsudo php-fpm
Error reported when trying to start:
ERROR: failed to open error_log (/usr/var/log/php-fpm.log): No such file or directory (2)
Create a folder if no folder is found
sudo mkdir /usr/varsudo mkdir /usr/var/logsudo php-fpm
At this time, PHP starts normally, but you still need to complete it. Place the configuration file and modify the permissions. If you open a public network, you will win the prize, do not use su to execute such things better.
cp /etc/php.ini.default /etc/php.inisudo chmod 777 /etc/php.inisudo killall php-fpmphp-fpm
At this time, PHP can start two notice services normally.
NOTICE: [pool www] 'user' directive is ignored when FPM is not running as rootNOTICE: [pool www] 'group' directive is ignored when FPM is not running as root
Modify the nginx configuration file so that it can process php
location ~ \.php$ { root /path/to/wwwroot; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /path/to/wwwroot$fastcgi_script_name;}
Start nginx
sudo nginx
Next is mysql.
Download from the official (download DMG for easier installation, but I download tar) http://dev.mysql.com/downloads/mysql/
Tar zxvf mysql.tar.gz cd mysql-* mkdir/User/typcn/mysqlmv */User/typcn/mysql/cd/User/typcn/mysqlsudo chown-R _ mysql. # Grant sudo chgrp-R _ mysql permissions. sudo scripts/mysql_install_db -- user = _ mysql -- datadir =/User/typcn/mysql/data # Install sudo chown-R root. sudo chown-R _ mysql data subl my. cnf
Edit Mysql configuration file
basedir = /path/to/mysqldatadir = /path/to/mysql/dataport = 3306 server_id = 1 socket = /tmp/mysql.sockuser = _mysql
Use scripts to manage Mysql
sudo ln -s /User/typcn/mysql/support-files/mysql.server /usr/local/bin/mysqlsubl support-files/mysql.server
Modify configuration file
basedir=/path/to/mysqldatadir=/path/to/datamysqld_pid_file_path=/path/to/mysql.pid
Okay. I admit that putting pid or something on tmp is a bad habit.
sudo mysql start
Try accessing localhost now