{"id":156190,"date":"2025-09-06T16:52:03","date_gmt":"2025-09-06T13:52:03","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=156190"},"modified":"2025-09-06T16:52:05","modified_gmt":"2025-09-06T13:52:05","slug":"how-to-install-laravel-on-ubuntu","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/how-to-install-laravel-on-ubuntu\/","title":{"rendered":"How To Install Laravel on Ubuntu 24.04"},"content":{"rendered":"\n<p>Laravel is a popular open source, free to customize and adopt PHP framework used in building of web <a href=\"https:\/\/computingforgeeks.com\/install-and-use-winget-windows-package-manager-client\/\">applications<\/a>. It has an easy syntax, elegant design, and its overall experienced biased on the developer experience. Some of the notable features in Laravel are:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>It uses MVC Architecture:<\/strong> Laravel follows Model-View-Controller (MVC) pattern ensuring neatness in code structuring and perfect separation of concerns.<\/li>\n\n\n\n<li><strong>Laravel<\/strong> <strong>adopts<\/strong> <strong>Object-Oriented Approach:<\/strong> The core of Laravel is designed with the object-oriented programming principles hence easy to re-use and maintain.<\/li>\n\n\n\n<li><strong>Laravel uses Modular Packaging:<\/strong> The functionalities of Laravel are packaged in modules. This allows for development of each component independently.<\/li>\n<\/ul>\n\n\n<p>[ebook product=&#8221;2&#8243; theme=&#8221;purple&#8221;]<\/p>\n\n\n\n<p>If you&#8217;re interested in how Laravel can be installed on an Ubuntu Linux system, then this article is for you. Users interested in <a href=\"https:\/\/computingforgeeks.com\/how-to-install-cakephp-framework-on-ubuntu\/\" target=\"_blank\" rel=\"noreferrer noopener\">CakePHP<\/a> can read the article available in our website. There are tons of resources online already written about Laravel. This includes the official Laravel documentation, various community tutorials, and YouTube videos that you can search and reference when doing your projects.<\/p>\n\n\n\n<p>Before installation of Laravel, PHP has to be installed on your local system. Update OS packages list index.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt update<\/code><\/pre>\n\n\n\n<p>Install PHP and required dependencies.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install php php-{cli,json,mysql,zip,gd,mbstring,curl,xml,pear,bcmath,sqlite3}<\/code><\/pre>\n\n\n\n<p>Proceed with the installation by keying <strong>y <\/strong>in your keyboard.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>0 upgraded, 61 newly installed, 0 to remove and 29 not upgraded.\nNeed to get 14.0 MB of archives.\nAfter this operation, 52.8 MB of additional disk space will be used.\nDo you want to continue? &#91;Y\/n] <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-orange-color\">y<\/mark><\/code><\/pre>\n\n\n\n<p>Check the version of PHP installed.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">php --version<\/mark>\nPHP 8.3.6 (cli) (built: Apr 15 2024 19:21:47) (NTS)\nCopyright (c) The PHP Group\nZend Engine v4.3.6, Copyright (c) Zend Technologies\n    with Zend OPcache v8.3.6, Copyright (c), by Zend Technologies<\/code><\/pre>\n\n\n\n<p>Install <a href=\"https:\/\/computingforgeeks.com\/how-to-install-php-composer-on-cpanel\/\">PHP Composer<\/a>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install composer<\/code><\/pre>\n\n\n\n<p>We can then create a Laravel test project.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir ~\/apps &amp;&amp; cd ~\/apps<\/code><\/pre>\n\n\n\n<p>We will create a Laravel project called <strong>mywebapp<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>composer create-project laravel\/laravel <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">mywebapp<\/mark><\/code><\/pre>\n\n\n\n<p>Sample installation output.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"611\" src=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-1024x611.png\" alt=\"\" class=\"wp-image-156202\" title=\"\" srcset=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-1024x611.png 1024w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-300x179.png 300w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-768x458.png 768w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-1536x916.png 1536w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-2048x1222.png 2048w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-704x420.png 704w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-696x415.png 696w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-1068x637.png 1068w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>To serve the page use<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd mywebapp\nphp artisan serve --host 0.0.0.0 --port=8000<\/code><\/pre>\n\n\n\n<p>Sample execution output:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code> INFO  Server running on &#91;http:\/\/0.0.0.0:8000].\n\n  Press Ctrl+C to stop the server<\/code><\/pre>\n\n\n\n<p>You will see the default Laravel page.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"506\" src=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-02-1024x506.png\" alt=\"\" class=\"wp-image-156205\" title=\"\" srcset=\"https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-02-1024x506.png 1024w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-02-300x148.png 300w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-02-768x380.png 768w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-02-1536x759.png 1536w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-02-2048x1012.png 2048w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-02-850x420.png 850w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-02-696x344.png 696w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-02-1068x528.png 1068w, https:\/\/computingforgeeks.com\/wp-content\/uploads\/2024\/05\/laravel-install-02-324x160.png 324w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Let&#8217;s create a sample <em><strong>Hello World<\/strong><\/em> application.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cd ~\/apps\/mywebapp\nphp artisan make:controller HelloWorldController<\/code><\/pre>\n\n\n\n<p>Add controller creation commands.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">vim routes\/web.php<\/mark>\nRoute::get('helloworld', 'App\\Http\\Controllers\\HelloWorldController@index');<\/code><\/pre>\n\n\n\n<p>Create a function.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">vim app\/Http\/Controllers\/HelloWorldController.php<\/mark>\n&lt;?php\n\nnamespace App\\Http\\Controllers;\n\nuse Illuminate\\Http\\Request;\n\nclass HelloWorldController extends Controller\n{\n    public function index()\n    {\n        return view('helloworld');\n    }\n}\n\n$<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\"> vim resources\/views\/helloworld.blade.php<\/mark>\n&lt;!DOCTYPE html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n&lt;meta http-equiv=\"Content-Type\" content=\"text\/html; charset=UTF-8\" \/&gt;\n&lt;title&gt;Hello World&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n&lt;div style=\"width: 100%; font-size: 40px; font-weight: bold; text-align: center;\"&gt;\nHello World from Laravel\n&lt;\/div&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<p>Serve the application.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php artisan serve --host 0.0.0.0 --port=8000<\/code><\/pre>\n\n\n\n<p>Database credentials are set inside the <code>.env<\/code> file. See example below.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ <mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-pale-pink-color\">vim .env<\/mark>\nDB_CONNECTION=mysql\nDB_HOST=127.0.0.1\nDB_PORT=3306\nDB_DATABASE=<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-cyan-blue-color\">laravel<\/mark>\nDB_USERNAME=<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-luminous-vivid-amber-color\">laravel<\/mark>\nDB_PASSWORD=<mark style=\"background-color:rgba(0, 0, 0, 0)\" class=\"has-inline-color has-vivid-purple-color\">DBUserPassword<\/mark><\/code><\/pre>\n\n\n\n<p>You will then need to run your application&#8217;s&nbsp;<a href=\"https:\/\/laravel.com\/docs\/migrations\" target=\"_blank\" rel=\"noreferrer noopener\">database migrations<\/a>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>php artisan migrate<\/code><\/pre>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Laravel is a popular open source, free to customize and adopt PHP framework used in building of web applications. It has an easy syntax, elegant design, and its overall experienced biased on the developer experience. Some of the notable features in Laravel are: If you&#8217;re interested in how Laravel can be installed on an Ubuntu &#8230; <a title=\"How To Install Laravel on Ubuntu 24.04\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/how-to-install-laravel-on-ubuntu\/\" aria-label=\"Read more about How To Install Laravel on Ubuntu 24.04\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":156205,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[690,299,50,68,81],"tags":[39140],"cfg_series":[],"class_list":["post-156190","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-dev","category-how-to","category-linux-tutorials","category-programming","category-ubuntu","tag-laravel-on-ubuntu-24-04"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/156190","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=156190"}],"version-history":[{"count":1,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/156190\/revisions"}],"predecessor-version":[{"id":160613,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/156190\/revisions\/160613"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/156205"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=156190"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=156190"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=156190"},{"taxonomy":"cfg_series","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/cfg_series?post=156190"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}