在Apache2/sites-enabled 下添加vhosts.conf文件,内容如下,保存重启apache 就行了。
<Directory "/home/www/*">
# Options Indexes MultiViews
Options All ExecCGI FollowSymLinks Indexes
AllowOverride All
Order allow,deny
Allow from all
# AuthName "Login dev website"
# AuthType Basic
# AuthUserFile /home/websites/.htpasswd
# require valid-user
</Directory>
Listen 8022
#NameVirtualHost *:8022
<VirtualHost *:8022>
ServerName demo.com
ServerAlias demo.cn
Options All ExecCGI FollowSymLinks Indexes
DirectoryIndex index.php
DocumentRoot /home/www/demo
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
80端口在Apache2/sites-enabled/000-default.conf
添加内容如下:
<VirtualHost *:80>
DirectoryIndex index.php
ServerAdmin niuzai369@126.com
DocumentRoot "/home/www/pp"
ServerName ppinvoice.cn
<Directory "/home/www/pp">
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
重启apache : service apache2 restart
<Directory "/home/www/*">
# Options Indexes MultiViews
Options All ExecCGI FollowSymLinks Indexes
AllowOverride All
Order allow,deny
Allow from all
# AuthName "Login dev website"
# AuthType Basic
# AuthUserFile /home/websites/.htpasswd
# require valid-user
</Directory>
Listen 8022
#NameVirtualHost *:8022
<VirtualHost *:8022>
ServerName demo.com
ServerAlias demo.cn
Options All ExecCGI FollowSymLinks Indexes
DirectoryIndex index.php
DocumentRoot /home/www/demo
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
80端口在Apache2/sites-enabled/000-default.conf
添加内容如下:
<VirtualHost *:80>
DirectoryIndex index.php
ServerAdmin niuzai369@126.com
DocumentRoot "/home/www/pp"
ServerName ppinvoice.cn
<Directory "/home/www/pp">
Options FollowSymLinks
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
重启apache : service apache2 restart