設定apache將laravel專案run起來
將laravel專案在apache上可以run
可以使用Xshell的工具連上apache
設定 Apache 建立 Laravel VirtualHost
vi /etc/httpd/conf/httpd.conf
用/
或是?
搜尋Listen然後修改後面的參數,如下
Listen *:80
儲存離開(:wq)
新增一組laravel的VirtualHost資料
vi /etc/httpd/conf.d/(專案名+port).conf
// ex: iscar_box80.conf
<VirtualHost *:80>
DocumentRoot "/var/www/html/專案名/public"
ServerName "此輸入你想要的url名稱" // ex:stage-tw-box.iscarmg.com
ErrorLog "/var/log/httpd/專案名_error.log"
CustomLog "/var/log/httpd/專案名_access.log" combined
DirectoryIndex index.php
<Directory "/var/www/html/專案名/public">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
儲存離開(:wq)
修改資料夾權限
chown -R apache.apache /var/www/html/專案名
chmod -R 755 /var/www/html/專案名
chmod -R 777 /var/www/html/專案名/storage
修改.htaccess檔
vi /var/www/html/專案名/public/.htaccess
在RewriteEngine On前新增一行
Options +FollowSymLinks
將 RewriteRule ^ index.php [L]
改為 RewriteRule ^(.+)$ /index.php [L]
儲存離開(:wq)
重啟apache
systemctl restart httpd.service
看會不會出現Laravel首頁
遇到的問題
1.當你連不上laravel
請查看httpd.conf檔裡面的DocumentRoot "這邊的路徑有沒有指到你的專案底下的public"
如果要一起run很多個專案的話請看下面的連結
Last updated
Was this helpful?