• Categories
    Category
  • Categories
    Category
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial Comments FAQ Related Articles

How to install Laravel on Ubuntu 22.04

  • 00:53 lsb_release -a
  • 01:05 sudo apt update
  • 01:29 sudo apt upgrade
  • 01:56 sudo apt install apache2
  • 02:24 systemctl start apache2
  • 02:35 systemctl enable apache2
  • 02:45 sudo apt install php8.1-fpm php8.1-mysql php8.1-gd php8.1-bcmath php8.1-cli php8.1-curl php8.1-mbstring php8.1-zip php8.1-opcache php8.1-xml
  • 03:34 curl -ss https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
  • 03:50 composer
  • 04:15 cd /var/www/html/
  • 04:21 composer create-project laravel/laravel linuxhelp-project
  • 04:55 cd linuxhelp-project/
  • 05:04 sudo chown -R www-data:www-data /var/www/html/linuxhelp-project
  • 05:11 sudo chmod -R 775 /var/www/html/linuxhelp-project/storage
  • 05:29 cd /etc/apache2/sites-available/
  • 05:39 touch laravel.conf
  • 05:50 vim laravel.conf
  • 06:22 a2ensite laravel.conf
  • 06:38 systemctl reload apache2
  • 06:47 apachectl -t
7898

To Install Laravel On Ubuntu 22.04

Introduction

Laravel is a free and open-source PHP web framework designed to facilitate the development of robust and scalable web applications. It builds upon the widely-used Symfony framework and offers a straightforward, user-friendly approach to coding. As a backend framework, Laravel encompasses a comprehensive set of features necessary for developing modern web applications, including routing, validation, caching, queuing, file storage, and additional functionalities.

Procedure

Step1: Check the OS version using the below command

root@linuxhelp:~# lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.4 LTS
Release:	22.04
Codename:	jammy

Step 2: Check for the updates using the below command

root@linuxhelp:~# sudo apt update
Hit:1 http://in.archive.ubuntu.com/ubuntu jammy InRelease
Get:2 http://in.archive.ubuntu.com/ubuntu jammy-updates InRelease [128 kB]
Get:3 http://security.ubuntu.com/ubuntu jammy-security InRelease [129 kB]
Hit:4 http://in.archive.ubuntu.com/ubuntu jammy-backports InRelease 
Fetched 14.2 MB in 4s (3,402 kB/s)                           
Reading package lists... Done
Building dependency tree... Done
 
Reading state information... Done
10 packages can be upgraded. Run 'apt list --upgradable' to see them.

Step 3: Upgrade the package list using the below command

root@linuxhelp:~# sudo apt upgrade
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Calculating upgrade... Done
The following packages were automatically installed and are no longer required:
  libflashrom1 libftdi1-2 libllvm13 libwpe-1.0-1 libwpebackend-fdo-1.0-1
Use 'sudo apt autoremove' to remove them.
The following packages have been kept back:
  python3-update-manager update-manager update-manager-core
The following packages will be upgraded:
  libpython3.10 libpython3.10-minimal libpython3.10-stdlib libssl3 openssl python3.10 python3.10-minimal
7 upgraded, 0 newly installed, 0 to remove and 3 not upgraded.
7 standard LTS security updates
Need to get 10.5 MB of archives.
After this operation, 8,192 B of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu jammy-updates/main amd64 libpython3.10 amd64 3.10.12-1~22.04.5 [1,950 kB]
Setting up libpython3.10-stdlib:amd64 (3.10.12-1~22.04.5) ...
Setting up libpython3.10:amd64 (3.10.12-1~22.04.5) ...
Setting up python3.10 (3.10.12-1~22.04.5) ...
Processing triggers for libc-bin (2.35-0ubuntu3.8) ...
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for mailcap (3.70+nmu1ubuntu1) ...
Processing triggers for desktop-file-utils (0.26-1ubuntu3) ...
Processing triggers for gnome-menus (3.36.0-1ubuntu3) ...

Step 4: For Laravel to work we need Apache , to install Apache use the below command

root@linuxhelp:~# sudo apt install apache2
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libflashrom1 libftdi1-2 libllvm13 libwpe-1.0-1 libwpebackend-fdo-1.0-1
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap
Suggested packages:
  apache2-doc apache2-suexec-pristine | apache2-suexec-custom
