We review them in the form of simulated actual needs. The requirements are as follows:
1. Prepare two CentOS 6, one machine running MySQL, another machine running Apache and Nginx + PHP
2. Install Apache and Nginx at the same time, which Nginx start 80 port, used to run static objects (image, JS, CSS), Apache listening 88 port, is responsible for running dynamic pages (PHP related), and need to be accessed by Nginx Agent
3. mysql server needs to turn on slow query log
4. Build Discuz, WordPress and phpMyAdmin, the domain name is bbs.abc.com, blog.abc.com, pma.abc.com
5. Configuring pseudo-static (Nginx) for Discuz
6. Apache does not need to log logs, Nginx logs, but does not record the log of static pages such as pictures, and configuration log cutting
7. Configure image anti-theft chain (Nginx)
8. Configure picture Cache for 7 days, JS,CSS cache for 1 days (Nginx)
9. Discuz and WordPress Access background limit the IP whitelist, such as only allow 192.168.1.100 access (Nginx)
phpMyAdmin the entire site needs to be configured with user authentication (Nginx)
11. Write a MySQL backup script that executes at 5 points per day and requires remote copy to the Web machine
12. Remove other common search engine spiders except Baidu and Google, such as (bingbot/2.0, Sogou Web spider/4.0, 360Spider, Yisouspider, yandexbot/3.0) (Nginx)
Reference configuration:
/usr/local/apache2/conf/extra/httpd-vhosts.conf
- Namevirtualhost *:88
- <virtualhost *:88>
- DocumentRoot "/tmp/tmp"
- ServerName tmp.com
- Php_admin_value Open_basedir "/tmp/tmp"
- <Directory/tmp/tmp/>
- Order Allow,deny
- Deny from all
- </Directory>
- </VirtualHost>
- <virtualhost *:88>
- DocumentRoot "/data/bbs"
- ServerName bbs.abc.com
- </VirtualHost>
- <virtualhost *:88>
- DocumentRoot "/data/blog"
- ServerName blog.abc.com
- </VirtualHost>
- <virtualhost *:88>
- DocumentRoot "/DATA/PMA"
- ServerName pma.abc.com
- </VirtualHost>
Copy Code
Related to Nginx:
1. bbs.conf
- Server
- {
- Listen 80;
- server_name bbs.abc.com;
- Index index.html index.htm index.php;
- Root/data/bbs;
- #根据user_agent控制
- if ($http _user_agent ~ ' bingbot/2.0| mj12bot/v1.4.2| spider/3.0| Youdaobot| tomato| gecko/20100315 ') {
- return 403;
- }
- Location ~ admin.php {
- Allow 192.168.31.141;
- Deny all;
- Proxy_pass http://127.0.0.1:88;
- Proxy_set_header Host $host;
- }
- Location ~ \.php$ {
- Proxy_pass http://127.0.0.1:88;
- Proxy_set_header Host $host;
- Proxy_set_header X-real-ip $remote _addr;
- Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
- }
- Location ~. *\. (JS|CSS)? $
- {
- Expires 24h;
- Access_log off;
- }
- Location ~* ^.+\. (Gif|jpg|png|swf|flv|rar|zip|doc|pdf|gz|bz2|jpeg|bmp|xls) $ {
- Expires 7d;
- Valid_referers None blocked Server_names *.abc.com *.a.com *.b.com *.baidu.com\
- *.google.com *.google.cn *.soso.com;
- if ($invalid _referer) {
- return 403;
- #rewrite ^/http://www.example.com/nophoto.gif;
- }
- Access_log off;
- }
- rewrite ^ ([^\.] *)/topic-(. +) \.html$ $1/portal.php?mod=topic&topic=$2 last;
- rewrite ^ ([^\.] *)/forum-(\w+)-([0-9]+) \.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
- rewrite ^ ([^\.] *)/thread-([0-9]+)-([0-9]+)-([0-9]+] \.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3d$4&page =$3 last;
- rewrite ^ ([^\.] *)/group-([0-9]+)-([0-9]+) \.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
- rewrite ^ ([^\.] *)/space-(USERNAME|UID)-(. +) \.html$ $1/home.php?mod=space&$2=$3 last;
- rewrite ^ ([^\.] *)/(Fid|tid)-([0-9]+) \.html$ $1/index.php?action=$2&value=$3 last;
- Access_log/home/logs/discuz.log Combined_realip;
- }
Copy Code
2. blog.conf (Reference http://www.upupw.net/nginxhelp/n33.html)
- Server
- {
- Listen 80;
- server_name blog.abc.com;
- Index index.html index.htm index.php;
- Root/data/blog;
- location/wp-admin/{
- Allow 127.0.0.1;
- Deny all;
- Location ~ \.php$ {
- Proxy_pass http://127.0.0.1:88;
- Proxy_set_header Host $host;
- }
- }
- Location/{
- Proxy_pass http://127.0.0.1:88/;
- Proxy_set_header Host $host;
- Proxy_set_header X-real-ip $remote _addr;
- Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
- }
- }
Copy Code
3. pma.conf
- Server
- {
- Listen 80;
- server_name pma.abc.com;
- Index index.html index.htm index.php;
- ROOT/DATA/PMA;
- Location/{
- Auth_basic "Auth";
- AUTH_BASIC_USER_FILE/USR/LOCAL/NGINX/CONF/HTPASSWD;
- Location ~ \.php$ {
- Proxy_pass http://127.0.0.1:88;
- Proxy_set_header Host $host;
- Proxy_set_header X-real-ip $remote _addr;
- Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
- }
- }
- }
Copy Code
phpMyAdmin installation http://www.aminglinux.com/bbs/thread-6509-1-1.html
Wordpress installation Http://www.apelearn.com/bbs/forum.php?mod=viewthread&tid=7954&highlight=wordpress
2015-05-18LAMP/LNMP Stage Review