Skip to content

Instantly share code, notes, and snippets.

@mmuhd
Forked from intelligenced/lamp-aws-laravel.md
Last active March 4, 2021 11:18
Show Gist options
  • Save mmuhd/9c6c7536c7932d44a2531019762609e4 to your computer and use it in GitHub Desktop.
Save mmuhd/9c6c7536c7932d44a2531019762609e4 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
    
  • Install Composer

    cd ~
    
    curl -sS https://getcomposer.org/installer -o composer-setup.php
    
    sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
    
  • Restart

    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

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