[root@localhost ~]# yum install -y apr apr-util httpd Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager. Package apr-1.4.8-3.el7_4.1.x86_64 already installed and latest version Package apr-util-1.5.2-6.el7.x86_64 already installed and latest version Package httpd-2.4.6-80.el7.x86_64 already installed and latest version Nothing to do
2.编辑Apache主配置文件,在相应的区域中加入以下标★语句.
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
146 # 147 # AllowOverride controls what directives may be placed in .htaccess files. 148 # It can be "All", "None", or any combination of the keywords: 149 # Options FileInfo AuthConfig Limit 150 # ★ AllowOverride all #修改为 AllowOverride all 152 153 # 154 # Controls who can get stuff from this server. 155 #
[root@localhost ~]# vim /etc/httpd/conf.d/userdir.conf
14 # of a username on the system (depending on home directory 15 # permissions). 16 # 17 # UserDir disabled #注释掉本行 18 ...... 20 # To enable requests to /~user/ to serve the user's public_html 21 # directory, remove the "UserDir disabled" line above, and uncomment 22 # the following line instead: 23 # 24 UserDir public_html #开启本行注释 25 </IfModule>
2.创建一个测试用户,并在其家目录创建一个public_html目录,设置相应的权限.
[root@localhost ~]# useradd lyshark [root@localhost ~]# echo "123123" |passwd --stdin lyshark Changing password for user lyshark. passwd: all authentication tokens updated successfully.
[root@localhost home]# ls -lZ drwxr-xr-x. lyshark lyshark unconfined_u:object_r:user_home_dir_t:s0 lyshark
[root@localhost home]# ls -lZ /var/www/ drwxr-xr-x. root root system_u:object_r:httpd_sys_content_t:s0 html
[root@localhost home]# yum provides semanage [root@localhost home]# yum install -y policycoreutils-python-2.5-22.el7.x86_64 Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager. Package policycoreutils-python-2.5-22.el7.x86_64 already installed and latest version Nothing to do
[root@localhost ~]# yum install -y apr apr-util httpd Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager. Package apr-1.4.8-3.el7_4.1.x86_64 already installed and latest version Package apr-util-1.5.2-6.el7.x86_64 already installed and latest version Package httpd-2.4.6-80.el7.x86_64 already installed and latest version Nothing to do
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
38 # Change this to Listen on specific IP addresses as shown below to 39 # prevent Apache from glomming onto all bound IP addresses. 40 # 41 #Listen 12.34.56.78:80 42 Listen 80 43 Listen 8080 ..... 76 # All of these directives may appear inside <VirtualHost> containers, 77 # in which case these default settings will be overridden for the 78 # virtual host being defined. 79 # 80 81 <VirtualHost 192.168.1.10:80> 82 DocumentRoot /var/www/html/vhost1 83 ServerName localhost 84 <Directory /var/www/html/vhost1> 85 AllowOverride None 86 Require all granted 87 </Directory> 88 </VirtualHost> 89 <VirtualHost 192.168.1.10:8080> 90 DocumentRoot /var/www/html/vhost2 91 ServerName localhost 92 <Directory /var/www/html/vhost2> 93 AllowOverride None 94 Require all granted 95 </Directory> 96 </VirtualHost>
[root@localhost ~]# yum install -y bind bind-chroot Loaded plugins: product-id, search-disabled-repos, subscription-manager This system is not registered with an entitlement server. You can use subscription-manager. Package 32:bind-9.9.4-61.el7.x86_64 already installed and latest version Package 32:bind-chroot-9.9.4-61.el7.x86_64 already installed and latest version Nothing to do