1.找到apache2 的设置路径
默认的apache的路径为/etc/apache2/
2. 修改httpd.conf
本文192.168.0.1 为自己的服务器的ip,下面一样的意思
ServerName 192,168.0.1:80
NameVirtualHost 192,168.0.1.166
3. 修改 /etc/apache2/sites-available/default文件 此文件为第一个网站的域名绑定信息
Servername qq.com ServerAdmin webmaster@localhost DocumentRoot /var/www Options FollowSymLinks #AllowOverride None AllowOverride ALL Options Indexes FollowSymLinks MultiViews #AllowOverride None AllowOverride ALL Order allow,deny allow from all ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all ErrorLog ${APACHE_LOG_DIR}/error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access.log combined Alias /doc/ "/usr/share/doc/"Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128
4. 增加新的域名的配置信息/etc/apache2/sites-available/test
Servername appask.cn ServerAdmin webmaster@localhost DocumentRoot /var/www/testaaaaa Options FollowSymLinks #AllowOverride None AllowOverride ALL Options Indexes FollowSymLinks MultiViews #AllowOverride None AllowOverride ALL Order allow,deny allow from all ErrorLog ${APACHE_LOG_DIR}/error_app.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/access_app.log combined
5. 执行 sudo a2ensite test 在sites-enable可以看到多了一个指向test的软链接
6.重启apache2 : service apache2 restart
一切就Ok了