Created symlink /etc/systemd/system/multi-user.target.wants/apache2.service → /lib/systemd/system/apache2.service.
Created symlink /etc/systemd/system/multi-user.target.wants/apache-htcacheclean.service → /lib/systemd/system/apache-htcacheclean.service.
Processing triggers for ufw (0.36.1-4ubuntu0.1) ...
Rules updated for profile 'Samba'

Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.8) ...

Step 5: Start the Apache using the below command

root@linuxhelp:~# systemctl start apache2

Step 6: Enable the Apache using the below command

root@linuxhelp:~# systemctl enable apache2
Synchronizing state of apache2.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable apache2

Step 7: Laravel relies on PHP, and composer is dependency manager for PHP , install PHP with dependencies using the below command

root@linuxhelp:~# sudo apt install php8.1-fpm php8.1-mysql php8.1-gd php8.1-bcmath php8.1-cli php8.1-curl php8.1-mbstring php8.1-zip  php8.1-opcache php8.1-xml
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libflashrom1 libftdi1-2 libllvm13 libwpe-1.0-1 libwpebackend-fdo-1.0-1
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  libonig5 libzip4 php-common php8.1-common php8.1-readline
Suggested packages:
  php-pear
Creating config file /etc/php/8.1/fpm/php.ini with new version
NOTICE: Not enabling PHP 8.1 FPM by default.
NOTICE: To enable PHP 8.1 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php8.1-fpm
NOTICE: You are seeing this message because you have apache2 package installed.
Created symlink /etc/systemd/system/multi-user.target.wants/php8.1-fpm.service → /lib/systemd/system/php8.1-fpm.service.
Processing triggers for man-db (2.10.2-1) ...
Processing triggers for libc-bin (2.35-0ubuntu3.8) ...
Processing triggers for php8.1-cli (8.1.2-1ubuntu2.18) ...
Processing triggers for php8.1-fpm (8.1.2-1ubuntu2.18) ...
NOTICE: Not enabling PHP 8.1 FPM by default.
NOTICE: To enable PHP 8.1 FPM in Apache2 do:
NOTICE: a2enmod proxy_fcgi setenvif
NOTICE: a2enconf php8.1-fpm
NOTICE: You are seeing this message because you have apache2 package installed.

Step8: Composer is a vital PHP dependency manager designed to simplify the process of downloading PHP libraries for our project , use the below command

root@linuxhelp:~# curl -ss https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
All settings correct for using Composer
Downloading...

Composer (version 2.7.7) successfully installed to: /usr/bin/composer

Step9: Check composer installation by using the below command

root@linuxhelp:~# composer
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
   ______
  / ____/___  ____ ___  ____  ____  ________  _____
 / /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 2.7.7 2024-06-10 22:11:12

Usage:
  command [options] [arguments]

Options:
  -h, --help                     Display help for the given command. When no command is given display help for the list command
  -q, --quiet                    Do not output any message
  -V, --version                  Display this application version
      --ansi|--no-ansi           Force (or disable --no-ansi) ANSI output
  -n, --no-interaction           Do not ask any interactive question
      --profile                  Display timing and memory usage information
      --no-plugins               Whether to disable plugins.
      --no-scripts               Skips the execution of all scripts defined in composer.json file.
  -d, --working-dir=WORKING-DIR  If specified, use the given directory as working directory.
      --no-cache                 Prevent use of the cache
  -v|vv|vvv, --verbose           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Available commands:
  
  self-update          [selfupdate] Updates composer.phar to the latest version
  show                 [info] Shows information about packages
  status               Shows a list of locally modified packages
  suggests             Shows package suggestions
  update               [u|upgrade] Updates your dependencies to the latest version according to composer.json, and updates the composer.lock file
  validate             Validates a composer.json and composer.lock

Step10: Go to document root of the website, in this we utilize default Apache document root using the below command

root@linuxhelp:~# cd /var/www/html

Step11: Create project using the below command and give yes

root@linuxhelp:/var/www/html# composer create-project laravel/laravel linuxhelp-project
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Continue as root/super user [yes]? yes
Creating a "laravel/laravel" project at "./linuxhelp-project"
Cannot use laravel/laravel's latest version v11.1.4 as it requires php ^8.2 which is not satisfied by your platform.
Installing laravel/laravel (v10.3.3)
  - Downloading laravel/laravel (v10.3.3)
  - Installing laravel/laravel (v10.3.3): Extracting archive
Created project in /var/www/html/linuxhelp-project
> @php -r "file_exists('.env') || copy('.env.example', '.env');"
Loading composer repositories with package information
Updating dependencies
Lock file operations: 112 installs, 0 updates, 0 removals
  - Locking brick/math (0.12.1)
  - Locking carbonphp/carbon-doctrine-types (2.1.0)
  - Locking dflydev/dot-access-data (v3.0.3)
  - Locking doctrine/inflector (2.0.10)
  - Locking doctrine/lexer (3.0.1)
  - Locking dragonmantank/cron-expression (v3.3.3)
  - Locking egulias/email-validator (4.0.2)
  - Locking fakerphp/faker (v1.23.1)
  - Locking filp/whoops (2.15.4)
  - Locking fruitcake/php-cors (v1.3.0)
  - Locking graham-campbell/result-type (v1.1.3)
  - Locking guzzlehttp/guzzle (7.9.2)
  - Locking guzzlehttp/promises (2.0.3)
  - Locking guzzlehttp/psr7 (2.7.0)
  - Locking guzzlehttp/uri-template (v1.0.3)
  - Locking hamcrest/hamcrest-php (v2.0.1)
  - Locking laravel/framework (v10.48.18)
  - Locking laravel/pint (v1.17.0)
  - Locking laravel/prompts (v0.1.24)
> @php artisan package:discover --ansi

   INFO  Discovering packages.  

  laravel/sail ................................................................................................................................ DONE
  laravel/sanctum ............................................................................................................................. DONE
  laravel/tinker .............................................................................................................................. DONE
  nesbot/carbon ............................................................................................................................... DONE
  nunomaduro/collision ........................................................................................................................ DONE
  nunomaduro/termwind ......................................................................................................................... DONE
  spatie/laravel-ignition ..................................................................................................................... DONE

83 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> @php artisan vendor:publish --tag=laravel-assets --ansi --force

   INFO  No publishable resources for tag [laravel-assets].  

No security vulnerability advisories found.
> @php artisan key:generate --ansi

   INFO  Application key set successfully.  

Step12: Switch to the linuxhelp-project using the below command

root@linuxhelp:/var/www/html# cd linuxhelp-project/

Step13: Set these permissions using the below commands

root@linuxhelp:/var/www/html/linuxhelp-project# sudo chown  -R www-data:www-data /var/www/html/linuxhelp-project
 
root@linuxhelp:/var/www/html/linuxhelp-project# sudo chmod -R 775 /var/www/html/linuxhelp-project/storage

Step14: Go to Apache2 site configuration location using the below command

root@linuxhelp:/var/www/html/linuxhelp-project# cd /etc/apache2/sites-available/

Step15: Create new configuration file named laravel.conf using the below command

root@linuxhelp:/etc/apache2/sites-available# touch laravel.conf

Step16: Edit the laravel configuration file using the below command,

root@linuxhelp:/etc/apache2/sites-available# vim laravel.conf

<VirtualHost *:80>
Servername 192.168.6.133
DocumentRoot /var/www/html/linuxhelp-project/public

<Directory /var/www/html/linuxhelp-project>
AllowOverride All
</Directory>

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
 

Step17: Enable new virtualhost by running the below command

root@linuxhelp:/etc/apache2/sites-available# a2ensite laravel.conf
Enabling site laravel.
To activate the new configuration, you need to run:
  systemctl reload apache2

Step18: Check the syntax using the below command

root@linuxhelp:/etc/apache2/sites-available# apachectl -t
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
Syntax OK

Step19: Reload Apache using the below command

root@linuxhelp:/etc/apache2/sites-available# systemctl reload apache2

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to install Laravel on Ubuntu 22.04. Your feedback is much welcome.

Tags:
jacob
Author: 

Comments ( 0 )

No comments available

Add a comment

Frequently asked questions ( 5 )

Q

What is Laravel?

A

Laravel is an open-source PHP web framework that aims to make building robust and maintainable applications easier. It provides a set of tools and libraries to help developers build web applications quickly andefficiently.

Q

What are the key features of Laravel?

A

* Modular design with MVC architecture
* Routing system for handling HTTP requests
* ORM (Object-Relational Mapping) for interacting with databases
* Support for caching, queues, and sessions
* Built-in support for RESTful APIs
* Strong focus on security and best practices

Q

How do I get started with Laravel?

A

