Part1: MacPortsMac is commonly used for MacPorts and homebrew, which can be easily installed. Xcode must be installed before installation. Xcode has a multi-G installation on the appstore. After the installation is completed, the Xcode icon is displayed on the launchpad. You must click the icon to install Xcode, after installation, enter gcc-v in the terminal and send
Part 1: MacPorts Mac is commonly used for MacPorts and homebrew, which can be easily installed. Xcode must be installed before installation. Xcode has a multi-G installation on the appstore. After the installation is completed, the Xcode icon is displayed on the launchpad. You must click the icon to install Xcode, after installation, enter gcc-v in the terminal and send
Part 1: MacPorts
MacPorts and homebrew are commonly used for Mac installation software.Install. Xcode must be installed before installation. Xcode is available on the appstore and can be downloaded for Multiple G versions.InstallThe Xcode icon is displayed on the launchpad.InstallAfter installation, you enter gcc-v on the terminal and find that no such command is available. You cannot install software without this command. It should be Xcode's default.InstallNot fully installed. Open Xcode, click Xcode-> Open develop tools-> more develop tools in the upper-left corner, and enter the Xcode webpage to search for UNIX,InstallCommand_line_tools_for_xcode _. dmg. Enter the terminal and enter gcc-v. OK.
I am using macportsInstall, Macports to http://www.macports.org/install.php to download the dmgfileInstallYou can,InstallEnter
Port list # view all software lists
Port search xxx # You can search for the software
Port install xxx #Install
Port uninstall xxx # uninstall
Port clean xxx # DeleteInstallTemporary Files
Ps: homebrewInstall
First:
Sudo chown-R 'whoam'/usr/local
Then you can officially startInstall, I recommendInstallYou can install git with git-osx-installer and then use gitInstall:
Cd/usr/local
Git init
Git remote add origin git: // github.com/mxcl/homebrew.git
Git pull origin master
After installation, the command is similar to the port command, such as brew search and brew install.
Part 2: Nginx
Input on the terminal
Sudo port install nginx spawn-fcgi
InstallAfter nginx is started, the nginx. conf file does not exist. You can view the following files in the/opt/local/etc/nginx directory:
Fastcgi_params.example koi-utf koi-win mime. types. example nginx. conf. example win-utf
Copy the example file directly:
Sudo mv mime. types. example mime. types
Sudo mv nginx. conf. example nginx. conf
Start nginx:
Sudo nginx
Visit http: // 127.0.0.1/to view the Nginx Welcome page.
Sudo nginx-t # Check whether the configuration file is valid
Sudo nginx-s reload # restart
Sudo nginx-h # Help
Important
1. Enable nginx to automatically start upon startup
Vi/Library/LaunchDaemons/org. macports. nginx. plist
Content is
Http://www.apple.com/DTDs/PropertyList-1.0.dtd>
Label Org. macports. nginx
ProgramArguments
/Opt/local/bin/daemondo
-- Label = nginx
-- Start-cmd
/Opt/local/sbin/nginx
;
-- Pid = fileauto
-- Pidfile
/Opt/local/var/run/nginx. pid
Debug
Disabled
KeepAlive
If the file already has content, exit vi directly.
Run
Sudo launchctl load-w/Library/LaunchDaemons/org. macports. nginx. plist
In this way, nginx is automatically started after it is started.
2. Modify nginx. conf content
Vi/opt/local/etc/nginx. conf
Below is my content
# User nobody;
User www;
Worker_processes 1;
Error_log/Users/apple/logs/nginx_errors.log;
Events {
Worker_connections 4098;
}
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/Users/apple/logs/access. log main;
Sendfile on;
Tcp_nopush on;
Tcp_nodelay on;
Fastcgi_connect_timeout 300;
Fastcgi_send_timeout 300;
Fastcgi_read_timeout 300;
Fastcgi_buffer_size 64 k;
Fastcgi_buffers 4 64 k;
Fastcgi_busy_buffers_size 128 k;
Fastcgi_temp_file_write_size 256 k;
# Keepalive_timeout 0;
Keepalive_timeout 65;
Gzip on;
Gzip_disable "MSIE [1-6] \. (?!. * SV1 )";
Include/opt/local/etc/nginx/conf. d/*. conf;
Include/opt/local/etc/nginx/sites-enabled /*;
}
Then create a directory
Sudo mkdir/opt/local/etc/nginx/sites-enabled
Go to cd/opt/local/etc/nginx/sites-enabled
Edit the conf file of a site
I created a default with the following content:
Server {
Listen 80; # listen for ipv4
Listen [:]: 80 default ipv6only = on; # listen for ipv6
Server_name localhost;
Access_log/Users/apple/logs/localhost. access. log;
Location /{
Root/Users/apple/phpdocs;
Index. php index.html index.htm;
}
Location ~ \. Php $ {
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/Users/apple/phpdocs $ fastcgi_script_name;
Include fastcgi_params;
}
}
Create log files and html files in the corresponding path after saving
In this case, do not place index. php first. The bad gatway error may occur. We haven't installed php or fastcgi yet.
Part 3: PHP
Input on the terminal
InstallPhp5, expansion module adjusted according to your own needs
Port install php5 + fastcgi fcgi php5-gd php5-mysql php5-sqlite php5-eaccelerator php5-curl php5-iconv
InstallThen, under/opt/local/etc/php5, cp php. ini-recommended php. ini
Modify the following items:
Error_reporting = E_ALL &~ E_NOTICE
Display_errors = On
Error_log =/Users/jonathan/logs/php5/error. log
Date. timezone = Asia/Shanghai
Manually create/Users/jonathan/logs/php5/error. log
Important
We need to write another plist file to run fastcgi.
Vi/Library/LaunchDaemons/org. macports. phpfcgi. plist
The content is as follows:
Label Org. macports. phpfcgi
Debug
OnDemand
RunAtLoad
EnvironmentVariables
PHP_FCGI_CHILDREN 2
PHP_FCGI_MAX_REQUESTS 5000
LaunchOnlyOnce
ProgramArguments
/Opt/local/bin/spawn-fcgi
-C 2
-P 9000
-F/opt/local/bin/php-cgi
Save and enter
Sudo launchctl load-w/Library/LaunchDaemons/org. macports. phpfcgi. plist
In this way, php fastcgi is automatically started.
Now go to the website directory and put an index. php. Check phpinfo ().
Part4:InstallMySQL
InstallMysql is very convenient. Go to the mysql website's next dmg. There are three filesInstall, One is mysqlInstallFile, one is mysql automatic start, and the other is the Add item control mysql switch in the system settings.
Download phpmyadmin to the website directory after installation,
Name config. sample. inc. php In the phpMyAdmin directory as config. inc. php.
Open config. inc. php and make the following changes:
$ Cfg ['blowfish _ secret'] = ''; // used for Cookie encryption and arbitrary long string
$ Cfg ['servers'] [$ I] ['host'] = '2017. 0.0.1 '; // The MySQL daemon binds an IP address.
$ Cfg ['servers'] [$ I] ['allownopassword'] = false; // you can access a password-less MySQL instance.
Access phpMyAdmin from the web and modify the MySQL password.
Part4:InstallMemcache
Install this originally thought can use port install php5-memcache, The result port of the compilation package may have problems, can not build memcache, only compiled by yourself
Install libevent first
Port install libevent
InstallGo to renewal:
Phpize
./Configure
Make
Make install
After compilation, memcache. so will be placed in the/opt/local/lib/php/extensions/debug-non-zts-xxxxxxx directory.
Write a configuration file for php to load memcache
Vi/opt/local/var/db/php5/memcache. ini
Content: extension = memcache. so
Save and exit
Then write a memcache STARTUP script.
Vi/etc/init. d/memcached
Content:
#! /Bin/bash
DAEMON =/opt/local/bin/memcached
NAME = memcached
DESC = memcached
USER = nobody
HOST = 0.0.0.0
PORT = 11211
MEM = 32
LOG =/Users/apple/logs/memcached/info. log
Case "$1" in
Start)
Echo-n "Startring $ DESC :"
$ DAEMON-m $ MEM-p $ PORT-l $ HOST-u $ USER-d-vv >>$ LOG 2> & 1
Echo "$ NAME ."
;;
Stop)
Echo-n "Stopping $ DESC :"
Killall $ NAME
Echo "$ NAME ."
;;
Restart)
Echo-n "Restarting $ DESC :"
Killall $ NAME
Sleep 1
$ DAEMON-m $ MEM-p $ PORT-l $ HOST-u $ USER-d-vv >>$ LOG 2> & 1
Echo "$ NAME ."
;;
*)
Echo "Usage: $ NAME {start | stop | restart}"> & 2
Exit 1
;;
Esac
Exit 0
Save and remember to grant the executable permission: chmod + x/etc/init. d/memcached
Do not forget to create a log file:/Users/apple/logs/memcached/info. log
Then enable memcached to start up.
Write a plist File
Vi/Library/LaunchDaemons/org. memcache. plist
Content is
Label Org. macports. memcache
OnDemand
Username
Nobody
ProgramArguments
/Etc/init. d/memcached
Start
Debug
Disabled
RunAtLoad
KeepAlive
Run after saving
Sudo launchctl load-w/Library/LaunchDaemons/org. memcache. plist