【问题标题】:Configuring laravel apache2 to load public fails配置 laravel apache2 加载公共失败
【发布时间】:2018-01-22 23:34:53
【问题描述】:

我想将 laravel 配置为每当用户访问 domain/api 他实际访问公用文件夹时

我已经尝试了以下

1.创建了一个文件 laravel.conf

<VirtualHost *:80>
   ServerName ipaddress/api

   ServerAdmin webmaster@localhost
   DocumentRoot /var/www/html/api/public

  <Directory /var/www/html/api>
     AllowOverride All
  </Directory>

  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

然后

sudo a2dissite 000-default.conf //disabled defaul loading
sudo a2ensite laravel.conf
sudo a2enmod rewrite
sudo service apache2 restart

但是现在上面的失败了

但是在 virtualHost 配置上,当我在没有 api 的情况下创建 servername to ipaddress 时,每当我访问它读取 api/public 的 IP 地址时,我希望它在用户访问时读取 api/public

ipaddress/api.

我还需要补充什么?

我在关注 This tutorial

【问题讨论】:

    标签: php apache laravel-5


    【解决方案1】:

    我不是 Apache 配置方面的专家,所以我不确定你所拥有的和教程使用的有什么不同。

    但是,我的网站设置类似,但我的网站看起来有点不同:

     DocumentRoot /var/www/website/public
    
     <Directory /var/www/website/public>
         Options Indexes FollowSymLinks MultiViews
         AllowOverride All
         Order allow,deny
         allow from all
      </Directory>
    

    放入配置的上下文中:

    <VirtualHost *:80>
       ServerName ipaddress/api
    
       ServerAdmin webmaster@localhost
       DocumentRoot /var/www/html/api/public
    
      <Directory /var/www/html/api/public>
         Options Indexes FollowSymLinks MultiViews
         AllowOverride All
         Order allow,deny
         allow from all
      </Directory>
    
      ErrorLog ${APACHE_LOG_DIR}/error.log
      CustomLog ${APACHE_LOG_DIR}/access.log combined
    </VirtualHost>
    

    也许试试看是否有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-02-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-13
      • 2016-06-21
      • 1970-01-01
      相关资源
      最近更新 更多