如何從 apache 2.4 運行 laravel 框架

如何從 apache 2.4 運行 laravel 框架

我一整天都在嘗試獲取 laravel 歡迎螢幕,但一無所獲。

這就是我所做的:

1)透過composer將laravel安裝到/var/www/html/,如下所示:

composer create-project laravel/laravel laravel_v1 4.2 --prefer-dist

2)當我運行命令時

php artisan serve

它說是在 localhost:8000 上啟動的,當我去那裡時,我會看到歡迎畫面。

3)現在我在 /etc/apache2/sites-available 中創建名為 myapp.conf 的虛擬主機文件,該文件具有以下內容:

<VirtualHost *:80>
 # Host that will serve this project.
    ServerName      app.dev

    # The location of our projects public directory.
    DocumentRoot    /var/www/html/laravel_v1/public


    # Rewrites for pretty URLs, better not to rely on .htaccess.
    <Directory /var/www/html/laravel_v1/public>
        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^ index.php [L]
        </IfModule>
    </Directory>
</VirtualHost>

現在,當我在瀏覽器中造訪 app.dev 時,我得到的只是 apache 歡迎頁面。我在這裡做錯了什麼?您能否幫助這個年輕人,以便他可以開始一些編碼。謝謝。

答案1

<VirtualHost *:80>
    ServerName app.dev
    ServerAlias www.app.dev

    DocumentRoot /var/www/html/laravel_v1/public"
    <Directory "/var/www/html/laravel_v1/public/">
     <IfModule mod_rewrite.c>
         Options -MultiViews
         RewriteEngine On
         RewriteCond %{REQUEST_FILENAME} !-f
         RewriteRule ^ index.php [L]
     </IfModule>
    </Directory>
</VirtualHost>

相對路徑有錯誤。

相關內容