Ubuntu-server基于多端口建立虚拟主机步骤:

来源:互联网 发布:创新的社会网络 上海 编辑:程序博客网 时间:2024/06/07 02:44

Ubuntu-server基于多端口建立虚拟主机步骤:

Ubuntu-server和centos-server不同,Ubuntu-server的apache配置文档有多个,在这里主要用到/etc/apache2/ports.conf、/etc/apache2/sites-available/、

1、首先把数据库导入,项目放到/var/www/下

2、打开/etc/apache2/ports.conf文档,添加你想要开放的端口(81):

NameVirtualHost *:81

Listen 81

保存并退出。

3、在/etc/apache2/sites-available/下copy文档default并重新命名,名称和项目名称(moleculeLab)一致,修改内容如下:

<VirtualHost *:81>

       ServerName*:81  

       DocumentRoot/var/www/moleculeLab

       ErrorLog/var/logs/moleculeLab-error_log

    CustomLoglogs/moleculeLab-access_log common     

</VirtualHost>

保存并退出。

4、在/etc/apache2/sites-enabled/下建立001-default文档,内容与000-default类似

<VirtualHost *:81>

       ServerAdminwebmaster@localhost

       DocumentRoot/var/www/moleculeLab

       <Directory/>

              OptionsFollowSymLinks

              AllowOverrideNone

       </Directory>

       <Directory/var/www/>

              OptionsFollowSymLinks MultiViews

              AllowOverrideNone

              Orderallow,deny

              allowfrom all

       </Directory>

</VirtualHost>

保存并退出

5、发布网站sudo ln -s /etc/apache2/sites-available/moleculeLab/etc/apache2/sites-enabled/001-default

6、重启apache:/etc/init.d/apache2restart 完成!

                                                

                                                                                                        

---2014-02-24

0 0