loader
Navrangpura, Ahmedabad, Gujarat
Follow us :

1. Known for its clean syntax, expressive syntax, and developer-friendly features, Laravel is an open-source PHP framework for building online applications. It makes it simple to construct dependable and scalable web applications since it adheres to the Model-View-Controller (MVC) architectural paradigm.

La Ravel’s salient characteristics include:

( 1 ) Routing: Laravel offers a straightforward and expressive method for defining web routes, making it simple to manage HTTP requests and specify the proper response logic.

( 2 ) Eloquent, Laravel’s ORM (Object-Relational Mapping), makes querying and manipulating database records simple by offering an intuitive syntax.

( 3 ) Laravel comes with a built-in templating engine called Blade that enables you to create dynamic, reusable views with capabilities like template inheritance, control structures, and simple data rendering.

( 4 ) Database migrations: The migration mechanism provided by Laravel enables you to easily make changes to the database structure while preserving your data and version control your database design.

( 5 ) User registration, login, and password reset functionality can be easily implemented because Laravel comes with a full authentication system preinstalled. Additionally, it provides strong authorization techniques for limiting access to different areas of your application.

( 6 ) Data Caching and Session Management: Laravel comes with built-in support for data caching, which can significantly enhance the performance of your application. It also offers a clear, uncomplicated interface for managing user sessions.

( 7 ) Task Scheduling: By specifying scheduled instructions, Laravel’s task scheduler enables you to automate monotonous operations within your application.

( 8 ) Testing: Laravel offers built-in support for testing, with capabilities like unit testing, integration testing, and browser testing, making it simpler to assure the quality and reliability of your application.

( 9 ) The sizeable and vibrant Laravel community helps to support its ongoing development, thorough documentation, and availability of several packages and extensions that may be simply incorporated into your applications.

Laravel provides a solid basis for developing cutting-edge online applications, with the overall goal of streamlining the development process and increasing developer productivity.

Apache Web Server installation

You will install the Apache2 web server on your Ubuntu system in this initial phase. You will be using the Apache web server and the Laravel web framework in this example.

To update and reload your Ubuntu repository, run the apt command below.

sudo apt update

The Apache2 web server package should then be installed using the following command.

sudo apt install apache2

Enter Y to confirm, then hit ENTER to launch the installation. It’s time to start installing Apache.

After installing Apache2, you must configure the UFW firewall to allow access to HTTP and HTTPS services.

The HTTP and HTTPS services can be added to the UFW firewall by using the ufw command listed below.

sudo ufw allow "Apache Full"

Input the server IP address (for example, http://192.168.1.11) in the address bar of your web browser after it has opened. The Apache2 web server’s default index.html page should now appear.

Installing PHP

The Ubuntu 20.04 computer will have PHP installed and configured after the Apache web server is set up. The PHP package for version 7.4 is available in the standard Ubuntu 20.04 repository, and it has good support for the Laravel web framework.

Install PHP packages for the Laravel web framework by running the apt command below.

sudo apt install php php-curl php-bcmath php-json php-mbstring php-xml php-tokenizer php-zip

Enter Y to approve the installation, then click ENTER to move on. The installation of PHP will start.

Use the Vim editor to make changes to the configuration file php.ini after the PHP installation is complete.

sudo vim /etc/php/8.1/apache2/php.ini

To make the PHP extensions file info, OpenSSL, and mastering available, uncomment the corresponding options.

extension=fileinfo
extension=mbstring
extension=openssl


When finished, save and close the file.

Restart the Apache2 service after that to make the latest PHP configuration modifications.

sudo systemctl restart apache2

Finally, run the following command to check and validate your PHP setup.

On your Ubuntu computer, check the PHP version installed.

php --version

You can see that PHP 7.4.3 is set up on the Ubuntu computer in the screenshot below.

MariaDB Server installation

PHP and the Apache2 web server packages have now been set up. On the Ubuntu 20.04 system, you will now be installing and setting up the MariaDB database server. For the Laravekl project, you will also be creating a fresh MariaDB database and user.

You can use the apt command listed below to install the MariaDB database on an Ubuntu computer.

sudo apt install mariadb-server

Enter Y to confirm, then hit ENTER to launch the installation.

Use the command below to log in as the root user to the MariaDB shell once the installation of MariaDB is complete

sudo mysql -u root -p

Run the MariaDB queries listed below to establish a brand-new database and user for the Laravel project. In this case, the user Laravel and the password “password” will be used to create the database laravel_db

CREATE DATABASE laravel_db;

Query OK, 1 row affected (0.001 sec)

CREATE USER laravel@localhost IDENTIFIED BY 'password';

Query OK, 0 rows affected (0.001 sec)

GRANT ALL PRIVILEGES ON laravel_db.* TO laravel@localhost;

Query OK, 0 rows affected (0.001 sec)

FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.001 sec)

exit

Bye

