centos7编译安装apache后添加用户认证和配置虚拟主机
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了centos7编译安装apache后添加用户认证和配置虚拟主机相关的知识,希望对你有一定的参考价值。
编译安装apache后的目录文件:/usr/local/apache2
1:用户认证
主配置目录:/usr/local/apache2/conf/
1)建立目录并设置用户认证:
Alias /1.php/ “/usr/local/apache2/htdocs/1.php”
<Directory"/usr/local/apache2/htdocs/">
AllowOverride None
Options None
Order allow,deny
Deny from all
AuthType Basic
AuthName "Please Login:"
AuthUserFile /usr/local/apache2/bin/mywebpd #存密码的目录
Require User root tong #用户
</Directory>
2:配置虚拟主机/usr/local/apache2/conf/extra/httpd-vhosts.conf
配置基于IP的虚拟主机,IP地址相同,但端口号不同的虚拟主机配置,
虚拟主机分别对应的目录为/usr/local/apache/htdocs/web1和/usr/local/apache/htdocs/web2:
Listen 80
#Listen 8080
<VirtualHost 192.168.217.137:80>
ServerSignature email
DocumentRoot /usr/local/apache/htdocs/web1
DirectoryIndex web1.html
LogLevel warm
HostNameLookups off
</VirtualHost>
<VirtualHost 192.168.217.137:8080>
ServerSignature email
DocumentRoot /usr/local/apache/htdocs/web2
DirectoryIndex web2.html index.htm
LogLevel warm
HostNameLookups off
</VirtualHost>
效果图:
本文出自 “勿忘初心” 博客,转载请与作者联系!
以上是关于centos7编译安装apache后添加用户认证和配置虚拟主机的主要内容,如果未能解决你的问题,请参考以下文章
Linux CentOS7 VMware LAMP架构Apache用户认证域名跳转Apache访问日志