首选,需要安装xcode和brew。
然后删除mac自带的Apache和php。(可以不删,但是配置起来比较麻烦)
1 2 3 4 5 6 7 8 9 10 11 |
sudo apachectl stop sudo rm -rf /etc/apache2 sudo rm -rf /usr/include/apahce2 sudo rm -rf /usr/libexec/apache2 sudo rm -rf /usr/php sudo rm -rf /usr/bin/php sudo rm -rf /usr/bin/php-config sudo rm -rf /usr/bin/phpize sudo rm -rf /usr/include/php sudo rm -rf /usr/lib/php sudo rm -rf /usr/share/man/man*/php* |
1 2 3 4 5 6 7 |
//brew install xxx //brew uninstall xxx //brew list //brew update xxx //brew install /xxx*/ 正则表达式需要用/ //安装nginx brew install nginx |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
user www www; worker_processes auto; error_log /Users/tangxiaofeng/wwwlogs/error.log crit; pid /usr/local/var/run/nginx.pid; #Specifies the value for maximum file descriptors that can be opened by this process. worker_rlimit_nofile 51200; events { worker_connections 51200; multi_accept on; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 50m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\."; #limit_conn_zone $binary_remote_addr zone=perip:10m; ##If enable limit_conn_zone,add "limit_conn perip 10;" to server section. server_tokens off; #log format log_format access '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; server { listen 80 default; server_name www.test.com; index index.html index.htm index.php; root /Users/tangxiaofeng/wwwroot/default; #error_page 404 /404.html; location ~ .*\.(php|php5)?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include /usr/local/etc/nginx/fastcgi.conf; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } access_log /Users/tangxiaofeng/wwwlogs/access.log access; } include vhost/*.conf; } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
//安装php,我安装的是php5.6 如果是nginx一定要加上 --wath-fpm brew install php56 --with-fpm //安装mysql brew install mysql //nginx -s reload|reopen|stop|quit //ln -s /usr/local/Cellar/nginx/1.6.2/bin/nginx /usr/bin/nginx 软链接 //nginx -c filename 指定配置文件 //nginx -t 测试是否有语法错误 //启动nginx sudo /usr/local/Cellar/nginx/1.6.2/bin/nginx //启动php-fpm sudo /usr/local/Cellar/php56/5.6.5/sbin/php-fpm //如果php-fpm启动不了,ps查看是否已运行,kill之 //配置hosts /etc/hosts //127.0.0.1 www.test.com |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
//如果phpize不能用,先安装m4 brew install m4 //如果configure不能用,先安装autoconf brew install autoconf //开始安装,以yaf为例 phpize ./configure --with-php-config=/usr/local/Cellar/php56/5.6.5/bin/php-config make make install sb /usr/local/etc/php/5.6/php.ini [yaf] extension = yaf.so yaf.environ = dev //重启php-pfm sudo kill -9 $(ps aux | grep php | awk '{print $2}') /usr/local/Cellar/php56/5.6.5/sbin/php-fpm |