ubuntu14.04安装apache+php+mysql笔记

根据这篇文章安装的

http://blog.csdn.net/zj794318840/article/details/24366179


遇到的问题

  #无法访问 /var/www/test.php 及 /var/www 下的目录

   在访问 http://127.0.0.1/ 时默认打开了 /var/www/html/index.html

   意识到是默认文档目录不是 /var/www 而是 /var/www/html


   google apache更改文档目录, 发现默认配置在 /etc/apache2/sites-available/000-default.conf

   更改默认文档目录:

     1. 修改 /etc/apache2/sites-available/000-default.conf 中的 DocumentRoot /var/www/html 为你想要的路径

     2. sudo service apache2 restart


   更为一般的做法:

    1. 创建自己新的站点sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mynewsite

          然后配置 mynewsite.

    2. 根据自己需求

        启用站点 sudo a2ensite yourneedsite

        禁用站点 sudo a2dissite yourneedsite

    3.sudo service apache2 restart


   这里有更详细的 apache web server 配置文档 https://help.ubuntu.com/lts/serverguide/httpd.html

 

  #AH00558:

      AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1.

      Set the 'ServerName' directive globally to suppress this message


    1.在 /etc/apache2/apache2.conf 中添加  ServerName localhost

    2.sudo service apache2 restart


  #安装了 larave 框架, 但只能访问根路由 $project/public, 不能访问别的路由

    经过一番折腾:

    # apache2 读取配置文件时, 首先读取 /etc/apache2/apache2.conf, 然后读取IncludeOptional 后指定的文件

       我的没有指定 httpd.conf 文件, 所以按网上说的配置 httpd.conf 自然全然无效, 坑..

       如果我们想加入自己的配置文件则使用IncludeOptional 指定.

   

    1.将 apache2.conf

     <Directory />
         Options FollowSymLinks
         AllowOverride None
         Require all denied
     </Directory>

     <Directory /usr/share>
         AllowOverride None
         Require all granted
     </Directory>
   
     <Directory /var/www/>
         Options Indexes FollowSymLinks
         AllowOverride None
         Require all granted
     </Directory>
         修改为

     <Directory />
         Options FollowSymLinks
         AllowOverride ALL
         Require all denied
     </Directory>

     <Directory /usr/share>
         AllowOverride None
         Require all granted
     </Directory>
   
     <Directory /var/www/>
         Options Indexes FollowSymLinks
         AllowOverride ALL
         Require all granted
     </Directory>

             AllowOverride 指令控制对应目录下的 .htaccess 文件可使用的指令

        而 .htaccess 文件的名字可以由 AccessFilename 指定.

  2.加载 rewrite_module

    在对应的配置文件中写入(我写到了/etc/apache2/sites-available/000-default.conf视自己情况定)

   LoadModule rewrite_module /usr/lib/apache2/modules/mod_rewrite.so

  3. sudo server apache2 restart

    这样 laravel 的路由问题就解决了

    详细情况可以查看官网文档 http://httpd.apache.org/docs

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值