專業設計師團隊,賦予空間新美感
裝潢設計搭配量身訂做系統家具
壁紙跳蚤防治專業團隊服務,消滅跳蚤蟲卵蛹
徹底消滅跳蚤,免費諮詢服務

首頁  •  j2h 論壇 • 程式設計討論     • 

同一 IP 設置多個虛擬站台

房東:小優
發表時間:2007-02-26


Apache2 on SuSE 9.3 設定備忘
設置密碼驗證功能
設定 SSL 加密的 http 服務
同一 IP 設置多個虛擬站台
設置密碼驗證

設定連入 /home/someone/public_html (/~someone) 時啟用密碼驗證

su - someone

/usr/sbin/htpasswd2 -c .htpasswd admin

New password: password_for_admin
Re-Type new password: password_for_admin

vi public_html/.htaccess

AuthType Basic
AuthName "Password Required"
AuthUserFile "/home/someone/.htpasswd"
Require user admin
or
Require valid-user

設定 SSL 加密的 http 服務

製作 SSL 憑證

openssl req -new -x509 -newkey rsa:1024 -days 3650 -keyout server.key -out server.crt

Enter PEM pass phrase: your_phrase
Verifying - Enter PEM pass phrase: your_phrase

Country Name (2 letter code) [AU]: TW
State or Province Name (full name) [Some-State]: Taiwan
Locality Name (eg, city) []: Taipei
Organization Name (eg, company) [Internet Widgits Pty Ltd]: My Labs
Organization Unit Name (eg, section) []: MIS
Common Name (eg, YOUR name) []: www.mydomain.com (same as web server name)
Email Address []: [email protected]

openssl req --help for listing options

openssl rsa -in server.key -out server.key

Enter pass phrase for server.key: your_phrase

mv server.key /etc/apache2/ssl.key/

mv server.crt /etc/apache2/ssl.crt/

Apache2 HTTP Server 環境設定

vi /etc/sysconfig/apache2

APACHE_SERVER_FLAGS="-D SSL"

cd /etc/apache2/vhosts.d

cp vhost-ssl.template vhost-ssl.conf

vi vhost-ssl.conf

#
#

...

#

#


重新啟動 Apache2 httpd

/etc/init.d/apache2 restart

httpd2 -S

VirtualHost configuration:

_default_:443 www.mydomain.com (/etc/apache2/vhosts.d/vhost-ssl.conf:35)

Syntax OK

netstat -ntulp | grep httpd

tcp 80 LISTEN httpd2-prefor
tcp 443 LISTEN httpd2-prefor

同一 IP 設置多個虛擬站台

echo "NameVirtualHost *:80" >> /etc/apache2/default-server.conf

cd /etc/apache2/vhosts.d

cat vhost.template | tee www1.conf www2.conf > /dev/null

vi www1.conf

ServerName www1.mydomain.com
DocumentRoot /srv/www/vhosts/www1
ScriptAlias /cgi-bin/ "/srv/www/vhosts/www1/cgi-bin"

...

...

vi www2.conf

same as above, but www1 → www2

vi www.conf (for default server)



ServerName www.mydomain.com



mkdir -p /srv/www/vhosts/www1/cgi-bin /srv/www/vhosts/www2/cgi-bin

/etc/init.d/apache2 reload

httpd2 -S

*:80 is a NameVirtualHost
default server www.mydomain.com (/etc/apache2/vhosts.d/www.conf:1)
port 80 namevhost www.mydomain.com (/etc/apache2/vhosts.d/www.conf:1)
port 80 namevhost www1.mydomain.com (/etc/apache2/vhosts.d/www1.conf:13)
port 80 namevhost www2.mydomain.com (/etc/apache2/vhosts.d/www2.conf:13)




  • 贊助網站       

    廣利不動產-新板特區指名度最高、值得您信賴的好房仲
    您的托付,廣利用心為您服務
    廣利不動產-板橋在地生根最實在--新板特區指名度最高、值得您信賴的好房仲
    完整房訊,房屋、店面熱門精選物件,廣利不動產 優質仲介,房屋租賃、買賣資訊透明,交易真安心!



  •  共 0 人回應

    姓名:
    佈告內容:
    其他選項: