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.
[email protected]:~# lsb_release -a && ip r [email protected]:~# cat /etc/hosts [email protected]:~# 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.
[email protected]:~# add-apt-repository ppa:ondrej/php [email protected]:~# apt update [email protected]:~# apt install -y zip unzip software-properties-common [email protected]:~# apt -y autoremove [email protected]:~# 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 [email protected]:~# apt-get install -y mysql-server mysql-client [email protected]:~# service mysql start [email protected]:~# service mysql status
Step #03: Download and install composer.
[email protected]:~# curl -sS https://getcomposer.org/installer | php [email protected]:~# mv composer.phar /usr/local/bin/composer [email protected]:~# chmod +x /usr/local/bin/composer [email protected]:~# systemctl start apache2 [email protected]:~# systemctl enable apache2
Step #04: Download Laravel project and install composer.
[email protected]:~# cd /var/www/html [email protected]/var/www/html# git clone https://github.com/laravel/laravel.git [email protected]/var/www/html# cd laravel [email protected]/var/www/html# su tech [email protected]/var/www/html$ sudo composer install [email protected]/var/www/html$ su root [email protected]:~# cd
Step #05: Setup permission on your project directory.
[email protected]:~# chown -R www-data.www-data /var/www/html/laravel [email protected]:~# chmod -R 755 /var/www/html/laravel [email protected]:~# chmod -R 777 /var/www/html/laravel/storage [email protected]:~# cd /var/www/html/laravel/ [email protected]:~# mv .env.example .env [email protected]:~# php artisan key:generate [email protected]:~# 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 [email protected] identified by '[email protected]'; 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 [email protected]; FLUSH PRIVILEGES; \q
Add database name, database user name and database password into .env file.
[email protected]:~# vi .env
Insert below details into .env file.
laravel_db laravel_user [email protected]
Run below command for migrate.
[email protected]:~# php artisan migrate
Step #06: Setup Apache web config file for properly working Laravel.
[email protected]:~# 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.
[email protected]:~# chmod 777 -R /var/www/html/laravel [email protected]:~# 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 Odoo 16 on Ubuntu 22.04 - May 14, 2023
- 12 Steps to Organize Photos on Your Computer - March 20, 2023
- 9 Ways to Speed Up Your MacBook Yosemite - February 21, 2023
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!