To learn about a web application framework, join us to review installing Laravel. With this tool, you would see some of common tasks have been easier such as authentication, routing, sessions, and caching. The main reason of choosing Laravel is to development process a pleasing one for the developer without sacrificing application functionality.In this article, we try to learn you How to install Laravel on Ubuntu 20.04 LTS [complete]. You can check out the packages available in Eldernode to purchase an Ubuntu VPS server.
Table of Contents
Tutorial install Laravel on Ubuntu 20.04
To let this tutorial work better, please consider the below Prerequisites:
a non-root user with sudo privileges
To set up, follow our Initial server set up on Ubuntu 20.04 LTS.
How to install Laravel on Ubuntu 20.04 LTS [complete]
Laravel is one of the PHP language frameworks designed for web application development and works based on MVC. Let’s go through the steps of this article to learn how to install Laravel on Ubuntu 20.04.
Step 1: Install LAMP Stack
You must first install the LAMP stack on Ubuntu.
Note: Laravel required PHP 7.2 or higher version for the install.
Now, use the commands below to install PHP.
sudo apt install software-properties-common sudo add-apt-repository ppa:ondrej/php sudo apt install -y php7.4 php7.4-gd php7.4-mbstring php7.4-xml
And, Install Apache2 by running the following command.
sudo apt install apache2 libapache2-mod-php7.4
Next, Install MySQL with the command below:
sudo apt install mysql-server php7.4-mysql
Step 2 : Install Composer
Use the following commands to install the composer
curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer sudo chmod +x /usr/local/bin/composer
Step 3 : Download and Install Laravel
Now it’s time to install Laravel, download the latest version, and install it with the following command.
cd /var/www git clone https://github.com/laravel/laravel.git
Then follow the instructions below:
cd /var/www/laravel sudo composer install
Also, follow the instructions below:
chown -R www-data.www-data /var/www/laravel chmod -R 755 /var/www/laravel chmod -R 777 /var/www/laravel/storage
Step 4 : Create Environment Settings
Now Create Environment Settings with below command:
mv .env.example .env
Then follow the instructions below:
php artisan key:generate Application key set successfully.
Also, follow the instructions below:
nano .env
APP_NAME=Laravel APP_ENV=local APP_KEY=base64:WrdferHu7dfkc2OdfLdfBPuxdfHqq2BdfQYhd APP_DEBUG=true APP_URL=http://localhost ...
Step 5 : Create MySQL User and Database
CREATE DATABASE laravel; CREATE USER 'eldernode'@'localhost' IDENTIFIED BY 'secret'; GRANT ALL ON eldernode.* to 'eldernode'@'localhost'; FLUSH PRIVILEGES; quit
Now edit the .env file and update database settings.
DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=eldernode DB_USERNAME=eldernode DB_PASSWORD=eldernode
Step 6 : Apache Configuration
nano /etc/apache2/sites-enabled/avalable.conf
Note: Before running, make sure the nano is installed on the server
Update the configuration with command below:
<VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/laravel/public <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/laravel> AllowOverride All </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Now Reload Apache2 configuration with below command:
sudo systemctl restart apache2
Step 7 : Access Laravel on browser
Congratulations, the installation is complete. you can now enter the IP in the browser and view the Laravel page.
Conclusion
In this tutorial, you passed the 7 steps and successfully set up a new Laravel application running on Ubuntu 20.04. So enjoy this accessible, yet powerful, providing powerful tools needed for large, robust applications.
Hello, thank you for your education;
Where I do the create-project command I encounter this error:
“Your requirements could not be resolved to an installable set of packages.”
Help if you can.
Your PHP version does not match.
What should we do to use Laravel Mix as a compiler?
You need to install Node.js and Yarn.
What is the use of a PHP composer?
Using Composer, you can specify the PHP libraries on which your project depends. Composer is used in all modern PHP frameworks and operating systems such as Laravel, Symfony, Drupal, and Magento.
What is composer.lock?
composer.lock is a file that holds information about all installed packages and their versions and locks the project to specific versions.
Hello, how can we delete things related to a record when we delete it from the database?
For example, when we delete a post, the comments related to that post are also deleted.
You can set some values for onDelete:
cascade: It means that if their father is removed, all his children will be removed. For example, deleting an author removes all blog posts and comments.
set null: After deleting their father in the field related to FK, the value is NULL. For example, the author_id field in the posts table is null.
restrict: If you set this value, it will not allow the removal of the father if he has a child. This means that as long as an author has a post or comment, you can not delete the author’s record and it gives an error.
What are the new features in Ubuntu 20.04 compared to previous versions?
One of the most important changes to the Ubuntu 20.04 LTS is the migration to Kernel 5.4, which has many improvements to hardware support. It also supports WireGuard (a secure VPN topology) and comes with Livepatch (no need to reboot after a kernel update).
Do we need to change the value of APP_KEY?
The APP_KEY variable contains a unique key that is automatically generated when installing Laravel via Composer. You do not need to change this value.
What should we do to produce a new secure key in Laravel through the composer? please guide me.
You can use the command php artisan key: generate.
What resources does Ubuntu 20.04 support?
Ubuntu is suitable for desktop and server use. The current version of Ubuntu supports systems with the following resources:
Intel x86 (IBM-compatible PC), AMD64 (x86-64), ARMv7, ARMv8 (ARM64), IBM POWER8 / POWER9 (ppc64el), IBM Z zEC12 / zEC13 / z14 and IBM LinuxONE Rockhopper I + II / Emporer I + II (s390x)
Which path is the main Apache configuration files? Please name them.
The main Apache configuration files in the /etc/httpd/conf/httpd.conf path are generally:
httpd.conf: Main server settings
modules.conf: Settings for enabling and disabling Apache modules
access.conf: can contain access settings.
srm.conf: Contains some other Apache settings such as DocumentRoot
How to update the system for security plugins?
You must update the security plugins by running the following command before starting the installation:
sudo apt-get update
sudo apt-get upgrade
How to enable theme settings on Ubuntu 20.04?
New dark theme settings can be activated from Settings> Appearance.
How long will the LTS release be supported?
Every released version of LTS is supported on desktops and servers for 5 years, and this version is no exception to this Ubuntu rule, and will be supported until 2025.
After installing Ubuntu 20.04, how to install multimedia codecs?
To play all media formats such as music, movies, etc., we need to install several new libraries:
sudo apt install ubuntu-restricted-extras
Is it possible to optimize battery consumption after installing Ubuntu 20.04 or not?
By installing a program to improve battery consumption, you will both increase battery life and prevent the battery from overheating. To prevent overheating in Linux laptops, TLP is a great tool that controls CPU temperature and extends the battery life of laptops in the long run. You can install it in the terminal using the following command:
sudo apt install tlp tlp-rdw
This guide does not work, just like the countless others I’ve tried
Dear friend, please follow the steps carefully. These tutorials have been tested.