typecho -- nginx 部署


[HTML_REMOVED][HTML_REMOVED]我年华虚度,空有一身疲倦[HTML_REMOVED][HTML_REMOVED]


前言

LAMP 环境不详细记录了,反正,从 apache 转过来是折腾了


方法

安装 nginx

apt-get install nginx

配置 PHP 环境

pt-get install php5-fpm php-apc
service php5-fpm restart

默认虚拟主机失效

service nginx stop
unlink /etc/nginx/sites-enabled/default

配置 nginx 主机

vim /etc/nginx/sites-available/typechosite
server {
    listen 80;
    root /var/www/html;
    index index.php index.html index.htm;

    server_name pinsily.site;

    location ~ \.php$ {
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    }
}
$ cd /etc/nginx/sites-enabled
$ ln -s ../sites-available/typechodev.com ./
$ nginx -t
$ service nginx restart

伪静态调整

导致问题:只能进入主页 解决:修改 typechosite 中的 location 参考http://docs.typecho.org/faq

location ~ .*\.php(\/.*)*$ {
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;

    set $path_info "";
    set $real_script_name $fastcgi_script_name;
    if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {

        fastcgi_param SCRIPT_FILENAME;
        $document_root$real_script_name;
        fastcgi_param SCRIPT_NAME $real_script_name;
        fastcgi_param PATH_INFO $path_info;

    }

进入后台直接下载 admin 文件

参考https://wildlyinaccurate.com/solving-502-bad-gateway-with-nginx-php-fpm/

vim /etc/php5/fpm/pool.d/www.conf

listen = /var/run/php5-fpm.sock 改成:

listen = 127.0.0.1:9000

502 bad gateway

如上 进入后台直接下载 admin 文件 参考