天天看點

apache userdir功能

userdir子產品可以很友善的和他人共享伺服器的目錄資料

該功能需要修改此配置檔案

/etc/httpd/conf.d/userdir.conf

<IfModule mod_userdir.c>

#

# UserDir is disabled by default since it can confirm the presence

# of a username on the system (depending on home directory

# permissions).

# UserDir disabled   ###########注釋掉改參數,即等于開始userdir功能

# To enable requests to /~user/ to serve the user's public_html

# directory, remove the "UserDir disabled" line above, and uncomment

# the following line instead:

  UserDir public_html       ############## 打開

</IfModule> 

#共享目錄的權限設定如下

<Directory "/home/*/public_html">

# AllowOverride FileInfo AuthConfig Limit Indexes

AllowOverride all

#添加一些認證的配置,可以用賬号,密碼通路該目錄

authuserfile "/etc/htttpd/passwd"

authname "input your accout"

authtype basic

require user jay

# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

# Require method GET POST OPTIONS

</Directory>

建立網站資料,注意權限的問題

使用普通使用者,建立共享目錄

useradd jay

su - root

mkdir  public_html  #建立共享目錄

apache userdir功能

設定該目錄權限

chmod -Rf 755 /public_html/index.html

apache userdir功能

建立阿帕奇的使用者認證檔案,注意退回到root

[root@localhost ~]# htpasswd -c /etc/httpd/

conf/ conf.d/ conf.modules.d/ logs/ modules/ run/

[root@localhost ~]# htpasswd -c /etc/httpd/passwd jay

New password:

Re-type new password:

Adding password for user jay

重新開機apache,注意修改httpd的端口 80

systemctl restart httpd

此時通路 http:ip/~使用者家目錄名 

輸入賬号密碼

虛拟主機

如果web server不支援多虛拟主機

使用者有多個業務網站,就得購買多台伺服器,造成資源浪費,成本較高 

apache userdir功能

  虛拟主機,也稱作,網站空間:

其實就是一台運作在網際網路中的伺服器,被劃分為多個"虛拟"伺服器

apache userdir功能
apache userdir功能

 基于ip的多虛拟主機

apache userdir功能
apache userdir功能
apache userdir功能
apache userdir功能

 配置apache的主配置檔案,定義多個虛拟 主機

apache userdir功能

 重新開機apache服務,加載配置

通路

apache userdir功能

總結

配置了apache的多虛拟主機功能。

在httpd.conf中定義了2個虛拟主機