根据这篇文章安装的
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
/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