编译安装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>
效果图: