隐藏入口文件index.php
nginx.access
if (!-e $request_filename) {
rewrite ^/(.*) /index.php/$1 last;
}
location / { // …..省略部分代码
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
default.conf
server {
listen 80;
server_name crm.xxxx.com;
set $root_path '/usr/public/crm';
client_max_body_size 10m;
root $root_path;
index index.html index.php index.htm;
try_files $uri $uri/ @rewrite;
location @rewrite {
rewrite ^/(.*)$ /index.php?_url=/$1;
}
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~* ^/(css|img|js|flv|swf|download)/(.+)$ {
root $root_path;
}
location ~ /\.ht {
deny all;
}
}
nginx转发配置
server {
listen 80;
server_name crm.xxxx.com;
index index.html;
location / {
send_timeout 60;
proxy_pass http://127.0.0.1:8032;
}
}
server {
listen 80;
server_name api.xxxx.com;
index index.html;
location / {
send_timeout 60;
proxy_pass http://127.0.0.1:8031;
}
}
cat /usr/local/nginx/conf/enable-php.conf
location ~ [^/]\.php(/|$)
{
try_files $uri =404;
# fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
* php-fpm.conf
默认用的socket连接,改为ip+port
sudo emacs /usr/local/php/etc/php-fpm.conf
listen = /tmp/php-cgi.sock 改为 listen=127.0.0.1:9000
重启php-fpm服务
sudo /etc/init.d/php-fpm restart
wordpress nginx
rewrite /wp-json/?$ /index.php?rest_route=/ last;
rewrite /wp-json/(.*)? /index.php?rest_route=/$1 last;
rewrite /index.php/wp-json/?$ index.php?rest_route=/ last;
rewrite /index.php/wp-json/(.*)? /index.php?rest_route=/$1 last;