To exit the MariaDB shell, run the query “EXIT” right away. You have now set up a new database and user for the Laravel project as well as installed the MariaDB database server.

Composer installation

Installing the Composer will be done in this section. It is package management for the PHP programming language, comparable to pip for Python, the gem for Ruby, npm for Node.js, and yarn for PHP.

There are several ways to install the Laravel web framework. In this example, Composer will be used to install the Laravel web framework.

To download the Composer installation, run the command listed below.

curl -sS https://getcomposer.org/installer -o composer-setup.php

To install the Composer, execute the installer script “composer-setup.php” right away. By doing this, the Composer will be installed in the /usr/local/bin directory.

sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer

This screenshot was taken during Composer installation.

Run the command shown below to check and validate the Composer installation when the installation is complete.

sudo -u www-data composer --version

Display the Composer help content.

sudo -u www-data composer --help

Start Installing Laravel

For the purposes of this example, you will need to establish three directories: “.cache” for the PHP package cache, “.config” for the additional Composer setup, and “laravelapp” for the Laravel project itself. The “/var/www” directory will contain all of those directories.

To create new directories for the Laravel installation, run the command below.

sudo mkdir -p /var/www/{.cache,.config,laravelapp}

Currently, give the user and group www-data ownership to the Composer and Laravel directories.

sudo chown -R www-data:www-data /var/www/{.cache,.config,laravelapp}

After that, use the following command to navigate to the /var/www/laravelapp directory.

cd /var/www/laravelapp/

then use the composer command listed below to install the Laravel web framework. The. at the end of the program will install Laravel in the /var/www/laravelapp working directory.

sudo -u www-data composer create-project laravel/laravel .

After the Laravel installation is complete, the outcome is shown below.

Next, use the Vim editor to make changes to the “.env” file when the installation is finished. This setting serves as Laravel’s immediate environment setup and contains information like the installation URL and database specifics.

vim .env

For the Laravel installation, replace the APP_URL configuration with your domain name. The domain name laravelapp.hwdomain.io.c will be used to host the laravel in this example.

APP_URL=http://laravel_db.hwdomain.io

As soon as you have modified your database configuration, modify the database details.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel_db
DB_USERNAME=laravel
DB_PASSWORD=password

Save and close the file when you are done.

The MariaDB database server and Laravel web framework installation are now complete.

Setup Apache Virtual Host

The Apache2 virtual host for the Laravel web framework needs to be configured now. The Laravel project will be running in this illustration on the local domain laravel_db.hwdomain.io.

Create a new file “/etc/apache2/sites-available/laravel.conf” using Vim editor.

sudo vim /etc/apache2/sites-available/laravel.conf

The file should now have the following configuration. You can alter the domain if you are already using it. Additionally, be sure to modify the Laravel project’s Document root path.

<VirtualHost *:80>

    ServerAdmin admin@hwdomain.io
    ServerName laravel_db.hwdomain.io
    DocumentRoot /var/www/laravelapp/public

    <Directory />
            Options FollowSymLinks
            AllowOverride None
    </Directory>
    <Directory /var/www/laravelapp>
            AllowOverride All
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Save and close the file when you are done.

The next step is to run the following command to enable the virtual host configuration laravel. conf and the Apache2 module rewriting.

sudo a2enmod rewrite
sudo a2ensite laravel.conf

Now make sure there are no errors in the Apache2 configuration.

sudo apachectl configtest

Apply the updated virtual host configuration for the Laravel project now by restarting the Apache2 service using the command listed below.

sudo systemctl restart apache2

You have now finished setting up Apache to serve Laravel’s virtual host.

On your machine, edit the /etc/hosts file using the nano/vim editor.

sudo vim /etc/hosts

Include the subsequent configuration. Make sure to update your detailed server’s domain name and IP address.

Save and close the file when you are done.

sudo systemctl restart mariadb.service
sudo systemctl enable mariadb.service
sudo systemctl restart apache2
sudo systemctl enable apache2

Finally, return to your web browser and type the URL for the Laravel installation (i.e., http://laravel_db.hwdomain.io) into the address bar. And you ought to see the Laravel web framework’s default index page. Additionally, you can see the PHP version you are currently using and the Laravel version you just installed at the bottom.

Congratulation! The Laravel web framework has now been successfully installed on Ubuntu 20.04. Additionally, you have learned how to set up the LAMP stack for the Laravel web farm.

Author

by admin

bg

Subscribe to our Newslatter

Sign Up to Our Newsletter to Get Latest Updates & Services

mail box
logo-footer
HighSky IT Solutions Pvt. Ltd. is a leading IT training and certification programs in Red hat, RSCSA Cloud, Open-source, AWS, Devops and various domains.
Contact Info

2nd floor, Rohera Arcade, opp SOTC office, Near Navrangpura police station, Navrangpura, Ahmedabad -380009 Gujarat

Copyright ©2024 Design & Developed by HighSky IT