{"id":2720,"date":"2024-08-06T02:53:02","date_gmt":"2025-11-25T02:30:25","guid":{"rendered":""},"modified":"2025-02-02T00:46:19","modified_gmt":"2025-02-01T23:46:19","slug":"how-to-install-laravel-php-framework-on-ubuntu-24-04","status":"publish","type":"post","link":"https:\/\/netcloud24.com\/knowledgebase\/how-to-install-laravel-php-framework-on-ubuntu-24-04\/","title":{"rendered":"Linux VPS &#038; VPS Windows Setup Guide | NetCloud24 Laravel PHP Framework on Ubuntu 24.04"},"content":{"rendered":"<p>\u00a0<\/p>\n<\/p>\n<header>\n<h1>\u00a0<\/h1>\n<\/header>\n<article>\n<p><strong>Laravel<\/strong> is a popular open-source PHP framework designed for web application development. It offers an elegant syntax, a range of features, and tools that make development faster and easier. In this guide, we\u2019ll show you how to install Laravel on <strong>Ubuntu 24.04<\/strong>. For optimal performance, we recommend hosting your Laravel application on a . Using a <strong>VPS server<\/strong> allows for dedicated resources, ensuring better performance, scalability, and control over your development environment.<\/p>\n<h2>Step 1: Update Your VPS Server<\/h2>\n<p>Before starting the installation process, ensure your <a href=\"https:\/\/ie.netcloud24.com\">VPS server<\/a> is updated with the latest software packages. Run the following commands to update your system:<\/p>\n<pre><code>sudo apt update &amp;&amp; sudo apt upgrade -y<\/code><\/pre>\n<p>By using a <strong>Windows VPS<\/strong>, you can ensure that your Laravel application runs in a high-performance environment, providing faster load times and better reliability.<\/p>\n<h2>Step 2: Install Apache, MySQL, and PHP (LAMP Stack)<\/h2>\n<p>Laravel requires a LAMP stack (Linux, Apache, MySQL, PHP) to run. Follow these steps to install Apache, MySQL, and PHP on your server:<\/p>\n<ul>\n<ul>\n<li>Install Apache:<\/li>\n<\/ul>\n<\/ul>\n<pre><code>sudo apt install apache2 -y<\/code><\/pre>\n<ul>\n<ul>\n<li>Start and enable Apache to run at boot:<\/li>\n<\/ul>\n<\/ul>\n<pre><code>sudo systemctl enable apache2 --now<\/code><\/pre>\n<ul>\n<ul>\n<li>Install MySQL:<\/li>\n<\/ul>\n<\/ul>\n<pre><code>sudo apt install mysql-server -y<\/code><\/pre>\n<ul>\n<ul>\n<li>Secure the MySQL installation:<\/li>\n<\/ul>\n<\/ul>\n<pre><code>sudo mysql_secure_installation<\/code><\/pre>\n<ul>\n<ul>\n<li>Install PHP and the necessary extensions for Laravel:<\/li>\n<\/ul>\n<\/ul>\n<pre><code>\r\nsudo apt install php php-mysql php-xml php-mbstring php-json php-cli php-zip php-curl php-bcmath -y\r\n<\/code><\/pre>\n<h2>Step 3: Create a MySQL Database for Laravel<\/h2>\n<p>Laravel requires a MySQL database to store application data. Log in to the MySQL shell and create a database and user for Laravel:<\/p>\n<pre><code>sudo mysql -u root -p<\/code><\/pre>\n<p>Create the database and user:<\/p>\n<pre><code>\r\nCREATE DATABASE laravel_db;\r\nCREATE USER 'laravel_user'@'localhost' IDENTIFIED BY 'your_password';\r\nGRANT ALL PRIVILEGES ON laravel_db.* TO 'laravel_user'@'localhost';\r\nFLUSH PRIVILEGES;\r\nEXIT;\r\n<\/code><\/pre>\n<p>Be sure to replace <code>your_password<\/code> with a secure password.<\/p>\n<h2>Step 4: Install Composer<\/h2>\n<p>Laravel is installed using Composer, a PHP dependency manager. Install Composer by running the following commands:<\/p>\n<pre><code>\r\nsudo apt install curl -y\r\ncurl -sS https:\/\/getcomposer.org\/installer | php\r\nsudo mv composer.phar \/usr\/local\/bin\/composer\r\n<\/code><\/pre>\n<p>Verify the Composer installation:<\/p>\n<pre><code>composer --version<\/code><\/pre>\n<h2>Step 5: Install Laravel<\/h2>\n<p>Now that Composer is installed, use it to install Laravel. Navigate to the web root directory and create a new Laravel project:<\/p>\n<pre><code>\r\ncd \/var\/www\/html\r\ncomposer create-project --prefer-dist laravel\/laravel laravel-app\r\n<\/code><\/pre>\n<h2>Step 6: Set Permissions for Laravel<\/h2>\n<p>After Laravel is installed, set the correct ownership and permissions for the Laravel project directory:<\/p>\n<pre><code>\r\nsudo chown -R www-data:www-data \/var\/www\/html\/laravel-app\r\nsudo chmod -R 755 \/var\/www\/html\/laravel-app\r\n<\/code><\/pre>\n<h2>Step 7: Configure Apache for Laravel<\/h2>\n<p>Create an Apache virtual host configuration file for your Laravel application:<\/p>\n<pre><code>sudo nano \/etc\/apache2\/sites-available\/laravel-app.conf<\/code><\/pre>\n<p>Add the following configuration:<\/p>\n<pre><code>\r\n\r\n    ServerAdmin admin@your-domain.com\r\n    DocumentRoot \/var\/www\/html\/laravel-app\/public\r\n    ServerName your-domain.com\r\n\r\n    \r\n        AllowOverride All\r\n        Require all granted\r\n    \r\n\r\n    ErrorLog ${APACHE_LOG_DIR}\/laravel-error.log\r\n    CustomLog ${APACHE_LOG_DIR}\/laravel-access.log combined\r\n\r\n<\/code><\/pre>\n<p>Replace <code>your-domain.com<\/code> with your actual domain name. Then, enable the site and restart Apache:<\/p>\n<pre><code>\r\nsudo a2ensite laravel-app.conf\r\nsudo a2enmod rewrite\r\nsudo systemctl restart apache2\r\n<\/code><\/pre>\n<h2>Step 8: Configure Laravel Environment<\/h2>\n<p>Laravel uses a <code>.env<\/code> file for environment-specific settings. Open the <code>.env<\/code> file in the Laravel project directory and configure the database settings:<\/p>\n<pre><code>sudo nano \/var\/www\/html\/laravel-app\/.env<\/code><\/pre>\n<p>Update the following lines with your database information:<\/p>\n<pre><code>\r\nDB_DATABASE=laravel_db\r\nDB_USERNAME=laravel_user\r\nDB_PASSWORD=your_password\r\n<\/code><\/pre>\n<p>Save the file and exit the editor.<\/p>\n<h2>Step 9: Complete Laravel Installation<\/h2>\n<p>To complete the Laravel setup, generate the application key by running:<\/p>\n<pre><code>php artisan key:generate<\/code><\/pre>\n<p>Your Laravel installation is now complete. You can access your application by navigating to <code>http:\/\/your-domain.com<\/code> in your web browser.<\/p>\n<h2>Step 10: Optimize Your VPS Server for Laravel<\/h2>\n<p>Hosting Laravel on a  provides you with the dedicated resources necessary to run your web application efficiently. A <strong>VPS server<\/strong> ensures high performance, better scalability, and faster load times, allowing you to handle increased traffic and user demands seamlessly. A VPS also offers the flexibility to customize your server environment to suit your Laravel project\u2019s specific needs.<\/p>\n<h2>Conclusion<\/h2>\n<p>Installing Laravel on Ubuntu 24.04 provides you with a powerful framework for building modern web applications. By hosting your Laravel application on a , you benefit from better performance, scalability, and control, ensuring that your application runs smoothly in a production environment.<\/p>\n<p>For more information on VPS hosting and optimizing your Laravel setup, visit  today.<\/p>\n<\/article>\n<footer>\n<p>\u00a9 2024 Windows VPS &#8211; All Rights Reserved<\/p>\n<\/footer>\n<div class=\"post-author-box\" style=\"border-top:1px solid #ddd;margin-top:20px;padding-top:15px;\">\n<p><strong>Author:<\/strong> \u0141ukasz Bodziony<\/p>\n<p><strong>Website:<\/strong> <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a><\/p>\n<p><em>\u0141ukasz Bodziony is the CEO and founder of <a href=\"https:\/\/netcloud24.com\" target=\"_blank\" rel=\"dofollow\">NETCLOUD24<\/a>, a global VPS hosting brand proudly originating from Poland. With extensive experience in cloud computing, virtualization, and server management, he delivers high-performance <strong>Windows VPS<\/strong> and <strong>Remote Desktop Services (RDS)<\/strong> solutions to clients across Europe, North America, and beyond.<\/em><\/p>\n<p><em>His expertise covers a wide range of technologies, including <strong>Microsoft Azure<\/strong>, <strong>Proxmox VE<\/strong>, <strong>Amazon Web Services (AWS)<\/strong>, and numerous other virtualization and cloud platforms.<\/em><\/p>\n<p><em>Beyond running his hosting business, \u0141ukasz also provides <strong>professional paid server configuration and optimization services<\/strong> for companies and individuals. Outside of work, he is dedicated to caring for his children and building a secure future for them.<\/em><\/p>\n<p><em>If you are interested in working with him or need expert assistance with your hosting, cloud environment, or server setup, feel free to reach out via <a href=\"https:\/\/ca.netcloud24.com\" target=\"_blank\" rel=\"dofollow\">Windows VPS<\/a>.<\/em><\/p>\n<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u00a0 \u00a0 Laravel is a popular open-source PHP framework designed for web application development. It offers an elegant syntax, a range of features, and tools that make development\u2026<\/p>\n","protected":false},"author":1,"featured_media":3421,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_seopress_robots_primary_cat":"","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[],"tags":[14,12,11,23,20,21,22,17,7,8,6,10,18,19,15,24,16,5,13,9],"class_list":["post-2720","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","tag-cheapvps","tag-cloudvps","tag-hostingvps","tag-rds","tag-rdscal","tag-remotedesktop","tag-remotedesktopvps","tag-servervps","tag-ukvps","tag-virtualserver","tag-vpshosting","tag-vpsserver","tag-vpssolutions","tag-vpswindows","tag-vpswithwindows","tag-windowsrds","tag-windowsserver","tag-windowsvps","tag-windowsvpshosting","tag-windowsvpsuk"],"jetpack_publicize_connections":[],"_links":{"self":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/2720","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/comments?post=2720"}],"version-history":[{"count":0,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/posts\/2720\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media\/3421"}],"wp:attachment":[{"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/media?parent=2720"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/categories?post=2720"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netcloud24.com\/knowledgebase\/wp-json\/wp\/v2\/tags?post=2720"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}