{"id":15587,"date":"2019-02-21T12:24:25","date_gmt":"2019-02-21T12:24:25","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=15587"},"modified":"2026-01-13T12:10:11","modified_gmt":"2026-01-13T12:10:11","slug":"how-to-install-laravel-on-ubuntu","status":"publish","type":"post","link":"\/tutorials\/how-to-install-laravel-on-ubuntu\/","title":{"rendered":"How to install Laravel on Ubuntu with Apache"},"content":{"rendered":"<p>There are many powerful PHP frameworks, but some of them have limitations when it comes to reading the application&rsquo;s source code. This can be a problem if you want to document application code.<\/p><p>Fortunately, Laravel, when combined with Apache, provides an excellent solution. This PHP framework efficiently organizes and compresses the source code. In this tutorial, we&rsquo;ll guide you through the full installation of Laravel with Apache on Ubuntu.<\/p><p><strong>A brief overview of installing Laravel on Ubuntu with Apache:<\/strong><\/p><figure tabindex=\"0\" class=\"wp-block-table\"><table><tbody><tr><td>Required Knowledge<\/td><td>Basic Ubuntu server management, PHP, Apache<\/td><\/tr><tr><td>Privileges Required<\/td><td>Root or sudo user privileges<\/td><\/tr><tr><td>Difficulty<\/td><td>Intermediate<\/td><\/tr><tr><td>Main Goal<\/td><td>Installing Laravel, configuring PHP and Apache<\/td><\/tr><tr><td>OS Compatibility<\/td><td>Ubuntu 22.04 or later<\/td><\/tr><\/tbody><\/table><\/figure><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/Linux-Commands-Cheat-Sheet.pdf\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" width=\"2048\" height=\"566\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=1024,h=1024,fit=scale-down\" alt=\"\" class=\"wp-image-69262\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=2048,fit=scale-down 2048w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2022\/11\/Linux-cheat-sheet.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 2048px) 100vw, 2048px\" \/><\/a><\/figure>\n<\/div><p>\n\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-what-is-laravel\">What is Laravel<\/h2><p>Laravel is unsurprisingly one of the most <a href=\"\/tutorials\/best-php-framework\/\">popular PHP frameworks<\/a>. It has many unique features that make it one of the best-rated options for web developers.<\/p><p>It also has great documentation and loves well-done source code, which translates into very expressive code syntax. Fast, efficient and user-friendly &ndash; Laravel. Here&rsquo;s how you can install Laravel <a href=\"\/tutorials\/what-is-ubuntu\/\">Ubuntu<\/a>.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-install-laravel-on-ubuntu\">How to install Laravel on Ubuntu<\/h2><p>Before we start, you&rsquo;ll need to SSH into your virtual private server. Here&rsquo;s a <a href=\"\/tutorials\/how-to-use-putty-ssh\/\">helpful tutorial<\/a> to help you along.<\/p><p>Following the steps below will walk you through the easiest way to install Laravel on Ubuntu:<\/p><h3 class=\"wp-block-heading\" id=\"h-1-install-apache-web-server\">1. Install Apache web server<\/h3><p>For Laravel to work, you&rsquo;ll need Apache. It is one of the most popular HTTP server tools, so it&rsquo;s likely that your VPS has it installed. Luckily, you can check easily! Once you connect to your server using <strong>SSH<\/strong>, verify that an Apache system service exists. To do so, we have to run this command.<\/p><pre class=\"wp-block-preformatted\">sudo systemctl status apache2<\/pre><p>As you can see, on our VPS there is no Apache service, so we have to install it. To do this, execute the following command.<\/p><pre class=\"wp-block-preformatted\">sudo apt install apache2<\/pre><p>Ubuntu by default, starts the Apache service and makes it boot during system loading.<\/p><p>Now, if you&rsquo;re using a firewall, it is necessary to establish a rule in the <a href=\"\/tutorials\/how-to-configure-firewall-on-ubuntu-using-ufw\/\">Ubuntu firewall<\/a> so that Apache can run smoothly. If you have no firewall installed, feel free to skip this step.<\/p><pre class=\"wp-block-preformatted\">sudo ufw allow &ldquo;Apache Full&rdquo;<\/pre><p>After that, we can check the Apache service status again.<\/p><pre class=\"wp-block-preformatted\">sudo systemctl status apache2<\/pre><div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1365\" height=\"339\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/ubuntu-apache-status.png\/public\" alt=\"Apache server status command output on Ubuntu\" class=\"wp-image-15595\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/ubuntu-apache-status.png\/w=1365,fit=scale-down 1365w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/ubuntu-apache-status.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/ubuntu-apache-status.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/ubuntu-apache-status.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/ubuntu-apache-status.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/ubuntu-apache-status.png\/w=990,fit=scale-down 990w\" sizes=\"(max-width: 1365px) 100vw, 1365px\" \/><\/figure>\n<\/div><p>Finally, open a web browser and go to the IP address of your server or its domain name.<\/p><p>If you see this screen, that means Apache is up and running.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1366\" height=\"666\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/apache-browser-screen.png\/public\" alt=\"Apache default screen on a browser\" class=\"wp-image-15596\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/apache-browser-screen.png\/w=1366,fit=scale-down 1366w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/apache-browser-screen.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/apache-browser-screen.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/apache-browser-screen.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/apache-browser-screen.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/apache-browser-screen.png\/w=990,fit=scale-down 990w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/figure>\n<\/div><h3 class=\"wp-block-heading\" id=\"h-2-install-php\">2. Install PHP<\/h3><p>The next step is to <a href=\"\/tutorials\/how-to-install-install-php-ubuntu\/\">install PHP<\/a>. Fortunately, PHP 8 comes by default in Ubuntu&rsquo;s official repositories, which makes the installation very easy. You will need to install the language itself and some extra module. To do this, execute the following command:<\/p><pre class=\"wp-block-preformatted\">sudo apt install php libapache2-mod-php php-mbstring php-xmlrpc php-soap php-gd php-xml php-cli php-zip php-bcmath php-tokenizer php-json php-pear<\/pre><p>If the following command produced an output saying some packages were not found, simply update your Ubuntu by running the following command, and rerun the previous one:<\/p><pre class=\"wp-block-preformatted\">sudo apt-get update<\/pre><p>Now, we can test if PHP is working correctly. To do this, we need to create a file in Apache&rsquo;s root directory. Let&rsquo;s call it test.php. Run the following command:<\/p><pre class=\"wp-block-preformatted\">sudo nano \/var\/www\/html\/test.php<\/pre><p>And add the call to the phpinfo function.<\/p><pre class=\"wp-block-preformatted\">&lt;?php\nphpinfo();\n?&gt;<\/pre><p>We have to save it and close it. To save, hit <strong>CTRL+O<\/strong>, and to exit, hit <strong>CTRL+X<\/strong> Then, open the web browser and go to <strong>http:\/\/Your-serverIP\/test.php<\/strong>.<\/p><p>If you see this screen, you can be sure that PHP is working as it should.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1366\" height=\"666\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/php-info-screen.png\/public\" alt=\"PHP info screen on a browser\" class=\"wp-image-15598\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/php-info-screen.png\/w=1366,fit=scale-down 1366w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/php-info-screen.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/php-info-screen.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/php-info-screen.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/php-info-screen.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/php-info-screen.png\/w=990,fit=scale-down 990w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/figure>\n<\/div><h3 class=\"wp-block-heading\" id=\"h-3-download-and-install-a-database-manager\">3. Download and install a database manager<\/h3><p>If we are going to develop using Laravel in Ubuntu 22.04, it is necessary to install a database manager. Laravel supports PostgreSQL, MySQL, MariaDB, SQLite, and SQL servers. We can install and configure the one we want. For this tutorial, we will install MariaDB.<\/p><pre class=\"wp-block-preformatted\">sudo apt install mariadb-server<\/pre><p>After that, you can set a password for the root. To do this, you need to use the mysql_secure_installation script. Keep in mind that this step is optional but recommended for security reasons.<\/p><pre class=\"wp-block-preformatted\">sudo mysql_secure_installation<\/pre><p>After we define the root password, we will be asked several MariaDB configuration questions. The answers you should input are next to the lines of code:<\/p><pre class=\"wp-block-preformatted\">Remove anonymous users? [Y\/n] y\nDisallow root login remotely? [Y\/n] n\nRemove test database and access to it? [Y\/n] y\nReload privilege tables now? [Y\/n] y<\/pre><div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1366\" height=\"768\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/mariadb-configuration-ubuntu.png\/public\" alt=\"Maria DB configuration on ubuntu\" class=\"wp-image-15599\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/mariadb-configuration-ubuntu.png\/w=1366,fit=scale-down 1366w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/mariadb-configuration-ubuntu.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/mariadb-configuration-ubuntu.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/mariadb-configuration-ubuntu.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/mariadb-configuration-ubuntu.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/mariadb-configuration-ubuntu.png\/w=990,fit=scale-down 990w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/figure>\n<\/div><p>Congratulations, MariaDB was installed successfully. <\/p><p>If you prefer a NoSQL database management system, read our tutorial to learn about <a href=\"\/tutorials\/how-to-install-mongodb-on-ubuntu\/\">how to install MongoDB on Ubuntu<\/a>.<\/p><h3 class=\"wp-block-heading\" id=\"h-4-install-composer\">4. Install Composer<\/h3><p><a href=\"\/tutorials\/how-to-install-composer\/\">Composer<\/a> is a PHP dependency manager that facilitates the download of PHP libraries in our projects. Composer works great and makes it much easier to install Laravel.<\/p><p>First, we need to download Composer.<\/p><pre class=\"wp-block-preformatted\">curl -sS https:\/\/getcomposer.org\/installer | php<\/pre><p>Next, we have to make sure Composer can be used globally and make it executable. The following commands will take care of that.<\/p><pre class=\"wp-block-preformatted\">sudo mv composer.phar \/usr\/local\/bin\/composer<\/pre><pre class=\"wp-block-preformatted\">sudo chmod +x \/usr\/local\/bin\/composer<\/pre><p>\n\n\n        <div class=\"protip\">\n            <div class=\"protip__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                    Suggested Reading                <\/p>\n            <\/div>\n            <p class=\"protip__content\">Check out our article to learn more <a href=\"\/tutorials\/vps\/change-linux-permissions-and-owners\/\">how to change permissions and owners in Linux<\/a> to control user access in your system.<\/p>\n                    <\/div>\n        \n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-5-install-laravel-on-ubuntu-using-composer\">5. Install Laravel on Ubuntu using Composer<\/h3><p>With Composer installed, now we can install Laravel. To do this, run the following command:<\/p><pre class=\"wp-block-preformatted\">composer create-project --prefer-dist laravel\/laravel [project_name]<\/pre><p>Of course, we have to replace <strong>[project_name]<\/strong> with the name of your application. In this case, we name the project example.<\/p><p>\n\n\n        <div class=\"protip\">\n            <div class=\"protip__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                    Pro Tip                <\/p>\n            <\/div>\n            <p class=\"protip__content\">Explore our <a href=\"\/vps\/laravel-hosting\">Laravel VPS hosting plans<\/a>, which come with the Ubuntu 22.04 and Laravel template pre-installed for a quick launch.<\/p>\n                    <\/div>\n        \n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-use-laravel-for-local-development\">How to use Laravel for local development<\/h2><p>To develop applications locally, we can use PHP serve and specify the host and port of our server. To do this, execute the following commands and replace [IP] with your server IP and <strong>[port]<\/strong> with the port you wish to use.<\/p><pre class=\"wp-block-preformatted\">cd example<\/pre><pre class=\"wp-block-preformatted\">php artisan serve --host=[IP] --port=[port]<\/pre><p>Next, open your web browser and go to the server&rsquo;s IP address or domain name and the specified port. The address would look like the one displayed in the output above. If you see the screen below in your browser, you&rsquo;re ready to start working with Laravel.<\/p><div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"1366\" height=\"666\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/laravel-landing-page.png\/public\" alt=\"Laravel landing Page on a browser\" class=\"wp-image-15600\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/laravel-landing-page.png\/w=1366,fit=scale-down 1366w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/laravel-landing-page.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/laravel-landing-page.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/laravel-landing-page.png\/w=768,fit=scale-down 768w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/laravel-landing-page.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/02\/laravel-landing-page.png\/w=990,fit=scale-down 990w\" sizes=\"(max-width: 1366px) 100vw, 1366px\" \/><\/figure>\n<\/div><h2 class=\"wp-block-heading\" id=\"h-how-to-use-laravel-to-deploy-an-application\">How to use Laravel to deploy an application<\/h2><p>On the contrary, if we are going to <a href=\"\/tutorials\/how-to-deploy-laravel\/\">deploy a Laravel application on our VPS<\/a>, then we have to make some adjustments to avoid problems.<\/p><p>First, we need to move the previously created project directory to the Apache web root. Remember, in our case, the folder name is Example. Execute the following command:<\/p><pre class=\"wp-block-preformatted\">sudo mv example \/var\/www\/html\/<\/pre><p>After that, set the necessary permissions to ensure the project runs smoothly:<\/p><pre class=\"wp-block-preformatted\">sudo chgrp -R www-data \/var\/www\/html\/example\/<\/pre><pre class=\"wp-block-preformatted\">sudo chmod -R 775 \/var\/www\/html\/example\/storage<\/pre><p>It is necessary to create a new virtual host for the project. It can be done easily with the commands below:<\/p><pre class=\"wp-block-preformatted\">cd \/etc\/apache2\/sites-available<\/pre><pre class=\"wp-block-preformatted\">sudo nano laravel_project.conf<\/pre><p>Add the following to create the new Virtual host. Remember to replace <strong>thedomain.com<\/strong> with your server&rsquo;s <strong>IP address<\/strong>.<\/p><pre class=\"wp-block-preformatted\">&lt;VirtualHost *:80&gt;\n&nbsp;&nbsp;&nbsp;ServerName thedomain.com\n&nbsp;&nbsp;&nbsp;ServerAdmin webmaster@thedomain.com\n&nbsp;&nbsp;&nbsp;DocumentRoot \/var\/www\/html\/example\/public\n\n&nbsp;&nbsp;&nbsp;&lt;Directory \/var\/www\/html\/example&gt;\n&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;AllowOverride All\n&nbsp;&nbsp;&nbsp;&lt;\/Directory&gt;\n&nbsp;&nbsp;&nbsp;ErrorLog ${APACHE_LOG_DIR}\/error.log\n&nbsp;&nbsp;&nbsp;CustomLog ${APACHE_LOG_DIR}\/access.log combined\n&lt;\/VirtualHost&gt;<\/pre><p>Save the file and close it.<\/p><p>After that, disable the default configuration file of the virtual hosts in Apache with this command:<\/p><pre class=\"wp-block-preformatted\">sudo a2dissite 000-default.conf<\/pre><p>Afterwards, enable the new virtual host:<\/p><pre class=\"wp-block-preformatted\">sudo a2ensite laravel_project<\/pre><p>Enable the Apache rewrite module, and finally, restart the Apache service:<\/p><pre class=\"wp-block-preformatted\">sudo a2enmod rewrite<\/pre><pre class=\"wp-block-preformatted\">sudo systemctl restart apache2<\/pre><p>Now, open the web browser and go to the server&rsquo;s IP. If you get the same Laravel landing screen you have seen last time, you&rsquo;re ready to start working.<\/p><p>Now we can get to work with this great PHP framework.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-uninstall-laravel-and-composer\">How to uninstall Laravel and Composer<\/h2><p>To uninstall Laravel we only have to delete the folder of the generated project. In the case &ndash; &nbsp;the Composer, the following command will be enough:<\/p><pre class=\"wp-block-preformatted\">sudo rm \/usr\/local\/bin\/composer<\/pre><p>That&rsquo;s it. Laravel is removed from your VPS.<\/p><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=1024,h=1024,fit=scale-down\" alt=\"\" class=\"wp-image-77934\" srcset=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=1024,fit=scale-down 1024w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=300,fit=scale-down 300w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=150,fit=scale-down 150w, https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=768,fit=scale-down 768w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>To develop quality web applications, you need a feature-rich PHP framework. Laravel is one of them. Here you learned how to install it on a computer or server with Ubuntu 22.04.<\/p><p>Remember, it&rsquo;s a good idea to consult the official documentation, if you want more information or if you want to learn more about the project. <\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are many powerful PHP frameworks, but some of them have limitations when it comes to reading the application&rsquo;s source [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/tutorials\/how-to-install-laravel-on-ubuntu\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":110,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Install Laravel on Ubuntu with Apache","rank_math_description":"Learn how to install Laravel on Ubuntu: 1. Install Apache web server 2. Install PHP 3. Download and install database manager + more.","rank_math_focus_keyword":"install laravel ubuntu","footnotes":""},"categories":[22646,22644],"tags":[],"class_list":["post-15587","post","type-post","status-publish","format-standard","hentry","category-pre-installed-applications","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-install-laravel-on-ubuntu","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/como-instalar-laravel-ubuntu","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/installer-laravel-sur-ubuntu","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/como-instalar-laravel-en-ubuntu","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/install-laravel-di-ubuntu","default":0},{"locale":"en-GB","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-install-laravel-on-ubuntu","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-install-laravel-on-ubuntu","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-install-laravel-on-ubuntu","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/como-instalar-laravel-ubuntu","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-install-laravel-on-ubuntu","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-install-laravel-on-ubuntu","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/como-instalar-laravel-en-ubuntu","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/como-instalar-laravel-en-ubuntu","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/como-instalar-laravel-en-ubuntu","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-install-laravel-on-ubuntu","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-install-laravel-on-ubuntu","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/15587","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/users\/110"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/comments?post=15587"}],"version-history":[{"count":38,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/15587\/revisions"}],"predecessor-version":[{"id":139029,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/posts\/15587\/revisions\/139029"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/media?parent=15587"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/categories?post=15587"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/tutorials\/wp-json\/wp\/v2\/tags?post=15587"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}