How To Install Linux Apache MySQL PHP Laravel App on Ubuntu

Simple A to Z server set up

Posted by Captain Nimo 1 month ago

Introduction

A "LAMP" stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP. Laravel Framework is most PHP framework , currently project is combined by NPM and Composer . Laravel application set up would be a good "pattern" for similar projects

1. Install Apache


sudo apt-get update

sudo apt-get install apache2

2. Install Mysql


sudo apt-get install mysql-server

3. Install PHP and PHP package


sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql

sudo apt-get install php5.6    //   5.6  or 7.0

sudo apt-get install php5.6-gd php5.6-mysql php5.6-dom

4. Install Git


sudo apt-get install git-all

5. Install Composer


php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

php -r "if (hash_file('SHA384', 'composer-setup.php') === 'aa96f26c2b67226a324c27919f1eb05f21c248b987e6195cad9690d5c1ff713d53020a02ac8c217dbf90a7eacc9d141d') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

php composer-setup.php

php -r "unlink('composer-setup.php');"

//zip and unzip will be need in the composer install 

apt-get install zip unzip

6. Laravel setup

git clone your own repo or use composer install Laravel



//composer install 

composer create-project laravel/laravel your project  "5.1.*"

//gt clone your repo 

sudo git clone your-repo.git

Please also check the Laravel required PHP extention



sudo apt-get install php7.0-mbstring

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

sudo apt-get install php-xml

The Document Root need be set as /var/www/html/your-laravel-app/public

Then you will find the URL does not work well , because you need enable the rewrite

(I assume the .htaccess file is working )


sudo a2enmod rewrite

sudo service apache2 restart 

/etc/apache2.conf need modify too



        Options Indexes FollowSymLinks
        AllowOverride All
        Require all granted

Summary

This is a simple server setup , the Firewall setup and other secure section are not considered at this moment . Now you can check your vagrant or real domain , it should work now