如何使用2 laravel项目设置apache

如何使用2 laravel项目设置apache,laravel,apache,ubuntu,apache2,Laravel,Apache,Ubuntu,Apache2,首先,我复制000-default.conf cp 000-default.conf演示 然后,我在网站链接演示可用 ln -s ../sites-available/demo demo 这是我的000 default.conf我想在www.example.com中设置项目运行 <VirtualHost *:80> ServerName example.com ServerAlias demo.example.com/ DocumentRoot /va

首先,我复制000-default.conf

cp 000-default.conf演示

然后,我在网站链接演示可用

ln -s ../sites-available/demo demo
这是我的
000 default.conf
我想在www.example.com中设置项目运行

<VirtualHost *:80>
     ServerName example.com
     ServerAlias demo.example.com/
     DocumentRoot /var/www/html/test/
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combin
    </VirtualHost>
<VirtualHost *:80>
 ServerName www.example.com
 DocumentRoot /var/www/html/main/public
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
 <Directory /var/www/html/main/public>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Require all granted
        </Directory>
</VirtualHost>

ServerName example.com
ServerAlias demo.example.com/
DocumentRoot/var/www/html/test/
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
这是我想在demo.example.com中运行的演示文件

<VirtualHost *:80>
     ServerName example.com
     ServerAlias demo.example.com/
     DocumentRoot /var/www/html/test/
     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combin
    </VirtualHost>
<VirtualHost *:80>
 ServerName www.example.com
 DocumentRoot /var/www/html/main/public
 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
 <Directory /var/www/html/main/public>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Require all granted
        </Directory>
</VirtualHost>

服务器名www.example.com
DocumentRoot/var/www/html/main/public
ErrorLog${APACHE_LOG_DIR}/error.LOG
CustomLog${APACHE\u LOG\u DIR}/access.LOG组合
选项索引跟随符号链接多视图
允许超越所有
要求所有授权

在运行服务apache2 restart之后,我只能进入www.example.com,但无法进入demo.example.com。我不确定我做错了什么,所以我觉得有必要说几句话——首先,我总是在复制的文件上留下
.conf
。其次,我总是使用
a2ensite
a2dispate
来启用和禁用任何站点


如果您使用的是
example.com
域名,我也会在这种情况下禁用默认站点。如果您的默认站点当前未启用,这就是为什么您无法访问
demo.example.com
-如果您希望访问该站点,您需要通过运行
a2ensite 000 default

来启用它,因此我觉得有必要说几句话-首先,我总是在复制的文件上保留
.conf
。其次,我总是使用
a2ensite
a2dispate
来启用和禁用任何站点

如果您使用的是
example.com
域名,我也会在这种情况下禁用默认站点。如果您的默认站点当前未启用,这就是为什么您无法访问
demo.example.com
-如果您希望访问该站点,则需要通过运行
a2ensite 000 default来启用它