How to install & Configure Laravel in Ec2 Ubuntu

  


Laravel is an open-source PHP web application framework with expressive, elegant syntax. Laravel allows you to easily build scalable and flexible web applications, restful APIs and eCommerce solutions.

With build-in features such as routing, authentication, sessions, caching and unit testing Laravel is a framework of choice for many PHP developers.

In this tutorial we will show you how to install Laravel on an Ubuntu 20.04 system. The same instructions apply for Ubuntu 20.04 and any Ubuntu based distribution, including Linux Mint, Kubuntu and Elementary OS.


Update and Upgrade your OS.
# sudo apt-get  update && sudo apt-get upgrade -y

Install Apache2 
# sudo apt-get install -y apache2 

 Install Zip & Unzip package     
# sudo apt-get install -y zip unzip  

PHP 7.4 which is the default PHP version in Ubuntu 20.04 is fully supported and recommended for Laravel 5.7.

Create Online PHP repository your server.
    
# sudo yes " " | add-apt-repository ppa:ondrej/php

Run the following command to install PHP and all required PHP modules:

#sudo apt-get install -y php7.4-fpm php7.4-cli php7.4-mcrypt php7.4-gd php7.4-mysql php7.4-pgsql php7.4-imap php-memcached php7.4-mbstring php7.4-xml php7.4-curl php7.4-bcmath php7.4-sqlite3 php7.4-zip libapache2-mod-php7.4


# sudo a2enmod proxy_fcgi setenvif


# sudo a2enconf php7.4-fpm

Go to tmp directory
adesh@techlinuxserver$  cd /tmp

Install Composer
# curl -sS https://getcomposer.org/installer | php

Move Composer to /usr/local/bin 
# sudo mv composer.phar /usr/local/bin/composer

Create swap file
# sudo fallocate -l 1G /swapfile

Make Swap Space
# sudo mkswap /swapfile

Swap partition On for the following command 
# sudo swapon /swapfile

Remove ubuntu default page
# sudo rm -rf /var/www/html/index.html 

Create project with the help of composer  {devops is my project name}
# sudo composer create-project laravel/laravel /var/www/html/devops --prefer-dist

Change the group permission
# sudo chgrp -R www-data /var/www/html

Change the owner permission
# sudo chown www-data.www-data /var/www/html/devops/storage -R

Modify the directory and change the specific permission
# sudo chmod -R 775 /var/www/html/devops/storage

Open file and  (Directory /var/www/>owOverride All)   
# sudo vim /etc/apache2/apache2.conf                                                                   (Directory /var/www/>owOverride All)   
                                                                                                  
Open file and change RootDirectory {devops is my project name}
# sudo vim /etc/apache2/sites-available/000-default.conf                                  (DocumentRoot /var/www/html/devops/public)

In Order to user mod_rewrite you can type the following command 
# sudo a2enmod rewrite

Restart the Apache service
# sudo systemctl restart apache2
or
# sudo /etc/init.d/apache2 restart


 


Post a Comment

0 Comments