Saturday, April 8, 2017

Laravel 5.x on Ubuntu 14.04 (EC2) and PHP5.6

The following commands will install laravel on the said environment - title says :) This can be automated on when the instance gets launched.

#repository for php5.6 because the version isn't available on default
sudo add-apt-repository -y ppa:ondrej/php

sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get -y install apache2
sudo apt-get install python-software-properties

#these php5.6 package seems to make the installation of laravel breeze
sudo apt-get -y install php5.6 php5.6-mcrypt php5.6-gd php5.6-mysql php5.6-mbstring php5.6-xml zip unzip php5.6-zip

#option: remove and purge old PHP 5.x packages
sudo apt-get -y purge php5-common
sudo apt-get -y install libapache2-mod-php5.6

sudo apt-get -V install mysql-server-5.6

# locate the php.ini file from phpinfo.php and load needed modules

cd
sudo curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

# installing git seems not required. I'm not an expert it i manage to get it installed
# sudo apt-get install git


# for laravel 5.4.x - this wasn't required before perhaps new docs says so...
sudo /bin/dd if=/dev/zero of=/var/swap.1 bs=1M count=1024
sudo /sbin/mkswap /var/swap.1
sudo /sbin/swapon /var/swap.1

# root of the website / "project1" is the name of the root of new laravel installation
cd /var/www/html/
sudo composer create-project laravel/laravel project1 --prefer-dist
sudo chgrp -R www-data /var/www/html/project1
sudo chmod -R 775 /var/www/html/project1/storage

cd /etc/apache2/sites-available

# create the project1 conf file / virtual host
sudo vi project1.conf
<VirtualHost *:80>
ServerName localhost

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/project1/public

<Directory /var/www/html/project1>
AllowOverride All
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>


sudo a2dissite 000-default.conf
sudo a2ensite project1.conf
sudo a2enmod rewrite

sudo service apache2 restart

Now, browse your Laravel installation - http://<ip_or_domain

Hope this helps!

Resources:

  • tons of website which will be added once i get the list


No comments:

Post a Comment