安裝nginx
1.安裝brew命令
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2.使用brew 安裝nginx
brew install nginx
3.修改配置nginx 文件 (文件應該在 /usr/local/etc/nginx/nginx.conf)
server { listen 8080; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / { root /you/web/path; #配置web目錄 #root /usr/local/var/www; autoindex on; index index.html index.htm index.php; #添加php默認 }
(開啟PHP支持)修改為如下
location ~ \.php$ { root /you/web/path; #root /usr/local/var/www; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; #fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
4.啟動nginx
sudo nginx
5.有些情況需要打開,php-fpm 否則會報服務器錯誤~
sudo php-fpm