I was following various tutorials to install Laravel on my Ubuntu box but I kept running into different issues with PHP or Apache.

After working on it for a while, I think I have cracked the best method for me which I will document here.

1) Set up a clean Ubuntu 16.04 install and log in to the root account

2) Install the following packages

sudo apt-get install php-dev php-mcrypt php-gd php-mbstring php-xml php-common php-zip apache2-dev libapache2-mod-php mysql-server composer

You will be prompted to provide a password for mysql in this installation process.

3) Install laravel using composer

composer global require laravel/installer

4) Edit your .bashrc file

nano ~/.bashrc

Add this to the top of the file:

export PATH="$PATH:$HOME/.config/composer/vendor/bin"

Save the file, exit nano and then run:

source ~/.bashrc

5) Create and setup a new project

cd /var/www/
laravel new appname
cd appname
mv .env.example .env
php artisan key:generate

6) Change Permissions

chown -R www-data.www-data /var/www/appname
chmod -R 755 /var/www/appname
chmpd -R 777 /var/www/appname/storage
7) Change Apache settings
sudo nano /etc/apache2/sites-available/000-default.conf
Change DocumentRoot /var/www/html to DocumentRoot /var/www/{yourapplocation}/public
Add the following lines below the edited line.
<Directory /var/www/{yourapplocation}/public>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>

Change one more file:

sudo nano /etc/apache2/sites-available/000-default.conf.dpkg-dist

Change DocumentRoot to /var/www/{appname}

8) Finally restart apache

service apache2 restart

9) Now if you go to the IP of your machine in a browser, you should see the Laravel Welcome screen

I hope this is helpful to a few of ye. Let me know in the comments if there are any issues with the article. 🙂