* Install Composer (the PHP package manager) and run `composer create-project --prefer-dist laravel/laravel project-name` to set up a new Laravel project.
* Study the official Laravel documentation and tutorials.
* Start by building small projects to learn the framework.

Q

How do I handle routing in Laravel?

A

In Laravel, routing is handled by the `Route` facade. You can define routes using the `get()`, `post()`,
`put()`, and `delete()` methods to specify HTTP request types and corresponding controller actions.

Q

What are Laravel's built-in caching mechanisms?

A

Laravel provides several caching mechanisms, including:
* Memcached
* Redis
* File-based caching (e.g., storing data in a file)
You can use the `Cache` facade to interact with these caching systems.

Related Tutorials in How to install Laravel on Ubuntu 22.04

Related Tutorials in How to install Laravel on Ubuntu 22.04

How to install Meld tool in Ubuntu
How to install Meld tool in Ubuntu
Feb 25, 2017
How to install Dconf-Editor on Ubuntu 18.04
How to install Dconf-Editor on Ubuntu 18.04
Jul 14, 2018
How to install and update OpenSSL on Ubuntu 16.04
How to install and update OpenSSL on Ubuntu 16.04
Mar 9, 2017
How to install GLib 2.0 on Ubuntu 17.04
How to install GLib 2.0 on Ubuntu 17.04
May 22, 2017
How to Install Android Emulator on Ubuntu 20.4.1
How to Install Android Emulator on Ubuntu 20.4.1
Jul 13, 2021
How To Install AnyDesk on Ubuntu 16.04
How To Install AnyDesk on Ubuntu 16.04
Apr 4, 2018
How to install Genymotion 2.12.1 on Ubuntu 18.04
How to install Genymotion 2.12.1 on Ubuntu 18.04
Jul 9, 2018
How to install Timeshift 18.4 on Ubuntu 18.04
How to install Timeshift 18.4 on Ubuntu 18.04
Jul 6, 2018

Related Forums in How to install Laravel on Ubuntu 22.04

Related Forums in How to install Laravel on Ubuntu 22.04

Ubuntu
matthew class=
Failed to enable unit: Refusing to operate on linked unit file sshd.service
Apr 15, 2019
Ubuntu
mason class=
Passwd: You may not view or modify password information for root On Ubuntu 19.04
May 27, 2019
Ubuntu
isaac class=
/etc/apt/sources.list Permission denied
May 18, 2017
Ubuntu
yousuf class=
lsb_release command not working : Debian
Jan 18, 2018
ifconfig command
jackbrookes class=
what is the location of the ifconfig program on your machine?
Jan 4, 2018
Linux
andrew class=
laravel.log could not be opened: failed to open stream: Permission denied
Apr 28, 2017
Ubuntu
mason class=
"E: Package 'php-mcrypt' has no installation candidate" error on Ubuntu 20.4.1
Mar 15, 2021
NFS
luke class=
clnt_create: RPC: Program not registered
Apr 25, 2017

Related News in How to install Laravel on Ubuntu 22.04

Related News in How to install Laravel on Ubuntu 22.04

How To Install Mixxx on Ubuntu 16.04
How To Install Mixxx on Ubuntu 16.04
Oct 11, 2017
Ubuntu 17.04 released with greater expectations
Ubuntu 17.04 released with greater expectations
Apr 15, 2017
Ubuntu Core now available on i.MX6 based TS-4900 thanks to Technologic Systems Inc.
Ubuntu Core now available on i.MX6 based TS-4900 thanks to Technologic Systems Inc.
Mar 1, 2017
Ubuntu 17.10 Artful Aardvark Beta 1 is now here. Download Now
Ubuntu 17.10 Artful Aardvark Beta 1 is now here. Download Now
Sep 2, 2017
Ubuntu Unity is no more: One Linux dream has been axed
Ubuntu Unity is no more: One Linux dream has been axed
Apr 7, 2017
What’s next for Ubuntu Linux Desktop?
What’s next for Ubuntu Linux Desktop?
Apr 11, 2017
Say Hi to Ubuntu's new mascot
Say Hi to Ubuntu's new mascot
Mar 22, 2019
KDE Connect App was removed from Google Play Store and brought back in 24 hours
KDE Connect App was removed from Google Play Store and brought back in 24 hours
Mar 22, 2019
Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Isaac ?
How to run windows application in linux

I need to run the windows application in my Linux machine, instead of installing from yum repo or any other repos. How to do that..??

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.