apache 安装及基本测试
# tar xvf httpd-2.2.22.tar.gz
# ./configure --prefix= /usr/local/apache2
# make
# make install
cd /usr/local/apache2/bin
./apachectl start #启动apache
打开web 浏览器 显示 it works
单ip单端口 多域名实例
NameVirtualHost 指令是专门用在基于域名的访问方式中的,因此在基于域名的配置中,它是必须的,在基于 IP 的配置中,非必要。同样的 ServerName 也是必须的。
NameVirtualHost 跟 VirtualHost 一样,官方都建议使用 IP 形式的 addr 而非 hostname。接下来的所有操作均参照文档上的建议。
实例1:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/a
ServerName a.jaseywang.me
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/b
ServerName b.jaseywang.me
ServerAlias aaa.a.jaseywang.me
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/c
ServerName c.jaseywang.me
</VirtualHost>
实例2:
NameVirtualHost 192.168.1.88:80
#或者 NameVirtualHost *:80
<VirtualHost 192.168.1.88:80 >
#或者 <VirtualHost *:80 >
ServerAdmin webmaster@163.com
DocumentRoot /usr/local/apach2/htdocs/web2
ServerName web2.com
ServerAlias *.web2.com
DirectoryIndex web2.html
ErrorLog /usr/local/apach2/htdocs/web2/error_log
TransferLog /usr/local/apach2/htdocs/web2/access_log
</VirtualHost>
<VirtualHost 192.168.1.88:80 >
#或者 <VirtualHost *:80 >
ServerAdmin webmaster@163.com
DocumentRoot /usr/local/apach2/htdocs/web1
ServerName web1.com
ServerAlias *.web1.com
DirectoryIndex web1.html
ErrorLog /usr/local/apach2/htdocs/web1/error_log
TransferLog /usr/local/apach2/htdocs/web1/access_log
</VirtualHost>
转载于:https://blog.51cto.com/czq227/819813