Warning: Creating default object from empty value in /home/panola5/ww2.panolatech.com/wp-content/themes/Consulting_Pro/admin/main/inc/class.redux_filesystem.php on line 29
Weekly Roundup: Laravel on Bash/Windows 10 - Panola Technology Consulting, LLC

Weekly Roundup: Laravel on Bash/Windows 10

Last year the Windows 10 Anniversary Update introduced a Linux Bash Shell running Ubuntu 14. I was trying it as a LAMP environment to do development in a local environment. It was good but incomplete and did not allow me to run Laravel.

Fast forward to 2017 and the Windows 10 Creators Update has a more up to date Linux Bash Shell and you can update Ubuntu to version 16 which is a more complete environment. I tried to do an update of Ubuntu but that turned out to be problematic so I did a clean install and ditched any configuration changes I had made. You will need a web server, a database server and Composer installed. For this I am running Apache and MySQL.

Install Composer

$ sudo apt-get install composer

Install Laravel

$ cd /var/www
$ sudo composer create-project --prefer-dist laravel/laravel <directory>

Change Storage Permissions

$ sudo chmod -R 777 <directory>/storage/app
$ sudo chmod -R 777 <directory>/storage/framework
$ sudo chmod -R 777 <directory>/storage/logs
$ sudo chmod -R 777 <directory>/bootstrap/cache

I wanted to run my Laravel site in a subdomain of localhost. So I first had to add my site to the Virtual Hosts file.

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

<VirtualHost *:80>
        DocumentRoot /var/www/<directory>/public
        ServerName <subdomain>.localhost
</VirtualHost>

$ sudo service apache2 restart

Edit Windows Host File (Windows Machine Only).

 

C:\Windows\System32\drivers\etc\hosts

# localhost name resolution is handled within DNS itself.
     127.0.0.1     <subdomain>.localhost

Create Database and Setup variables in  .env file in /var/www/<directory> then run:

$ php artisan migrate

Generate Key

$ php artisan key:generate

Turn on Apache Mod Rewrite

$ sudo a2enmod rewrite
$ sudo service apache2 restart

Since I last worked with Laravel 5.2, in version 5.5 all Routes go in /routes/web.php

I needed to make one last change in Apache to get my routes working. I edited /etc/apache2/apache2.conf and restarted Apache to get the urls working.

<Directory />
     Options FollowSymLinks
     AllowOverride All
     Require all denied
<Directory>
<Directory /usr/share>
     AllowOverride None
     Require all granted
<Directory>
<Directory /var/www>
     Options FollowSymLinks
     AllowOverride All
     Require all denied
<Directory>

This is fairly rudimentary as far as how-to’s go. It is really meant to include what I found from several different sources.