<Directory "/var/www/html"> Options Indexes FollowSymLinks AllowOverride None Require all granted </Directory>
# vim /etc/httpd/conf.d/userdir.conf <IfModule mod_userdir.c> UserDir www </IfModule> <Directory "/home/*/www"> AllowOverride FileInfo AuthConfig Limit Indexes Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec Require method GET POST OPTIONS </Directory> # apachectl configtest Syntax OK # systemctl restart httpd
$ chmod 711 ~student $ mkdir ~student/www $ echo "check student web page" > ~student/www/index.html之後在網址列輸入 http://your.host.name/~student 查閱是否有資料即可!
# vim somefile.sh
#!/bin/bash
if [ "${var}" == "" ]; then
程式碼寫在這裡
fi
第一列是宣告底下為甚麼語法寫的程式腳本,而 if 跟中括號之間,需要有空格隔開,這個是重點!不然程式碼會出錯。
另外,如果需要外帶參數,則參數的變數名稱為 ${1} 才對!<Directory "/some/where"> Options XXX AllowOverride XXX Require ip XXX Require ip XXX </Directory> # apachectl configtest Syntax OK # systemctl restart httpd
<Directory "/some/where"> Options XXX AllowOverride AuthConfig </Directory> # systemctl restart httpd
# vim .htaccess
AuthType basic
AuthName "你要顯示到彈出式視窗的文字"
AuthUserFile /some/auth/filename
require user 帳號名稱
# require valid-user
# htpasswd [-c] /some/auth/filename username
DocumentRoot "/var/www/https" ServerName your.host.name:443重新啟動過 httpd 之後,即可生效了!