Today, I was idle and bored to read other mainstream blogs, and came across several very good typecho themes, so I thought I would install another blog system. I have used this blog system before, but later I gave up because of too few functions. Now I think that simplicity is not another kind of beauty. Suggest novice do not try to install this blog system, there are holes have not been filled.

Just because the environment is a key LNMP, compatible with the blog system, then download to use directly, said a few problems, just start the installation phase is very normal, after the installation is complete home page can normal visit, is excited, came across all 404 articles and backstage management page, I went to, really hell, most people say the first Internet solution:

  • Modify php.ini file:

cgi.fix_pathinfo=1
Copy the code
  • Edit the server area under nginx.conf and add the following content under location / :

        index index.html index.php;
		
        if (-f $request_filename/index.html){
            rewrite (.*) The $1/index.html break;
        }
        if (-f $request_filename/index.php){
            rewrite (.*) The $1/index.php;
        }
        if (!-f $request_filename){
            rewrite (.*) /index.php;
        }
Copy the code
  • Insert this line below root:

include typecho.conf
Copy the code

The above method does not work for me, you can try, maybe it works, and finally normal configuration:

server {
    listen 66;
    server_name _;
    index index.php index.html index.htm;
	root /home/wwwroot/typecho;
	
	#include typecho.conf
	include enable-php-pathinfo.conf;
	#include enable-php.conf;

    location / {
        index index.html index.php;
		
        if (-f $request_filename/index.html){
            rewrite (.*) The $1/index.html break;
        }
        if (-f $request_filename/index.php){
            rewrite (.*) The $1/index.php;
        }
        if (!-f $request_filename){
            rewrite (.*) /index.php;
        }
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ = 404;# Uncomment to enable naxsi on this location
        # include /etc/nginx/naxsi.rules
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;


    location ~ \.php$ {
        try_files $uri = 404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}Copy the code

After the test, run the LNMP command to generate the configuration. The configuration is as follows, which needs to be modified based on the actual situation:

server
    {
        listen 80;
        #listen [::]:80;
        server_name www.chao.com ;
        index index.html index.htm index.php default.html default.htm default.php;
        root  /home/wwwroot/www.chao.com;

        include rewrite/other.conf;
        #error_page 404 /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php-pathinfo.conf; location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)? $ { expires 12h; } location ~ /.well-known { allow all; } location ~ /\. { deny all; } access_log /home/wwwlogs/www.chao.com.log; }Copy the code

I hope you don’t blame me for reading this, but the core code can be done in one sentence:

include enable-php-pathinfo.conf;
Copy the code