日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

lamp/lnmp实例

發布時間:2024/4/15 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 lamp/lnmp实例 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

實現需求如下:

1. 準備兩臺centos 6,其中一臺機器跑mysql,另外一臺機器跑apache和nginx + php?

2. 同時安裝apache和nginx,其中nginx啟動80端口,用來跑靜態對象(圖片、js、css),apache監聽88端口,負責跑動態頁(php相關的),并且需要由nginx代理對外訪問

3. mysql服務器需要開啟慢查詢日志

4. 搭建discuz、wordpress以及phpmyadmin,域名分別為bbs.abc.com, blog.abc.com, pma.abc.com

5. 配置discuz的偽靜態(nginx)

6. apache不需要記錄日志,nginx記錄日志,但不記錄圖片等靜態頁的日志,并且配置日志切割

7. 配置圖片防盜鏈(nginx)

8. 配置圖片緩存7天,js,css緩存1天(nginx)

9. discuz和wordpress訪問后臺限制一下ip白名單,比如只允許192.168.1.100訪問(nginx)

10. phpmyadmin整個站點需要配置用戶認證(nginx)

11. 寫一個mysql備份的腳本,每天5點執行,需要遠程拷貝到web機器上

12. 把除了百度、google外的其他常見搜索引擎蜘蛛封掉,比如(bingbot/2.0、Sogou web spider/4.0、360Spider、YisouSpider、YandexBot/3.0)(nginx)


/usr/local/apache2/conf/extra/httpd-vhosts.conf

NameVirtualHost *:88


<VirtualHost *:88>

? ? ?DocumentRoot "/www"

? ? ?ServerName abc.com

? ? ?ServerAlias www.abc.com

</VirtualHost>


<VirtualHost *:88>

? ? ?DocumentRoot "/www/discuz"

? ? ?ServerName bbs.abc.com

? ? ?ServerAlias www.bbs.abc.com

</VirtualHost>


<VirtualHost *:88>

? ? ?DocumentRoot "/www/wordpress"

? ? ?ServerName blog.abc.com

? ? ?ServerAlias www.blog.abc.com

</VirtualHost>


<VirtualHost *:88>

? ? ?DocumentRoot "/www/phpadmin"

? ? ?ServerName pma.abc.com

? ? ?ServerAlias www.pma.abc.com

</VirtualHost>



?bbs.conf

server

{

? ? listen 80;

? ? server_name bbs.abc.com;

? ? index index.html index.htm index.php;

? ? root /www/discuz;


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.16.16;

? ? ? ? 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;

? ? ? ? }


? ? ? ? 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;


location ~* ^.+\.(gif|jpg|png|swf|flv|rar|zip|doc|pdf|gz|bz2|jpeg|bmp|xls)$

{

? ? ? ? ?expires 7d;

? ? ? ? ?valid_referers none blocked server_names ?*.taobao.com *.baidu.com *.google.com *.google.cn *.soso.com ;

? ? ? ? ?if ($invalid_referer) {

? ? ? ? ?# ? ? ?return 403;

? ? ? ? ? ? ? ?rewrite ^/ http://blog.abc.com/;

? ? ? ? ? }

? ? ? ? ? access_log off;

}

?location ~ .*\.(js|css)?$

? ? {

? ? ? ? ? expires ? ? ?24h;

? ? ? ? ? access_log off;

? ? }


deny 192.168.1.0/24;

allow all;


? ? access_log /usr/local/nginx/logs/discuz.log combined_realip;


}


blog.comf

server


{

? ? listen 80;

? ? server_name blog.abc.com;

? ? index index.html index.htm index.php;

? ? root /www/wordpress;


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;

? ? ? ? }


? ? 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;

? ? ? ? }

? ? access_log /usr/local/nginx/logs/wordpress.log combined_realip;

}


pma.conf

server

{

? ? listen 80;

? ? server_name pma.abc.com;

? ? index index.html index.htm index.php;

? ? root /www/phpadmin;


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;

? ? ? ? }

? ? access_log /usr/local/nginx/logs/pma.log combined_realip;

}


日志切割.sh

#!/bin/bash

#

exec &> /dev/null

d=`date -d "-1 day" +%Y%m%d`

/bin/mv ? /usr/local/nginx/logs/discuz.log ? /usr/local/nginx/logs/$d.discuz.log

/usr/local/nginx/sbin/nginx -s reload

find /tmp/ -type f -mtime +30|xargs rm -f


轉載于:https://blog.51cto.com/onelinux/1653131

與50位技術專家面對面20年技術見證,附贈技術全景圖

總結

以上是生活随笔為你收集整理的lamp/lnmp实例的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。