LAMP環境下搭建discuz!論壇javascript
1、下載discuz!php
1、建立目錄css
mkdir /data/wwwhtml
2、進入目錄
java
cd /data/wwwmysql
3、下載discuzlinux
wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zipsql
4、解壓discuz數據庫
unzip Discuz_X3.2_SC_GBK.zipapache
5、把upload目錄中的文件移動到當前目錄下,也就/data/www/目下
mv upload/* .
6、刪除掉其餘的文件
[root@mysql www]# rm -rfDiscuz_X3.2_SC_GBK.zip readme/ utility/
upload空目錄也要刪除掉:[root@mysqlwww]# rm -rf upload/
2、配置第一個虛擬主機
1、用vim打開/usr/local/apache2/conf/httpd.conf文件
刪除httpd.conf中的這行前面的#號
#Include conf/extra/httpd-vhosts.conf
2、在vim /usr/local/apache2/conf/extra/httpd-vhosts.conf配置文件中
加入以下配置:
<VirtualHost *:80> DocumentRoot "/data/www" #網站的根目錄 ServerName www.guhantai.cn #主機域名 ServerAlias www.guhantai.com.cn #第二個域名 #ErrorLog "logs/dummy-host.example.com-error_log" #CustomLog "logs/dummy-host.example.com-access_log" common </VirtualHost>>
有兩個虛擬主機,刪除掉一個,
保存以後退出
3、檢查配置文件
[root@mysql www]#/usr/local/apache2/bin/apachectl -t Syntax OK #出現這個提示就說明已經好了
4、更改Windows hosts文件作解析,將www.guhantai.cn解析到Linux主機的IP
c:\Windows\System32\drivers\etc\hosts
192.168.21.97 www.guhantai.cnwww.guanhaitai.com.cn
5、在Windows瀏覽器測試的時候提示沒法找到網頁,錯誤代碼404
6、修改vim/usr/local/apache2/conf/httpd.conf文件,以下圖:
7、而後使用以下命令來檢測配置文件是否OK:
[root@mysql www]# /usr/local/apache2/bin/apachectl -t Syntax OK #出現這個表示配置文件時正確的
八、重啓apache服務
[root@mysqlwww]# /usr/local/apache2/bin/apachectl restart
9、再次在瀏覽器中輸入http://www.guhantai.cn/install/的時候訪問正常,出現了Discuz的安裝嚮導界面,以下圖:
10、點擊「我贊成」
11、進入到下一步界面,紅色的「x」表示是沒有寫權限,如圖所示:
12、使用[root@mysql www]#ps aux |grep http查看Apache使用的帳號是daemon
13、給daemon帳號受權,讓daemon帳號對支持Apache的目錄進行可寫的操做
[root@mysqlwww]# chown -R daemon data/ config/ uc_server/data/ uc_client/data/
14、再次刷新時,紅色的「x」消失了,變成寫的了
15、點擊下一步
進入到設置運行環境界面,選擇全新安裝,下一步,進入到安
裝數據庫界面
而後下一步,開始安裝
16、安裝完成,進入論壇
17、進入論壇的管理中心以後,會出現一個提示,爲了安全起見要把install/index.php幹掉
刪除install/index.php:
[root@mysql www]# rm -rf install/index.php
3、配置mysql,給Discuz!增長一個帳戶
1、首先檢查Mysql有沒有啓動
[root@mysqlwww]# ps aux |grep mysql
2、登陸MySQL
登陸MySQL的時候提示沒有mysql這個命令,
[root@mysql www]# mysql -uroot -bash: mysql: command not found
後來查看passwd文件,發現是禁止登錄的
如今先更改PATH,容許mysql登陸:
[root@mysqlwww]# PATH=$PATH:/usr/local/mysql/bin
也能夠這樣子作:
[root@mysql www]# /usr/local/mysql/bin/mysql –uroot
如今登陸mysql就能夠登陸進去
[root@mysqlwww]# mysql –uroot
3、給mysql設定密碼
[root@mysqlwww]# mysqladmin -uroot password '123456'
123456就是msyql設定的登陸密碼
用帳號和密碼登陸msyq
[root@mysqlwww]# mysql -uroot -p123456
4、建立一個名稱爲cheng的數據庫
mysql>create database cheng;
5、建立一個用戶,用來受權
mysql>grant all on cheng.* to 'cheng'@'localhost' identified by '123456';
grant:受權
all:全部權限
identified:密碼
cheng'@'localhost:新建立的用戶,而且制定登陸本機
cheng:第4步建立的數據庫名稱
這個命令的意思,就是建立一個名稱爲cheng的用戶,只限於在本機登陸,並且對cheng這個數據庫有全部權限
4、爲某個虛擬主機配置用戶認證
一、 在虛擬主機配置文件中加入如下內容,建立apache的驗證用戶
虛擬主機配置文件位置:vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
加入如下內容:
代碼以下:
<Directory *>#這裏的*表示的是針對這臺虛擬主機來的,也能夠寫成絕對路徑/data/www
AllowOverride AuthConfig
AuthName "自定義的"
AuthType Basic
AuthUserFile /data/.htpasswd # 這裏的/data/.htpasswd你能夠隨便寫一個路徑或名字,沒有限制
require valid-user
</Directory>
二、 爲用戶建立密碼文件
[root@mysql www]# /usr/local/apache2/bin/htpasswd -c/data/.htpasswd cheng
爲cheng用戶建立密碼文件,第一次建立.htpasswd須要加上-c,若是.htpasswd已經存在,-c會覆蓋
三、 查看/data/.htpasswd文件
[root@mysqlwww]# cat /data/.htpasswd cheng:v5o0GkUDbIh8c
左邊是用戶名,冒號右邊是密碼。密碼是加密的
四、 檢查配置文件看看有錯誤沒有
[root@mysqlwww]# /usr/local/apache2/bin/apachectl -t Syntaxerror on line 35 of /usr/local/apache2/conf/extra/httpd-vhosts.conf: AuthUserFiletakes 1-2 arguments, text file containing user IDs and passwords
提示配置文件的第35行有錯誤
排錯:
使用vim查看/usr/local/apache2/conf/extra/httpd-vhosts.conf文件,看看是哪裏錯誤了
刪除多出來的那一行文字,再檢查配置文提示已經OK了
[root@mysql www]#/usr/local/apache2/bin/apachectl -t Syntax OK
在重啓一下apache服務
[root@mysql www]#/usr/local/apache2/bin/apachectl restart
五、 在此刷新網頁的時候,提示要輸入帳號和密碼才能夠訪問或者查看論壇
5、配置域名跳轉
一、 單域跳轉,將一下代碼拷貝到/usr/local/apache2/conf/extra/httpd-vhosts.conf文件中的第35行下面。具體以下圖所示:
代碼以下:
<IfModulemod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain1.com$
RewriteRule ^/(.*)$ http://www.domain2.com/$1 [R=301,L]
</IfModule>
檢查配置文件
[root@mysql www]#/usr/local/apache2/bin/apachectl -t
Syntax OK
重啓apache服務
[root@mysql www]#/usr/local/apache2/bin/apachectl restart
2、若是是多個域名,能夠這樣設置:
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^www.domain.com [OR]
RewriteCond %{HTTP_HOST} ^www.domain1.com$
RewriteRule ^/(.*)$ http://www.domain2.com/$1 [R=301,L]
</IfModule>
方法和但域名設置是同樣的,只是代碼不同而已
3、測試
在linux上測試
[root@mysql www]#curl -u cheng:123456-x127.0.0.1:80 www.guhantai.cn/forum.php -I HTTP/1.1 301 Moved Permanently Date: Sat, 13 Jun 2015 09:40:47 GMT Server: Apache/2.2.16 (Unix) DAV/2PHP/5.3.28 Location:http://www.guhantai.com.cn/forum.php Content-Type: text/html; charset=iso-8859-1
這個測試結果就是正確的
6、配置apache的訪問日誌
一、 查看日誌格式,在主配置文件裏面
[root@mysql ~]# vim /usr/local/apache2/conf/httpd.conf # LogFormat "%h %l %u %t \"%r\" %>s %b\"%{Referer}i\" \"%{User-Agent}i\"" combined #日誌格式,常用的也是這個格式 LogFormat "%h %l %u %t \"%r\" %>s %b" common <IfModule logio_module> # You need to enable mod_logio.c to use %I and %O LogFormat "%h %l %u %t \"%r\" %>s %b\"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio </IfModule>
User-Agent:用來識別瀏覽器的
二、 進入虛擬主機配置文件,配置日誌
[root@mysql ~]# vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
修改爲如下類容具體如圖:
代碼以下:
#配置日誌 ErrorLog"/usr/local/apache2/logs/dummy-host.example.com-error_log" SetEnvIf Request_URI".*\.gif$" p_w_picpath-request SetEnvIf Request_URI".*\.jpg$" p_w_picpath-request SetEnvIf Request_URI".*\.png$" p_w_picpath-request SetEnvIf Request_URI".*\.bmp$" p_w_picpath-request SetEnvIf Request_URI".*\.swf$" p_w_picpath-request SetEnvIf Request_URI".*\.js$" p_w_picpath-request SetEnvIf Request_URI".*\.css$" p_w_picpath-request CustomLog"|/usr/local/apache2/bin/rotatelogs -l/usr/local/apache2/logs/1.com-access_%Y%m%d.log 86400" combinedenv=!p_w_picpath-request </VirtualHost>
3、修改完成以後,保存退出,而且檢查配置文是否配置正確,若是正確那麼久重啓服務
[root@mysql ~]# /usr/local/apache2/bin/apachectl -t
Syntax OK
四、 重啓apache服務
[root@mysql ~]# /usr/local/apache2/bin/apachectl restart
五、 查看/usr/local/apache2/logs/目下有沒有日誌
[root@mysql www]# ls/usr/local/apache2/logs/ 1.com-access_20150613.log access_log error_log 1.com-access.log dummy-host.example.com-error_log httpd.pid
dummy-host.example.com-error_log:這個日誌是針推這個虛擬主機的
error_log:這個是針對整個apache的
|/usr/local/apache/bin/rotatelogs -l :日誌切割工具
7、配置靜態文件緩存
將一下配置文件拷貝到/usr/local/apache2/conf/extra/httpd-vhosts.conf配置文件中去。就拷貝在配置日誌文件的下面就能夠了。具體如圖:
代碼以下:
<IfModule mod_expires.c> ExpiresActive on ExpiresByType p_w_picpath/gif "access plus 1 days" ExpiresByType p_w_picpath/jpeg "access plus 24 hours" ExpiresByType p_w_picpath/png "access plus 24 hours" ExpiresByType text/css "now plus 2hour" ExpiresByType application/x-javascript "now plus 2 hours" ExpiresByType application/javascript"now plus 2 hours" ExpiresByType application/x-shockwave-flash "now plus 2 hours" ExpiresDefault "now plus 0 min" </IfModule>
保存退出
檢查配置文件是否有錯
[root@mysql www]#/usr/local/apache2/bin/apachectl -t
Syntax OK
重啓apache服務
[root@mysql www]#/usr/local/apache2/bin/apachectl restart
測試一
在根目錄建立一個1.txt文件
[root@mysql www]# touch 1.txt
在1.txt文件中寫內容
[root@mysql www]# echo "1111"> 1.txt
在Linux系統中測試
[root@mysql www]# curl -u cheng:123456-x127.0.0.1:80 www.guhantai.com.cn/1.txt -I HTTP/1.1 200 OK Date: Sat, 13 Jun 2015 21:29:58 GMT Server: Apache/2.2.16 (Unix) DAV/2PHP/5.3.28 Last-Modified: Sat, 13 Jun 2015 21:26:28GMT ETag: "a1547-5-5186ce0b0d705" Accept-Ranges: bytes Content-Length: 5 Cache-Control: max-age=0 #這裏是數字0表示的尚未緩衝文件 Expires: Sat, 13 Jun 2015 21:29:58 GMT Content-Type: text/plain
測試二
建立一個1.jpg格式的文件
[root@mysql www]# touch 1.jpg
在Linux系統中測試
[root@mysql www]#curl -u cheng:123456-x127.0.0.1:80 www.guhantai.com.cn/1.jpg -I HTTP/1.1 200 OK Date: Sat, 13 Jun 2015 21:38:39 GMT Server: Apache/2.2.16 (Unix) DAV/2PHP/5.3.28 Last-Modified: Sat, 13 Jun 2015 21:37:54GMT ETag: "a1548-0-5186d098fe20d" Accept-Ranges: bytes Cache-Control: max-age=86400 #這裏就有數字了 Expires: Sun, 14 Jun 2015 21:38:39 GMT #過時時間 Content-Type: p_w_picpath/jpeg
8、配置防盜鏈
一、在配置文件/usr/local/apache2/conf/extra/httpd-vhosts.conf加入如下代碼,代碼存放的位置如圖:
代碼:
SetEnvIfNoCase Referer"^http://www.guhantai.com.cn" local_ref SetEnvIfNoCase Referer"www.guhantai.cn" local_ref SetEnvIfNoCase Referer "^$"local_ref <filesmatch"\.(txt|doc|mp3|zip|rar|jpg|gif)"> Order Allow,Deny Allow from env=local_ref </filesmatch>
而後保存退出
二、檢查剛纔的配置文件是否有錯誤
[root@mysql www]# /usr/local/apache2/bin/apachectl -t
Syntax OK
三、重啓apache服務
[root@mysql www]# /usr/local/apache2/bin/apachectl restart
四、 測試是否成功
[root@mysql www]# curl -u cheng:123456-e"http://www.baidu.com/2.txt" -x127.0.0.1:80www.guhantai.com.cn/1.jpg -I HTTP/1.1403 Forbidden Date:Sat, 13 Jun 2015 22:37:18 GMT Server:Apache/2.2.16 (Unix) DAV/2 PHP/5.3.28 Content-Type: text/html; charset=iso-8859-1
這個就是模擬的把guhantai.com.cn網站下的1.txt文件掛載到baidu網站下去,而後經過百度網站的連接來訪問這個文件,提示不能夠訪問,說明防盜連接配置成功了,固然,這裏只是模擬,可使用百度或者其餘的均可以
9、訪問控制
1、把一下代碼複製到/usr/local/apache2/conf/extra/httpd-vhosts.conf文件中,須要注意的是要把代碼放在防盜鏈配置文件的後面才能夠,不能夠寫到前面。(實驗的最後會有全文的配置文件,必定要按照配置文檔的實驗順序才能夠,否則可能會出錯)
#訪問控制
<Directory /data/www/> <filesmatch ".*"> #匹配全部 Order deny,allow Deny from all Allow from 127.0.0.1 </filesmatch> </Directory>
退出保存
檢查配置文件
[root@mysql ~]#/usr/local/apache2/bin/apachectl -t
Syntax OK
重啓apache服務
[root@mysql ~]#/usr/local/apache2/bin/apachectl restart
瀏覽器訪問測試成功
在Linux上測試是OK的
[root@mysql www]# curl -u cheng:123456-x127.0.0.1:80 www.guhantai.com.cn/1.jpg -I HTTP/1.1 200 OK Date: Sun, 14 Jun 2015 04:33:42 GMT Server: Apache/2.2.16 (Unix) DAV/2PHP/5.3.28 Last-Modified: Sat, 13 Jun 2015 21:37:54GMT ETag: "a1548-0-5186d098fe20d" Accept-Ranges: bytes Content-Type: p_w_picpath/jpeg
這應用場景通常在針對某個特殊的目錄來的能夠這樣子寫
<Directory /data/www/adc> 這個寫法就是針對abc這個目錄來的
2、針對請求的uri去限制,只容許內網和指定的ip才能夠訪問包含admin關鍵詞的地址
<filesmatch "(.*)admin(.*)">
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.21.100
</filesmatch>
這裏的兩個IP地址的意思就是說,除了這兩IP地址以外,其餘的IP地址及訪問帶有admin關鍵字時會直接禁止
修改完配置文件以後必定要檢查配置文件,而後在重啓apache服務
3、某個目錄下禁止解析php,作這個實驗的是時候最好的是吧以前的訪問控制和精緻訪問admin後臺的相關的配置禁用掉,以避免出錯都是在/usr/local/apache2/conf/extra/httpd-vhosts.conf文件中來修改配置的
<Directory /data/www/uc_server>
php_admin_flag engine off
<filesmatch "(.*)php">
Order deny,allow
Deny from all
</filesmatch>
</Directory>
修改完配置文件以後必定要檢查配置文件,而後在重啓apache服務
測試,在uc_server目下寫一個php腳本
>?php
echo 12345678;
?>
不由止會暴露php源代碼
[root@mysql www]# curl -u cheng:123456-x192.168.21.97:80 'http://www.guhantai.com.cn/uc_server/2.php' >?php echo 12345678; ?>
禁止後
[root@mysql www]# curl -u cheng:123456-x192.168.21.97:80 'http://www.guhantai.com.cn/uc_server/2.php' <!DOCTYPE HTML PUBLIC "-//IETF//DTDHTML 2.0//EN"> <html><head> <title>403 Forbidden</title> </head><body> <h1>Forbidden</h1> <p>You don't have permission toaccess /uc_server/2.php on this server.</p> </body></html>
這樣就沒法看到php的源代碼
目錄使用diectory
<Directory /data/www/ uc_server > :只要是uc_server目錄下php所有都禁用掉,這個目錄根據實際的需來寫
10、配置僞靜態規則
Mod_rewite是apache的一個很是強大的功能,它能夠實現僞靜態
一、 在discuz!管理後臺頁面—全局—左側SEO設置—URL僞靜態,右邊所有打鉤,具體以下圖所示:
二、 在/usr/local/apache2/conf/extra/httpd-vhosts.conf配置文件中加入如下代碼:
#RewriteRule^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /forum.php?mod=viewthread&tid=$1&extra=page%3D$2 RewriteRule^/topic-(.+)\.html$ /portal.php?mod=topic&topic=$1&%1 RewriteRule^/article-([0-9]+)-([0-9]+)\.html$/portal.php?mod=view&aid=$1&page=$2&%1 RewriteRule^/forum-(\w+)-([0-9]+)\.html$ /forum.php?mod=forumdisplay&fid=$1&page=$2&%1 RewriteRule^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$/forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1 RewriteRule^/group-([0-9]+)-([0-9]+)\.html$/forum.php?mod=group&fid=$1&page=$2&%1 RewriteRule^/space-(username|uid)-(.+)\.html$ /home.php?mod=space&$1=$2&%1 RewriteRule^/blog-([0-9]+)-([0-9]+)\.html$/home.php?mod=space&uid=$1&do=blog&id=$2&%1 RewriteRule^/archiver/(fid|tid)-([0-9]+)\.html$/archiver/index.php?action=$1&value=$2&%1 RewriteRule^/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ /plugin.php?id=$1:$2&%1
如圖所示位置:
12、apache限制指定user_agent,把一下代碼拷貝到/usr/local/apache2/conf/extra/httpd-vhosts.conf文件中,緊挨着域名跳轉開始
代碼以下:
<IFModulemod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} ^.*MSIE\ 8.0*[NC,OR]
RewriteCond %{HTTP_USER_AGENT} ^.*curl* [NC]
RewriteRule .* - [F]
</IFModule>
修改完配置文件以後,必定要檢查配置文件,而後在重啓apache服務
測試:
十3、附件,附時間中的實例配置文件
<VirtualHost *:80> DocumentRoot "/tmp/tmp" ServerName tmp.com <Directory /tmp/tmp/> Order allow,deny Deny from all </Directory> </VirtualHost> <VirtualHost *:80> DocumentRoot "/data/www" ServerName www.1.com ServerAlias www.a.com www.b.com ServerAlias www.c.com # 用戶認證 # <Directory /data/www> # AllowOverride AuthConfig # AuthName "alksdjflkasjdf" # AuthType Basic # AuthUserFile /data/.htpasswd # require valid-user # </Directory> # 域名跳轉 <IfModule mod_rewrite.c> RewriteEngine on # RewriteCond %{HTTP_HOST} ^www.a.com$ [OR] RewriteCond %{HTTP_HOST} !^www.1.com$ RewriteRule ^/(.*)$ http://www.1.com/$1 [R=301,L] RewriteRule ^/(.*)\.png$ /static/p_w_picpath/common/fav.gif [R=302]#這個沒有多大意義 #僞靜態規則 #RewriteRule ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /forum.php?mod=viewthread&tid=$1&extra=page%3D$2 RewriteRule ^/topic-(.+)\.html$ /portal.php?mod=topic&topic=$1&%1 RewriteRule ^/article-([0-9]+)-([0-9]+)\.html$ /portal.php?mod=view&aid=$1&page=$2&%1 RewriteRule ^/forum-(\w+)-([0-9]+)\.html$ /forum.php?mod=forumdisplay&fid=$1&page=$2&%1 RewriteRule ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /forum.php?mod=viewthread&tid=$1&extra=page\%3D$3&page=$2&%1 RewriteRule ^/group-([0-9]+)-([0-9]+)\.html$ /forum.php?mod=group&fid=$1&page=$2&%1 RewriteRule ^/space-(username|uid)-(.+)\.html$ /home.php?mod=space&$1=$2&%1 RewriteRule ^/blog-([0-9]+)-([0-9]+)\.html$ /home.php?mod=space&uid=$1&do=blog&id=$2&%1 RewriteRule ^/archiver/(fid|tid)-([0-9]+)\.html$ /archiver/index.php?action=$1&value=$2&%1 RewriteRule ^/([a-z]+[a-z0-9_]*)-([a-z0-9_\-]+)\.html$ /plugin.php?id=$1:$2&%1 RewriteCond %{HTTP_USER_AGENT} ^.*Firefox/4.0* [NC,OR] RewriteCond %{HTTP_USER_AGENT} ^.*curl* [NC] RewriteRule .* - [F] </IfModule> # 配置日誌 ErrorLog "/usr/local/apache2/logs/dummy-host.example.com-error_log" SetEnvIf Request_URI ".*\.gif$" p_w_picpath-request SetEnvIf Request_URI ".*\.jpg$" p_w_picpath-request SetEnvIf Request_URI ".*\.png$" p_w_picpath-request SetEnvIf Request_URI ".*\.bmp$" p_w_picpath-request SetEnvIf Request_URI ".*\.swf$" p_w_picpath-request SetEnvIf Request_URI ".*\.js$" p_w_picpath-request SetEnvIf Request_URI ".*\.css$" p_w_picpath-request CustomLog "|/usr/local/apache2/bin/rotatelogs -l /usr/local/apache2/logs/1.com-access__%Y%m%d.log 86400" combined env=!p_w_picpath-request # 配置靜態文件緩存 #<IfModule mod_expires.c> # ExpiresActive on # ExpiresByType p_w_picpath/gif "access plus 1 days" # ExpiresByType p_w_picpath/jpeg "access plus 24 hours" # ExpiresByType p_w_picpath/png "access plus 24 hours" # ExpiresByType text/css "now plus 2 hour" # ExpiresByType application/x-javascript "now plus 2 hours" # ExpiresByType application/javascript "now plus 2 hours" # ExpiresByType application/x-shockwave-flash "now plus 2 hours" # ExpiresDefault "now plus 0 min" #</IfModule> <Ifmodule mod_headers.c> <filesmatch "\.(html|htm|txt)$"> header set cache-control "max-age=3600" </filesmatch> <filesmatch "\.(css|js|swf)$"> header set cache-control "max-age=604800" </filesmatch> <filesmatch "\.(ico|gif|jpg|jpeg|png|flv|pdf)$"> header set cache-control "max-age=29030400" </filesmatch> </ifmodule> # 配置防盜鏈 <Directory /data/www/> SetEnvIfNoCase Referer "^http://www.1.com" local_ref SetEnvIfNoCase Referer "www.a.com" local_ref SetEnvIfNoCase Referer "www.b.com" local_ref SetEnvIfNoCase Referer "^$" local_ref <filesmatch "\.(txt|doc|mp3|zip|rar|jpg|gif)"> Order Allow,Deny Allow from env=local_ref </filesmatch> </Directory> # 訪問控制 #<Directory /data/www/admin> #<filesmatch ".*"> # Order deny,allow # Deny from all # Allow from 127.0.0.1 #</filesmatch> #</Directory> #禁止訪問admin.php後臺 #<Directory /data/www> #<Filesmatch "^admin.php(.*)$"> #匹配文件的時候在作限制 # Order deny,allow # Deny from all # Allow from 127.0.0.1 #</Filesmatch> #</Directory> #禁止某個目錄下禁止解析php <Directory /data/www/uc_server> php_admin_flag engine off <filesmatch "(.*)php"> Order deny,allow Deny from all </filesmatch> </Directory> </VirtualHost>
筆記若是有錯誤的地方,還請大神們指正出來,固然我也會繼續修改