微信搜索superit|邀请体验:大数据, 数据管理、OLAP分析与可视化平台 | 赞助作者:赞助作者

nginx + simply static 实现 wordpress 全站纯静态化

nginx aide_941 40℃

1, 安装simply static , 生成纯静态文件到  /static/

2, 配置  wordpress.conf

 

server {

listen 80;
# listen [::]:80 default_server;
server_name www.cl-light.com.cn cl-light.com.cn; #这里是你自己的域名,如果没有,用本机ip
root /var/www/vhosts/cl-light.com.cn;  #这里是放wordpress的文件目录
index  index.php index.html index.htm;

# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
 
#location ^~ /?
#{
#try_files  $uri  $uri/ /index.php?q=$uri&$args;
#}
 
location /index.php {
       #try_files  /static/index.html $uri $uri/ /index.php?q=$uri&$args;
}
 
 
location =/ {
       #root /var/www/vhosts/cl-light.com.cn/static;
       try_files  $uri /static/$uri/  $uri/ /index.php?q=$uri&$args;
}
 
location / {
       #root /var/www/vhosts/cl-light.com.cn/static;
       try_files  $uri $uri/ /static/$uri/  /index.php?q=$uri&$args;
}
 
 
#location /index.php {
#try_files  /static/index.html $uri $uri/ /index.php?q=$uri&$args;
#}
 
location /wp-admin/{
       root /var/www/vhosts/cl-light.com.cn;
       try_files  $uri $uri/ /index.php?q=$uri&$args;
}
 
location ~ \.php$ {
       root /var/www/vhosts/cl-light.com.cn;
       fastcgi_pass 127.0.0.1:9000;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
       include fastcgi_params;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
 
location ~ \.(gif|jpg|css|js|jpeg|png|bmp|ico)$ {
       expires 1d;
}
 
}

 

转载请注明:SuperIT » nginx + simply static 实现 wordpress 全站纯静态化

喜欢 (1)or分享 (0)