If you are using windows, you can install Windows Subsystem for Linux (WSL).
Follow this official guide to install Ubuntu. https://docs.microsoft.com/en-us/windows/wsl/install-win10#manual-installation-steps.
Update list of available packages from apt package manager.
sudo apt update
Upgrade the system to install available upgrades for currently installed packages.
sudo apt upgrade
Add ondrej's php personal package archive as a source for apt package manager.
Since this is a personal package archive, you will be shown a warning before you proceed. You will need to use it at your own risk. However, this PPA is trusted by many.
sudo add-apt-repository ppa:ondrej/php
Again update the apt to pull down the list of packages from new source.
sudo apt update
sudo apt-get install php8.0-fpm
Go to the home directory.
Follow the Command-line installation section in https://getcomposer.org/download/
Make composer globally accessible.
mv composer.phar /usr/local/bin/composer
Prepare the system for Laravel and Composer. (System requirements for Laravel8)
sudo apt-get install php8.0-bcmath php8.0-common php8.0-mbstring php8.0-xml php8.0-curl php8.0-intl php8.0-gd php8.0-zip openssl zip unzip
Install laravel via composer.
composer global require laravel/installer
Place Composer's system-wide vendor bin directory in your
$PATH so the
laravel executable can be located by your system. This can be done by editing
.bashrc file as shown below.
Open .bashrc file using
nano text editor
Paste the following code at the end of the file. You can use
Alt+ / or arrow keys to go to the last line.
Save the document. [You can use
Ctrl+O to write the file and press
enter to confirm the file. Then
Ctrl+X to save the file.]
Use the edited file.
Create a new Laravel project. [Or you can clone a project using
laravel new example-project
Go to the laravel project directory.
Install vendor packages.
If you created a new project using laravel command,
.env file will be automatically get created.
.env file. To do this we will copy the .env.example file provided by laravel.
cp .env.example .env
Generate app key.
php artisan key:generate
Edit .env file and add database and other relevant information.
Install Maria DB from apt.
sudo apt install mariadb-server
Start Mariadb server.
sudo service mysql start
Run the security script to add root password.
You will be given the choice to change the MariaDB root password, remove anonymous user accounts, disable root logins outside of localhost, and remove test databases. It is recommended that you answer
yes to these options.
Login to the database.
sudo mysql -h localhost -u root -p
Create a database <testdb>.
CREATE DATABASE testdb;
Create a user <testuser> with password <password>.
CREATE user 'testuser'@localhost IDENTIFIED BY 'password';
Grant database permission to the user.
GRANT ALL ON testdb.* TO 'testuser' IDENTIFIED BY 'password';
Install mysql extension for php.
sudo apt-get install php8.0-mysql
Add database name <testdb> username <testuser> and password <password> in the