Static nginx configuration in lnmp

Source: Internet
Author: User
The Lnmp configuration has set up nginx lnmp, as well as blogs and forums. I am doing this statically. Create a discuz. conf and wordpress. conf and nginx. the conf file is placed in the same folder. Specifically, the file is stored in discuz under/usr/local/webserver/nginx/conf. conf content: location /{&

The Lnmp configuration has set up nginx lnmp, as well as blogs and forums. I am doing this statically.

Create a discuz. conf file, wordpress. conf file, and nginx. conf file in the same folder. Place the file in the directory:/usr/local/webserver/nginx/conf file.

The content of discuz. conf is as follows:

Location /{
Rewrite ^/archiver/(fid | tid)-[\ w \-] + \. html) $/archiver/index. php? $1 last;
Rewrite ^/forum-([0-9] +)-([0-9] +) \. html $/forumdisplay. php? Fid = $12 last;
32 last;
Rewrite ^/space-(username | uid)-(. +) \. html $/space. php? $1 = $2 last;
Rewrite ^/tag-(. +) \. html $/tag. php? Name = $1 last;
}

The content of wordpress. conf is as follows (super cache Acceleration)

Location/
{
Autoindex off;
Set $ wp_super_cache_file ";
Set $ wp_super_cache_uri $ request_uri;
If ($ request_method = POST)
{
Set $ wp_super_cache_uri ";
}
If ($ query_string)
{
Set $ wp_super_cache_uri ";
}
If ($ http_cookie ~ * "Comment_author _ | WordPress | wp-postpass _")
{
Set $ wp_super_cache_uri ";
}
If ($ wp_super_cache_uri ~ ^ (. +) $)
{
Set $ wp_super_cache_file/wp-content/cache/wp_super_cache/$ http_host/1_1index.html;
}
If (-f $ document_root $ wp_super_cache_file)
{
Rewrite ^ (. *) $ wp_super_cache_file break;
}
If (-f $ request_filename)
{
Expires 30d;
Break;
}
If (! -E $ request_filename)
{
Rewrite ^ (. +) $/index. php? Q = $1 last;
}
}

(Do not use super cache Acceleration as follows. we recommend that you use the above, almost)

Location /{
If (-f $ request_filename/index.html ){
Rewrite (. *) $1/index.html break;
}
If (-f $ request_filename/index. php ){
Rewrite (. *) $1/index. php;
}
If (! -F $ request_filename ){
Rewrite (. *)/index. php;
}
}

Configure this in your virtual machine configuration

Add a reference (discuz) to the first braces of the virtual machine configuration)

Include discuz. conf;

Or (wordpress)

Include wordpress. conf;

Check nginx configuration, no error, restart

Here is an example.

This is my bbs

Server
{
Listen 80;
Server_name bbs.1dle.com;
Index index.html index.htm index. php;
Root/data0/htdocs/bbs;
Include discuz. conf;
Error_page 404 =/error/404.html;
Error_page 502 =/error/502.html;

Location ~ . * \. (Php | php5 )? $
{
# Fastcgi_pass unix:/tmp/php-cgi.sock;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fcinclude GI. conf;

}

Log_format wwwlogs '$ remote_addr? $ Remote_user [$ time_local] "$ request "'
'$ Status $ body_bytes_sent' $ http_referer "'
'"$ Http_user_agent" $ http_x_forwarded_for ';
Access_log/data1/logs/wwwlogs. log wwwlogs;
}


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.