We're here to assist with any of your needs, don't hestitate to reach out.
Laravel is a free, open-source PHP web framework used for building web applications. It provides an elegant syntax and a set of useful tools to make development tasks easier. To install Laravel on Ubuntu 18.04, follow the steps below:
Step 1: Update the System
It's always a good idea to start by updating the system packages. Open the terminal and run the following command:
sudo apt update
sudo apt upgrade
Step 2: Install PHP
Laravel requires PHP to be installed on the system. Install PHP and other necessary extensions using the following command:
sudo apt install php php-cli php-fpm php-mbstring php-xml php-zip php-mysql php-gd php-curl
Step 3: Install Composer
Composer is a dependency manager for PHP. Laravel uses Composer to manage its dependencies. Install Composer globally by running the following commands:
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Step 4: Create a Laravel Project
Now that you have Laravel's prerequisites installed, you can create a new Laravel project. Navigate to the directory where you want to create the project and run the following command:
composer create-project --prefer-dist laravel/laravel project-name
Step 5: Configure Permissions
Change the ownership of the Laravel project directory to the web server's user:
sudo chown -R www-data:www-data project-name
Step 6: Configure Virtual Host (Optional)
If you want to access your Laravel project through a domain name instead of an IP address, you can configure a virtual host. Create a new virtual host configuration file:
sudo nano /etc/apache2/sites-available/project-name.conf
Inside the file, add the following configuration:
ServerName example.com
ServerAlias www.example.com
DocumentRoot /path/to/project-name/public
AllowOverride All
Require all granted
Save the file and enable the virtual host:
sudo a2ensite project-name.conf
sudo systemctl restart apache2
Now you should be able to access your Laravel application using the configured domain name.
That's it! You have successfully installed Laravel on Ubuntu 18.04.
What our customers say about us
Create your free account today.