最近使用laravel 搞项目,配置本地开发环境,很是头疼,不知道是什么情况,简单直白地总结一下,附上配置详情
电脑环境: Centos7 + lamp
-
你的电脑上有Apache
-
Apache配置文件地址
/usr/local/apache/conf/httpd.conf
说明: 查了许多,各个系统配置文件不一样,请领会意思<Directory /> AllowOverride All Require all denied Allow from all Options Indexes Order deny,allow </Directory> # Virtual hosts Include conf/extra/httpd-vhosts.conf //去掉前面的 # ,开启虚拟地址配置文件路径
-
找到虚拟地址这个文件
conf/extra/httpd-vhosts.conf
<VirtualHost *:80> ServerName <你自定义的域名> DocumentRoot <你的项目地址> <Directory "<你的项目地址>"> Options +Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All Require local </Directory> </VirtualHost>
-
配置
hosts
,文件/etc/hosts
# 域名要和虚拟地址中的一致 127.0.0.1 <你自定义的域名>
-
重启httpd 服务
sudo service httpd restart
其中又遇到这样的问题
使用sudo systemctl restart httpd.service
开 启服务之后查看状态,报错了(不知道是机器配置问题,还是其他)
[root@xx /]#httpd status
Looking up localhost
Making HTTP connection to localhost
Alert!: Unable to connect to remote host.
lynx: Can’t access startfile http://localhost/server-status
解决方法;
sudo service httpd start
-
浏览器访问
<你自定义的域名>
又报错了 :Forbidden You don't have permission to access / on this server.
这应该是大部分同学遇到的问题,很明了的问题,权限
chmod -R 777 <你的文件夹名称>
搞定了,
对了, laravel 的地址 指向 根目录/public
下