1、apache虚拟主机: <VirtualHost *:80> DocumentRoot 路径 ServerName 域名 ServerAlias ucenter.com ErrorLog "/logs/域名-error_log" CustomLog "/logs/域名-access_log" </VirtualHost> <Directory "路径"> Options FollowSymLinks AllowOverride None Order deny,allow Allow from all </Directory>
2、apache虚拟目录: Alias /虚拟目录名/ "/myweb" <Directory "/myweb"> Options Indexes MultiViews AllowOverride None Order allow,deny Allow from all </Directory>
3、WEB登陆认证访问: <VirtualHost *:80> DocumentRoot /var/www/html <Directory "/var/www/html"> authtype basic authname "Please input Password" #提示信息 authuserfile /etc/httpd/.passwd #认证文件路径.passwd未隐藏文件 require user user1 #用户必须输入密码访问 </Directory> </VirtualHost> htpasswd -cm /etc/httpd/.passwd user1 #此处密码与用户的系统密码无关 service httpd restart
4、nginx虚拟主机: 1). 进入 /usr/local/nginx/conf/vhost 目录, 创建虚拟主机配置文件 test.com.conf 2). 打开配置文件, 添加服务如下: server { listen 80; server_name www.test.com; index index.html index.htm index.php; root /var/www/test.com; access_log /var/log/test.com.log test.com; } 3) . 打开 Nginx 配置文件 /usr/local/nginx/conf/nginx.conf, 添加加载虚拟主机配置: include vhost/*.conf; 4). 重启 Nginx 服务: service nginx restart
5、tomcat虚拟主机: tomcat/conf/server.xml <Host name="www.test.com" appBase="/web" unpackWARs="true" autoDeploy="true" xmlValidation="false" xmlNamespaceAware="false"> <Context path="/" (虚拟目录名)docBase=""(虚拟目录路径) debug=”0” /> </Host>
|