2015-05-18LAMP/LNMP Stage Review

Source: Internet
Author: User

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

  1. Namevirtualhost *:88
  2. <virtualhost *:88>
  3. DocumentRoot "/tmp/tmp"
  4. ServerName tmp.com
  5. Php_admin_value Open_basedir "/tmp/tmp"
  6. <Directory/tmp/tmp/>
  7. Order Allow,deny
  8. Deny from all
  9. </Directory>
  10. </VirtualHost>
  11. <virtualhost *:88>
  12. DocumentRoot "/data/bbs"
  13. ServerName bbs.abc.com
  14. </VirtualHost>
  15. <virtualhost *:88>
  16. DocumentRoot "/data/blog"
  17. ServerName blog.abc.com
  18. </VirtualHost>
  19. <virtualhost *:88>
  20. DocumentRoot "/DATA/PMA"
  21. ServerName pma.abc.com
  22. </VirtualHost>

Copy Code

Related to Nginx:
1. bbs.conf

  1. Server
  2. {
  3. Listen 80;
  4. server_name bbs.abc.com;
  5. Index index.html index.htm index.php;
  6. Root/data/bbs;
  7. #根据user_agent控制
  8. if ($http _user_agent ~ ' bingbot/2.0| mj12bot/v1.4.2| spider/3.0| Youdaobot| tomato| gecko/20100315 ') {
  9. return 403;
  10. }
  11. Location ~ admin.php {
  12. Allow 192.168.31.141;
  13. Deny all;
  14. Proxy_pass http://127.0.0.1:88;
  15. Proxy_set_header Host $host;
  16. }
  17. Location ~ \.php$ {
  18. Proxy_pass http://127.0.0.1:88;
  19. Proxy_set_header Host $host;
  20. Proxy_set_header X-real-ip $remote _addr;
  21. Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
  22. }
  23. Location ~. *\. (JS|CSS)? $
  24. {
  25. Expires 24h;
  26. Access_log off;
  27. }
  28. Location ~* ^.+\. (Gif|jpg|png|swf|flv|rar|zip|doc|pdf|gz|bz2|jpeg|bmp|xls) $ {
  29. Expires 7d;
  30. Valid_referers None blocked Server_names *.abc.com *.a.com *.b.com *.baidu.com\
  31. *.google.com *.google.cn *.soso.com;
  32. if ($invalid _referer) {
  33. return 403;
  34. #rewrite ^/http://www.example.com/nophoto.gif;
  35. }
  36. Access_log off;
  37. }
  38. rewrite ^ ([^\.] *)/topic-(. +) \.html$ $1/portal.php?mod=topic&topic=$2 last;
  39. rewrite ^ ([^\.] *)/forum-(\w+)-([0-9]+) \.html$ $1/forum.php?mod=forumdisplay&fid=$2&page=$3 last;
  40. rewrite ^ ([^\.] *)/thread-([0-9]+)-([0-9]+)-([0-9]+] \.html$ $1/forum.php?mod=viewthread&tid=$2&extra=page%3d$4&page =$3 last;
  41. rewrite ^ ([^\.] *)/group-([0-9]+)-([0-9]+) \.html$ $1/forum.php?mod=group&fid=$2&page=$3 last;
  42. rewrite ^ ([^\.] *)/space-(USERNAME|UID)-(. +) \.html$ $1/home.php?mod=space&$2=$3 last;
  43. rewrite ^ ([^\.] *)/(Fid|tid)-([0-9]+) \.html$ $1/index.php?action=$2&value=$3 last;
  44. Access_log/home/logs/discuz.log Combined_realip;
  45. }

Copy Code

2. blog.conf (Reference http://www.upupw.net/nginxhelp/n33.html)

  1. Server
  2. {
  3. Listen 80;
  4. server_name blog.abc.com;
  5. Index index.html index.htm index.php;
  6. Root/data/blog;
  7. location/wp-admin/{
  8. Allow 127.0.0.1;
  9. Deny all;
  10. Location ~ \.php$ {
  11. Proxy_pass http://127.0.0.1:88;
  12. Proxy_set_header Host $host;
  13. }
  14. }
  15. Location/{
  16. Proxy_pass http://127.0.0.1:88/;
  17. Proxy_set_header Host $host;
  18. Proxy_set_header X-real-ip $remote _addr;
  19. Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
  20. }
  21. }

Copy Code

3. pma.conf

  1. Server
  2. {
  3. Listen 80;
  4. server_name pma.abc.com;
  5. Index index.html index.htm index.php;
  6. ROOT/DATA/PMA;
  7. Location/{
  8. Auth_basic "Auth";
  9. AUTH_BASIC_USER_FILE/USR/LOCAL/NGINX/CONF/HTPASSWD;
  10. Location ~ \.php$ {
  11. Proxy_pass http://127.0.0.1:88;
  12. Proxy_set_header Host $host;
  13. Proxy_set_header X-real-ip $remote _addr;
  14. Proxy_set_header x-forwarded-for $proxy _add_x_forwarded_for;
  15. }
  16. }
  17. }

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

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.