Debian7+Nginx+php-fpm
最近又开始折腾VPS,原来用的是centos+apache或这debian+apache,nginx太折腾人了,原来偶尔也会照着网上教程来装一个耍下。现在typecho0.9发布了,顺便就在vps上搭建一个debian+Nginx的平台安装一下typecho。
原来的centos和debian6好像都是nginx0.7,现在用了debian7,源里的nginx已经是1.2.1了,配置和以前的不一样,现在支持php-fastcgi和php-fpm,好像后者性能更佳。安装倒是很简单
apt-get install nginx php-fpm
配置很伤脑筋,一会403、404,一会又是500。折腾了大半天,总算是在vps上把Typecho0.9搭建起来了。配置文件主要就两个/etc/nginx/sites-available/default和/etc/php5/fpm/php.ini
php.ini文件里只需要改一个地方[参考:Typecho文档]
cgi.fix_pathinfo = 1
默认的网站配置default涉及到好几个功能,php-fpm、rewrite等,配置如下
server {
        listen   80; ## listen for ipv4; this line is default and implied
        #listen   [::]:80 default_server ipv6only=on; ## listen for ipv6
        root /var/www;
        index index.php index.html index.htm;
        # Make site accessible from http://localhost/
        server_name localhost;
        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?$args;
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
                if (!-e $request_filename) {
                        rewrite ^(.*)$ /index.php$1 last;
                }
        }
        location /doc/ {
                alias /usr/share/doc/;
                autoindex on;
                allow 127.0.0.1;
                allow ::1;
        }
        
         location ~ .*\.php(\/.*)*$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #
        #       # With php5-cgi alone:
        #       fastcgi_pass 127.0.0.1:9000;
        #       # With php5-fpm:
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
}
            
         
            
        
老师又开始折腾了
向小强同志学习