摘要:本文是基於homebrew來搭建nginx+mysql+php-fpm環境的。我也是新手,有什麼設定不對的地方,我希望大家指正。
安裝homebrew
homebrew是mac下非常好用的套件管理器,會自動安裝相關的依賴包,將你從繁瑣的軟體依賴安裝中解放出來。
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
安裝nginx
安裝brew update #更新可安装包的最新信息,建议每次安装前都运行下 brew search pkg_name #搜索相关的包信息 brew install pkg_name #安装包
1.8.0
1.8.0 eedefault.conf檔案內容
brew search nginx brew install nginx
cd /usr/local/etc/nginx/ mkdir conf.d vim ./conf.d/default.conf
server { listen 8080; server_name localhost; root /Users/user_name/nginx_sites/; # 该项要修改为你准备存放相关网页的路径 location / { index index.php; autoindex on; } #proxy the php scripts to php-fpm location ~ \.php$ { include /usr/local/etc/nginx/fastcgi.conf; fastcgi_intercept_errors on; fastcgi_pass 127.0.0.1:9000; } }
安裝php-fpm
cd /usr/local/etc/nginx/ vim nginx.conf
php-fpm會報錯。 worker_processes 1;
error_log /usr/local/var/log/nginx/error.log warn;
pid /usr/local/var/run/nginx.pid;
events {
worker_connections 256;
}
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 /usr/local/var/log/nginx/access.log main;
port_in_redirect off;
sendfile on;
keepalive_timeout 65;
include /usr/local/etc/nginx/conf.d/*.conf;
}
error_log
= /usr/local/var/log/php-fpm.log
sudo cp /private/etc/php-fpm.conf.default /private/etc/php-fpm.conf
vim /private/etc/php-fpm.conf
mysql_secure_installation
腳本,該腳本會一步步提示你設定一系列安全性相關的參數,包括:設定root密碼
,關閉匿名存取,不允許root用戶遠端存取
,資料庫不允許root用戶遠端存取啟動php服務,sudo php-fpm
;
Mac OSX 10.9自組合
-fpm
環境
補充:
🎜🎜快速停止或關閉Nginx:nginx -s stop🎜🎜或固定指令s reload🎜🎜 🎜 以上就介紹了Mac OSX 1010搭建nginx+mysql+php-fpm環境,包含了方面的內容,希望對PHP教學有興趣的朋友有幫助。 🎜 🎜 🎜