How To Install and Configure Laravel 9 on Ubuntu 20.046 min read
In this tutorial how to install and configure Laravel 9 on Ubuntu 20.04 server. Laravel is an open source php framework for run web application like web services.
###################################### IP address : 10.66.10.8 Operating System: Ubuntu 20.04 RAM : 2 GB Disk : 25 GB vCPU : 2 CPU op-mode(s) : 64-bit Service : Laravel 9 Database : Mysql 8.0 Hostname (FQDN) : Laravel.technologyrss.local ######################################
Step #01: Check server version and update server.
root@Laravel:~# lsb_release -a && ip r root@Laravel:~# cat /etc/hosts root@Laravel:~# apt update && apt -y upgrade
Note: If you face upgrade error so use below command for fix error issue.
If come error for upgrade: sudo lsof /var/lib/dpkg/lock sudo lsof /var/lib/apt/lists/lock sudo lsof /var/cache/apt/archives/lock sudo rm /var/lib/apt/lists/lock sudo rm /var/cache/apt/archives/lock sudo rm /var/lib/dpkg/lock sudo lsof /var/lib/dpkg/lock-frontend sudo rm /var/lib/dpkg/lock-frontend sudo apt update sudo rm /var/lib/dpkg/lock-frontend sudo dpkg --configure -a apt update && apt -y upgrade
Step #02: Install Apache PHP and mysql database.
root@Laravel:~# add-apt-repository ppa:ondrej/php root@Laravel:~# apt update root@Laravel:~# apt install -y zip unzip software-properties-common root@Laravel:~# apt -y autoremove root@Laravel:~# apt install -y apache2 php8.0-common php8.0-cli php8.0-gd php8.0-mysql php8.0-curl php8.0-intl php8.0-mbstring php8.0-bcmath php8.0-imap php8.0-xml php8.0-zip php8.0 php8.0-xml php-zip libapache2-mod-php8.0 root@Laravel:~# apt-get install -y mysql-server mysql-client root@Laravel:~# service mysql start root@Laravel:~# service mysql status
Step #03: Download and install composer.
root@Laravel:~# curl -sS https://getcomposer.org/installer | php root@Laravel:~# mv composer.phar /usr/local/bin/composer root@Laravel:~# chmod +x /usr/local/bin/composer root@Laravel:~# systemctl start apache2 root@Laravel:~# systemctl enable apache2
Step #04: Download Laravel project and install composer.
root@Laravel:~# cd /var/www/html root@Laravel/var/www/html# git clone https://github.com/laravel/laravel.git root@Laravel/var/www/html# cd laravel root@Laravel/var/www/html# su tech root@Laravel/var/www/html$ sudo composer install root@Laravel/var/www/html$ su root root@Laravel:~# cd
Step #05: Setup permission on your project directory.
root@Laravel:~# chown -R www-data.www-data /var/www/html/laravel root@Laravel:~# chmod -R 755 /var/www/html/laravel root@Laravel:~# chmod -R 777 /var/www/html/laravel/storage root@Laravel:~# cd /var/www/html/laravel/ root@Laravel:~# mv .env.example .env root@Laravel:~# php artisan key:generate root@Laravel:~# mysql -u root -p
Mysql root user password is blank so you can login without root password on your mysql terminal. Then create database user and password.
create database laravel_db; create user laravel_user@localhost identified by 'laravel_user@123'; GRANT CREATE, ALTER, DROP, INSERT, UPDATE, DELETE, SELECT, REFERENCES, RELOAD on *.* TO 'laravel_user'@'localhost' WITH GRANT OPTION; grant all privileges on laravel_db.* to laravel_user@localhost; FLUSH PRIVILEGES; \q
Add database name, database user name and database password into .env file.
root@Laravel:~# vi .env
Insert below details into .env file.
laravel_db laravel_user laravel_user@123
Run below command for migrate.
root@Laravel:~# php artisan migrate
Step #06: Setup Apache web config file for properly working Laravel.
root@Laravel:~# vi /etc/apache2/sites-enabled/000-default.conf
Insert or change your config as like below.
DocumentRoot /var/www/html/laravel/public <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/html/laravel> AllowOverride All </Directory>
Then setup permission and restart Apache web service using below command.
root@Laravel:~# chmod 777 -R /var/www/html/laravel root@Laravel:~# systemctl restart apache2
Then access your server ip address http://10.66.10.8/
If you see any error so please see my YouTube video, Please don’t forget subscribe my channel and share to others.
- How To Install Zabbix Server 6.4 On AlmaLinux 8 Server - August 9, 2024
- How To Clear RAM Memory Cache Buffer Linux Server - February 29, 2024
- How To Install Apache Cloud Stack Management Server 4.17 On Ubuntu 22.04 - February 1, 2024
We really appreciate for your support for buying me a coffee.
It takes us a while to compose and upload new content, as they have to be checked to see if Properly works. We appreciate you if you help me for one cup of coffee to keep us awake and always deliver good quality content.
No contribution is small of an amount. We are grateful for any amount you support us with. Thank you!