CentOS 7 apache virtualhost

Linux 2016. 1. 15. 20:03


1. 가상호스트 설정파일을 만든다


[root@localhost conf.d]# vi /etc/httpd/conf.d/vhost.conf



파일 내용은 아래와 같다.



<VirtualHost *:80>


        DocumentRoot /home/testuser/a.test.com

        ServerName a.test.com

        ServerAlias a.test.com

        ErrorLog /var/log/httpd/a.test.com_error.log

        CustomLog /var/log/httpd/a.test.com_access.log combined


</VirtualHost>




2. userdir.conf 에서 testuser 폴더 권한을 지정해 준다.


[root@localhost conf.d]# vi /etc/httpd/conf.d/userdir.conf 



내용 끝에 아래와 같이 추가해 준다.


#

# UserDir: The name of the directory that is appended onto a user's home

# directory if a ~user request is received.

#

# The path to the end user account 'public_html' directory must be

# accessible to the webserver userid.  This usually means that ~userid

# must have permissions of 711, ~userid/public_html must have permissions

# of 755, and documents contained therein must be world-readable.

# Otherwise, the client will only receive a "403 Forbidden" message.

#

<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


    #

    # 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>


#

# Control access to UserDir directories.  The following is an example

# for a site where these directories are restricted to read-only.

#

<Directory "/home/*/public_html">

    AllowOverride FileInfo AuthConfig Limit Indexes

    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec

    Require method GET POST OPTIONS

</Directory>


<Directory "/home/testuser/*">

        Require all granted

</Directory>

"/etc/httpd/conf.d/userdir.conf" 38L, 1307C




3. 아파치를 재시작한다.


[root@localhost conf.d]# systemctl restart httpd.service





끝.




'Linux' 카테고리의 다른 글

Linux NFS iptables  (0) 2016.01.19
CentOS 7 아파치 2.4.6 한글깨짐 AddDefaultCharset  (0) 2016.01.15
CentOS 7 apache virtualhost  (1) 2016.01.15
CentOS 7 iptables 설정  (1) 2016.01.15
CentOS 7 APM yum 설치 MariaDB  (11) 2016.01.15
CentOS 7 MySQL-5.7.10 설치 boost  (0) 2016.01.11
블로그 이미지

엘로드넷

댓글을 달아 주세요