【Linux】Centos7 下使用Apache 配置网站虚拟地址, 另附 laravel 虚拟地址配置
最近使用laravel 搞項目,配置本地開發環境,很是頭疼,不知道是什么情況,簡單直白地總結一下,附上配置詳情
電腦環境: Centos7 + lamp
你的電腦上有Apache
Apache配置文件地址 /usr/local/apache/conf/httpd.conf 說明: 查了許多,各個系統配置文件不一樣,請領會意思
<Directory />AllowOverride AllRequire all deniedAllow from allOptions IndexesOrder 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 +MultiViewsAllowOverride AllRequire 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 下
總結
以上是生活随笔為你收集整理的【Linux】Centos7 下使用Apache 配置网站虚拟地址, 另附 laravel 虚拟地址配置的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Cento7 PHP5.6 升级 PH
- 下一篇: Linux系统下命令行连接蓝牙设备