LNMP环境使用THINKPHP详细配置VHOST+SSL
*使用lnmp1.3、Thinkphp3.2.3、url模式2
*修改php配置文件php.ini,将其中cgi.fix_pathinfo = 0,值改为1(lnmp文件路径:/usr/local/php/etc/php.ini)
server
{
listen 80;
server_name example.com;
rewrite ^/(.*) https://example.com/$1 permanent;#关键代码
}
server
{
#listen 80;
listen 443 ssl;
#listen [::]:80;
server_name example.com;
index index.html index.htm index.php default.html default.htm default.php;
root 网站web目录;
#ssl
ssl_certificate /home/example.crt;
ssl_certificate_key /home/example.key;
#include other.conf;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
#comment try_files $uri =404; to enable pathinfo
#try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
include pathinfo.conf;
}
location / {
#try_files $uri /index.php$uri;
#try_files $uri $uri/ /index.php?q=$uri&$args;
#or
try_files $uri /index.php$uri?$args;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log /home/log access;
}