In fact, this process is similar to the installation of Linux, but some of the commands are different, similar.
Many of the online tutorials are installed with a package manager such as Brew, but do you have a third-party Mac with PHP? Obsessive-compulsive disorder can not endure, so I want to use their own php-fpm to build, did not expect a build is two hours, here the process to tidy up a spare, but also convenient for people.
Because it is a debugging environment, so there is no focus on security, some things directly chmod 777 to be used for WS, or change it.
Download Nginx source code and start compiling
tar zxvf nginx.tar.gzcd nginx?1.7.4./configure
Execution Error:
./configure:error: theHTTP Rewrite module requires thePCRE Library. You can either disable theModule by using??without? http_rewrite_moduleoption,orInstall thePCRE Library into the system,orBuild thePCRE librarystatically from theSource withNginx by using?? with?pcre=<path> option.
Rewrite requires PCRE library support, download the PCRE library and compile the installation
tar xvzf pcre.tar.gzcd pcre-8.35./configuremakesudo make install
Re-compiling Nginx
cd .../configuremakemake install
Creating a symbolic link makes the switch easier
/usr/local/nginx/sbin/nginx /usr/local/bin/nginx
With a Web service, then try to start the system's own PHP-FPM
php-fpm
Execute error
toopenfile‘/private/etc/php-fpm.conf‘fileordirectory (2)
Can not find the configuration file, in order to save trouble directly to the. default replication, and then give permission
sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf777 /private/etc/php-fpm.confsudo php-fpm
Try to start an error:
toopen error_log (/usr/var/log/php-fpm.logfileordirectory (2)
Create a new folder without finding it
sudo mkdir /usr/varsudo mkdir /usr/var/logsudo php-fpm
At this time PHP normal startup, but still need to improve, put a configuration file, modify the permissions, if the open public access to the words "winning" on the Cup, this thing or do not use Su to do a little better.
cp /etc/php.ini.default /etc/php.ini777 /etc/php.inisudo killall php-fpmphp-fpm
At this time PHP normal startup has two notice can regardless of his
isisnotrunningasisisnotrunningas root
Modify Nginx config file so that it can handle 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 up is MySQL.
From the official download (download dmg words install more simple, but my hand cheap download tar) http://dev.mysql.com/downloads/mysql/
tar zxvf mysql.tar.gzcd mysql-*mkdir /User/typcn/mysqlmv * /User/typcn/mysql/cd /User/typcn/mysqlsudo chown -R _mysql .#赋予权限sudosudo scripts/mysql_install_db --user=_mysql --datadir=/User/typcn/mysql/data#执行安装sudosudo
Edit MySQL configuration file
basedir = /path/to/mysqldatadir = /path/to/mysql/dataport = 3306 server_id = 1 socket = /tmp/mysql.sockuser = _mysql
Managing MySQL with scripting
/User/typcn/mysql/support-files/mysql.server /usr/local/bin/mysqlsubl support-files/mysql.server
Modifying a configuration file
basedir=/path/to/mysqldatadir=/path/to/datamysqld_pid_file_path=/path/to/mysql.pid
All right. I admit that PID is a bad habit to put TMP.
sudo mysql start
Now go to localhost and try it.