cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak
vi /etc/httpd/conf/httpd.conf
250行 ServerAdmin root@localhost
354行 UserDir disable 修改成--> #UserDir disable
361行 #UserDir public_html 修改成--> UserDir www
354行 UserDir disable 修改成--> #UserDir disable
361行 #UserDir public_html 修改成--> UserDir www
#將個人網頁資料夾改成由 public_html 改成 www,方便輸入
390行 DirectoryIndex index.html index.html.var 修改成--> DirectoryIndex index.html index.htm index.php index.html.var
730行 LanguagePriority zh-TW en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN
730行 LanguagePriority zh-TW en ca cs da de el eo es et fr he hr it ja ko ltz nl nn no pl pt pt-BR ru sv zh-CN
746行 AddDefaultCharset UTF-8 修改成--> #AddDefaultCharset UTF-8
/etc/rc.d/init.d/httpd start
chkconfig httpd on
注意:web server 架設好之後,個人網頁的功能也啟動了,只要輸入「http://IP/~xxx」即可瀏覽,不過請確定 SELinux 的功能是關閉的,否則將無法正常瀏覽個人網頁。
關閉 SELinux
vi /etc/sysconfig/selinux
SELINUX=enforcing 改成--> SELINUX=disabled
限制網頁連線範圍
mkdir /var/www/html/test1vi /etc/httpd/conf/httpd.conf
在檔案最後面新增下面區段
<Directory /var/www/html/test1>
Deny from all
Allow from 192.168.1.0/255.255.255.0
Options Indexes FollowSymLinks
</Directory>
/etc/rc.d/init.d/httpd restart Deny from all
Allow from 192.168.1.0/255.255.255.0
Options Indexes FollowSymLinks
</Directory>
測試:w3m http://IP/test1/
使用帳號密碼認證保護資料夾
vi /etc/httpd/conf/httpd.conf
326行 AllowOverride None 修改成--> AllowOverride All
/etc/rc.d/init.d/httpd restart
mkdir /var/www/html/test2
cd /var/www/html/test2
htpasswd -c .htpasswd sysadm
ls -al
vi .htaccess
AuthUserFile /var/www/html/test2/.htpasswd
AuthName "Top Secret"
AuthType Basic
require valid-user
測試:w3m http://IP/test2/AuthName "Top Secret"
AuthType Basic
require valid-user
修改密碼:htpasswd -m .htpasswd sysadm
新增使用者:htpasswd .htpasswd user2
網頁記錄檔分析 - Webalizer
Webalizer 官方網站:http://www.mrunix.net/webalizer/yum -y install webalizer
cp /etc/httpd/conf.d/webalizer.conf /etc/httpd/conf.d/webalizer.conf.bak
vi /etc/httpd/conf.d/webalizer.conf
Alias /usage /var/www/usage
<Location /usage>
Order deny,allow
Deny from all
Allow from 127.0.0.1 修改成--> Allow from 192.168.1.0/255.255.255.0
Allow from ::1
# Allow from .example.com
</Location>
/usr/bin/webalizer
/etc/rc.d/init.d/httpd restart
測試:w3m http://IP/usage/
more /etc/cron.daily/00webalizer
httpd log位置:ll /var/log/httpd/
Webalizer 官方文件:ftp://ftp.mrunix.net/pub/webalizer/README
讓使用者新建帳號後 家目錄自動產生www
#cd /etc/skel
#mkdir www
這樣新增使用者後 將會在其家目錄自動新增資料夾
新建檔案及目錄的預設權限修正 /etc/login.defs
新建檔案及目錄的預設權限 : umask (/etc/login.defs)
目錄權限 : 777
檔案權限 : 666
系統預設umask 0022 :
即目錄777 drwxrwxrwx 減 0022 d----w--w- 等於 drwxr-xr-x
檔案666 -rw- rw- rw- 減 0022 - ----w--w- 等於 - rw-r--r--
umask=022 使用者新增的檔案才有權限呈現在網頁中

設定完就可以測試一下,測試步驟
#useradd test 新增使用者名稱為test
#passwd test 建立test這位使用者的密碼為test
ftp至server 用test的帳號密碼登入後,將網頁相關檔案上傳到
public_html資料夾。
最後再開啟網頁 http://ServerIP/~test/index.htm
就可以看到test這位使用者透過ftp上傳至網頁資料夾的首頁了
沒有留言:
張貼留言