[TOC]
# tpshop的nginx 服务器配置方法
这里造成注意第1个location和第2个location,都要加
第3个location中的,根据不同服务器的`.sock`加载不同的内容,本服务是这个
>oneinstack
```
fastcgi_pass unix:/dev/shm/php-cgi.sock;
```
>tpshop官方给的加的是这个
```
fastcgi_pass unix:/tmp/php-cgi.sock;
```
很多时间打不开都是因为它的路径不正确而引起的!
## 配置
以下配置地方,可以在 `php-fpm.conf` 进行配置,
`alidata` 的地址: `/alidata/server/php-5.5.7/etc/php-fpm.conf`
![mark](http://qiniu.newthink.cc/blog/20171107-141331782.png)
## DEMO1:完整代码如下:
采用 `php-cgi.sock` 形式
```
server {
listen 80;
server_name banmutian.sxctkj.cc;
#access_log /data/wwwlogs/banmutian.sxctkj.cc_nginx.log combined;
index index.html index.htm index.php;
root /data/wwwroot/banmutian.sxctkj.cc;
location / {
index index.htm index.html index.php;
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php?s=$1 last;
break;
}
}
location ~ /.*\.php/ {
rewrite ^(.*?/?)(.*\.php)(.*)$ /$2?s=$3 last;
break;
}
location ~ \.php {
fastcgi_pass unix:/dev/shm/php-cgi.sock;
fastcgi_index index.php;
include fastcgi_params;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
#set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
#fastcgi_param PATH_INFO $path_info;
}
}
```
## DEMO2:采用 `fastcgi_pass` 形式
```
server {
listen 80;
server_name shop.sxqibo.com;
default_type 'text/html';
charset utf8;
index index.php;
root /mnt/www/tpshop208;
# location ~ .*\.(php|php5)?$
# {
# #fastcgi_pass unix:/tmp/php-cgi.sock;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# include fastcgi.conf;
# }
location / {
if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php/$1 last;
break;
}
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
set $real_script_name $fastcgi_script_name;
if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
set $real_script_name $1;
set $path_info $2;
}
fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
fastcgi_param SCRIPT_NAME $real_script_name;
fastcgi_param PATH_INFO $path_info;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
#include /alidata/server/nginx/conf/rewrite/zybuxi.conf;
access_log /alidata/log/nginx/access/tpshop208.log;
}
```