Last active
April 25, 2016 04:27
-
-
Save period331/bfadb64ad72d6e765afd2261745953ea to your computer and use it in GitHub Desktop.
nginx-php开发环境配置
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;; | |
; Pool Definitions ; | |
; 只关注需要修改的配置; | |
;;;;;;;;;;;;;;;;;;;;;;; | |
; 以登陆用户的用户名和分组,避免权限问题 | |
user = baocaixiong | |
group = staff | |
; The address on which to accept FastCGI requests. | |
; Valid syntaxes are: | |
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on | |
; a specific port; | |
; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on | |
; a specific port; | |
; 'port' - to listen on a TCP socket to all IPv4 addresses on a | |
; specific port; | |
; '[::]:port' - to listen on a TCP socket to all addresses | |
; (IPv6 and IPv4-mapped) on a specific port; | |
; '/path/to/unix/socket' - to listen on a unix socket. | |
; Note: This value is mandatory. | |
;listen = 127.0.0.1:9000 | |
; 以版本作为sock文件名,方面在nginx中直接指定 | |
; 例如php5.4 则可以为,/usr/loca/var/run/php5.4-fpm.sock | |
listen = /usr/local/var/run/php5.5-fpm.sock | |
; Set permissions for unix socket, if one is used. In Linux, read/write | |
; permissions must be set in order to allow connections from a web server. Many | |
; BSD-derived systems allow connections regardless of permissions. | |
; Default Values: user and group are set as the running user | |
; mode is set to 0660 | |
;listen.owner = nobody | |
;listen.group = nobody | |
; 方便nginx的用户读取,改为0666 | |
listen.mode = 0666 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;;;;;;;;;;;;;;;; | |
; FPM Configuration ; | |
; 只关注需要修改的配置; | |
;;;;;;;;;;;;;;;;;;;;;;; | |
;;;;;;;;;;;;;;;;;; | |
; Global Options ; | |
;;;;;;;;;;;;;;;;;; | |
[global] | |
; Pid file | |
; Note: the default prefix is /Users/baocaixiong/.phpbrew/php/php-7.0.5/var | |
; Default Value: none | |
; pid文件指定为以php版本为名,例如php5.4,则为 /usr/local/var/run/php5.4-fpm.pid | |
pid = /usr/local/var/run/php7-fpm.pid | |
;;;;;;;;;;;;;;;;;;;; | |
; Pool Definitions ; | |
;;;;;;;;;;;;;;;;;;;; | |
; 指定pool目录 | |
include=fpm.d/*.conf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name ~^(?<php_version>[a-zA-Z0-9_\.]+)\.local\.(?<app_path>[a-zA-Z0-9_]+)\.(?<public_path>[a-zA-Z0-9-_]+)\.my$; | |
# 如果域名写死,可以用该方法获得域名变量 | |
# if ($host ~ ^([a-zA-Z0-9\.]+)\.local\.([a-zA-Z0-9_]+)\.my$) { | |
# set $php_version $1; | |
# set $app_path $2; | |
# } | |
if ($php_version = "") { | |
set $php_version 'php7'; | |
} | |
autoindex on; | |
root /Users/baocaixiong/www/$app_path/$public_path; | |
index index.php index.html index.htm; | |
# 不能解决PATH_INFO的情况 | |
# if (!-e $request_filename) { | |
# rewrite ^/(.*) /index.php/$1 last; | |
# } | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root html; | |
} | |
location ~ \.php$ { | |
fastcgi_pass unix:/usr/local/var/run/$php_version-fpm.sock; | |
# fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
# return 200 $document_root$fastcgi_script_name; | |
} | |
location /status { | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
fastcgi_pass unix:/usr/local/var/run/$php_version-fpm.sock; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80; | |
server_name ~^(?<php_version>[a-zA-Z0-9_\.]+)\.local\.my$; | |
autoindex on; | |
root /Users/baocaixiong/www; # 相应修改 | |
location / { | |
# index index.html index.htm; | |
} | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root html; | |
} | |
location ~ \.php$ { | |
fastcgi_pass unix:/usr/local/var/run/$php_version-fpm.sock; | |
# fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
include fastcgi_params; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
# return 200 $document_root$fastcgi_script_name; | |
} | |
location /status { | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
fastcgi_pass unix:/usr/local/var/run/$php_version-fpm.sock; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment