Skip to content

Instantly share code, notes, and snippets.

@intelligenced
Last active February 11, 2019 18:49
Show Gist options
  • Save intelligenced/d06f64e48930bdef5f7b7a00b6e861c8 to your computer and use it in GitHub Desktop.
Save intelligenced/d06f64e48930bdef5f7b7a00b6e861c8 to your computer and use it in GitHub Desktop.
Instructions for setting up LAMP on AWS Ubuntu & Setup for Laravel

Setting up LAMP (Ubuntu, Apache2, MySQL, PHP 7.0) using AWS

  • Set EC2 Instance, Download Key-Value Pair (.pem)

  • Get Putty Compatible Key ppk, using PUTTygen by loading .pem key without adding parameters

  • Enter user@public-dns as server and Add SSH Key to Auth in Settings

  • Update Apt-Get Packages

    sudo apt-get update
    
  • Install Python-Software-Properties

    sudo apt-get install python-software-properties
    
  • Install Locale's needed for PPA:ONDREJ

    sudo apt-get install -y language-pack-en-base
    sudo LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
    
  • Update Dependencies

    sudo apt-get update
    
  • Add PPA:ONDREJ

    sudo add-apt-repository ppa:ondrej/php
    
  • Install php 7.0

    sudo apt-get  install php7.0
    
  • Install Apache2

    sudo apt-get install apache2
    

(optional : Finding other modules) sudo apt-cache search php7-*

  • Install SQL Server ( root, secret )

    sudo apt-get install mysql-server
    
  • Install PHP 7 with mySQL

    sudo apt-get install php7.0-mysql
    
  • Install PHP-7 dependencies for Apache2

    sudo apt-get install libapache2-mod-php7.0 php7.0-mysql php7.0-curl php7.0-json
    
  • Install Git

    sudo apt-get install git-all
    
  • Install PhpMyAdmin [ secret, secret ]

    sudo apt-get install phpmyadmin
    

    ( Make sure to tick the damn server using space, an asterisk will indicate if it's selected )

  • Clone Repo to www directory

    git clone repo to www/ directory
    
  • Edit the Configuration

    sudo nano /etc/apache2/sites-available/000-default.conf
    
  • Change Document Root, to cloned repo's public

    sudo service apache2 restart
    

Laravel Setup

  • Change sudo nano /etc/apache2/000-default.conf to Laravel's Public Directory / Create a new conf file
  • Browser's HTTP 500 Error will be displayed if the above is completed successfully.
  • Navigate to root of laravel project, use ls -a to display all hidden files ( .env )
  • Copy Example Environment & Set it as default sudo mv .env.example .env
  • Set environment using sudo nano .env
  • Create db using phpMyAdmin and Populate with ExistingData / Skip if Seeding
  • Install Composer sudo apt-get install composer
  • Install unzip Package required for Composer sudo apt-get install unzip
  • Go to repo & Install sudo composer install
  • Add Proper Permissions
 sudo chmod 775 main-repo-folder
 sudo chmod -R 777 storage 
  • Give permissions to Composer if required sudo chown -R $USER $HOME/.composer
  • Set a key for Laravel App sudo php artisan key:generate
  • Enable Mod Rewrite for URL Redirection sudo a2enmod rewrite
  • Set Document Root in /etc/apache2/sites-enabled/000-default.conf , change DocumentRoot: /var/www/{laravl folder name}/public
  • sudo nano 000-default.conf ADD within <VirtualHOst *:80>
 <Directory "/var/www/laravel/public">
    AllowOverride all
  </Directory>
  • Restart Server and Visit the Public DNS sudo service apache2 restart

  • ADD DNS sudo nano /etc/resolv.conf to nameserver 8.8.8.8

@intelligenced
Copy link
Author

intelligenced commented Nov 27, 2016

In case of Apache Errors:

apt-get purge php*
apt-get purge apache2

Install these Packages

apt-get install apache2 php7.0 libapache2-mod-php7.0

@intelligenced
Copy link
Author

intelligenced commented Aug 13, 2017

In case of SOAP Errors

Install and Enable
sudo apt-get install php7.0-soap

In case of DNR Service Errors

Add to host
sudo nano /etc/hosts to service IP (10.241.6.190 tr.egov.mv )

@intelligenced
Copy link
Author

intelligenced commented Oct 22, 2017

Find out the version of Ubuntu

lsb_release -a

In case of missing extension errors

Try Installing

sudo apt-get install php7.0-xml
sudo apt-get install php7.0-mbstring

@Afoo2
Copy link

Afoo2 commented Mar 7, 2018

Pre-Requisites

sudo apt-get update 
sudo apt-get upgrade

Installing PHP 7.2

sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.2  php7.2-xml php7.2-gd php7.2-opcache php7.2-mbstring php7.2-dev php-pear php-xml php7.2-soap

Installing Apache

sudo apt-get update 
sudo apt-get upgrade
sudo apt-get install apache2 libapache2-mod-php7.2
sudo apt-get install mysql-server
sudo apt-get install php7.2-mysql

Install Git

sudo apt-get install git-all

Clone Repo to www directory

git clone repo to www/ directory

Check laravel setup above

Install the Microsoft PHP Drivers for SQL Server

sudo su
curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add -
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > /etc/apt/sources.list.d/mssql-release.list
exit

sudo apt-get update
sudo ACCEPT_EULA=Y apt-get install msodbcsql
sudo ACCEPT_EULA=Y apt-get install mssql-tools
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
sudo apt-get install unixodbc-dev

sudo pear config-set php_ini `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"` system
sudo pecl install sqlsrv
sudo pecl install pdo_sqlsrv

Configure Apache driver loading

sudo su
a2enmod mpm_prefork
a2enmod php7.2
sudo echo "extension=sqlsrv.so" >> /etc/php/7.2/apache2/php.ini
sudo echo "extension=pdo_sqlsrv.so" >> /etc/php/7.2/apache2/php.ini
exit
sudo service apache2 restart

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment