Install Laravel PHP Framework On Ubuntu
Laravel is a flexible opensource PHP framework for web artisans. It can be used as an alternative to CodeIgniter framework. Laravel is designed for ease of use to allow developers create great applications.
Step 1: Install Apache2
To do that, run the commands below…l
sudo apt update sudo apt install apache2
After installing, the commads below can be used to stop, start and enable Apache2 service to always start up with the server boots.
sudo systemctl stop apache2.service sudo systemctl start apache2.service sudo systemctl enable apache2.service
Step 2: Install PHP 7.2 And Related Modules
To install PHP and related modules run the commands below
sudo apt install php7.2 libapache2-mod-php7.2 php7.2-mbstring php7.2-xmlrpc php7.2-soap php7.2-gd php7.2-xml php7.2-cli php7.2-zip
After install PHP, run the commands below to open PHP-FPM default file.
sudo nano /etc/php/7.2/apache2/php.ini
Then make the change the following lines below in the file and save.
memory_limit = 256M upload_max_filesize = 64M cgi.fix_pathinfo=0
Step 3: Install Composer To Download Laravel
Run the commands below to install composer package and install.. you must have curl package installed for the commands to work.. if not, just run sudo apt install curl to install it…
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer
Change into Laravel directory and run the commands below to download and install Laravel for the project you want to create… name the project whatever you want… for this post, we’re calling it MyProject..
cd /var/www/html sudo composer create-project laravel/laravel MyProject --prefer-dist
After running the commands above, a new project directory will be created… Run the commands below to set the correct permissions for that directory..
sudo chown -R www-data:www-data /var/www/html/MyProject/ sudo chmod -R 755 /var/www/html/MyProject/
Step 5: Run Laravel Project
php artisan server
Step 6: Copy the URL in the above screenshot and open that URL in the browser. If you see the following screen, it implies Laravel has been installed successfully.