In previous article “How-to : Introduction to Laravel : Create a Laravel Framework project on openSUSE Leap 42.1” we’ve created Laravel project called demo-project.

However, this project is not available on web server, so we can’t open it in web browser and see it’s content.

Let’s configure Apache server to serve our demo-project.

In this article we will:

  • Place project files in appropriate folder
  • Adjust files ownership for proper publishing
  • Create configuration for Apache, so our content will be available

Let’s get to work…

Move project files

In openSUSE Linux folder structure folder /srv/www is dedicated for any content related to web server.

For that reason we will move demo-project folder first into /srv/www folder structure to keep it consistent.

dev-lnx-01:~ # mv ~/demo-project /srv/www

Adjust file ownership

To avoid any issues with accessing files by Apache web server we will change ownership of the whole demo-project folder structure to match user on which Apache service is working.

In openSUSE Linux user assigned to Apache server is called wwwrun. This might be different on other Linux distributions, so if you using different Linux distro, please check proper user name and adjust command accordingly.

dev-lnx-01:~ # chown -R wwwrun /srv/www/demo-project/

Create Apache configuration

Now it’s time to inform Apache web server that we have some content we want to serve on the network.

In order to do that we have to create configuration file which will describe where our demo-project is located and give some instructions to Apache web server how to navigate and use folder structure with our Laravel-based project.

In order to do that create file /etc/apache2/conf.d/demo-project.conf with following content:

Alias /demo-project /srv/www/demo-project/public

<Directory /srv/www/demo-project/public>
        Require all granted
        Options +Indexes +FollowSymLinks -MultiViews
        AllowOverride all
        <IfModule mod_rewrite.c>
            Options -MultiViews
            RewriteEngine On
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^ index.php [L]
        </IfModule>
</Directory>

Now we have to reload Apache configuration, so Apache will load our configuration for demo-project and open our project in web browser.

dev-lnx-01:~ # service apache2 reload

Now we can go to web browser and open http://ip-of-your-server/demo-project (in my case I open http://192.168.36.101/demo-project as this is IP address of my test virtual machine).

When you open demo-project in web browser you will see big Laravel 5 in the middle of the browser.
That means your project is properly published on Apache web server.

laravel-intro-first-screen

At this stage we can enjoy our demo-project being available on the network.

I hope to provide more fun on how to develop simple applications in Laravel soon 🙂

Till next time…