What is Laravel? Laravel is a free and open-source PHP-based web framework for building web applications. It was created by Taylor Otwell and intended for the development of web applications following the MVC(model–view–controller) architectural pattern and based on Symfony. Step 1: Update System Packages First, update and upgrade your Ubuntu system packages to ensure everything is up-to-date: sudo apt update sudo apt upgrade -y Step 2: Install Apache Install Apache, which will serve your Laravel application: sudo apt install apache2 -y Start and enable Apache to start on boot: sudo systemctl start apache2 sudo systemctl enable apache2 Step 3: Install PHP and Required Extensions Laravel requires PHP 8.1 or newer. Install PHP and common extensions:unzip sudo apt install php php-cli php-fpm php-mysql php-xml php-mbstring php-curl php-zip php-bcmath php-gd unzip -y Step 4: Install MySQL Install MySQL Server to manage your databases: sudo apt install mysql-server -y Secure MySQL installation: sudo mysql_secure_installation Log in to MySQL and create a database and user for Laravel: sudo mysql -u root -p CREATE DATABASE laravel_db; CREATE USER 'laravel_user'@'localhost' IDENTIFIED BY 'Admin@123'; GRANT ALL PRIVILEGES ON laravel_db.* TO 'laravel_user'@'localhost'; FLUSH PRIVILEGES; EXIT; Step 5: Install Composer Composer is a dependency manager for PHP. Install it globally: curl -sS https://getcomposer.org/installer | php sudo mv composer.phar /usr/local/bin/composer Step 6: Install Laravel 11 Navigate to the web root directory and install Laravel: cd /var/www/html sudo composer create-project --prefer-dist laravel/laravel laravel_app Step 7: Configure Apache for Laravel Create a new Apache virtual host configuration file for your Laravel project: sudo nano /etc/apache2/sites-available/laravel_app.conf Add the following configuration to the file: <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html/laravel_app/public ServerName 192.168.224.135 <Directory /var/www/html/laravel_app/public> AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> Enable the new site and the mod_rewrite module for Apache: sudo a2ensite laravel_app.conf sudo a2enmod rewrite sudo systemctl restart apache2 Step 8: Configure Laravel Environment Update the .env file in the Laravel project to configure the database connection: sudo nano /var/www/html/laravel_app/.env Modify the database settings: DB_CONNECTION=mysql DB_HOST=127.0.0.1 DB_PORT=3306 DB_DATABASE=laravel_db DB_USERNAME=laravel_user DB_PASSWORD=Admin@123 Now, Migrate the database. cd /var/www/html/laravel_app php artisan migrate Step 9: Set Directory Permissions Ensure Laravel has the correct permissions to write to the necessary directories: sudo chown -R www-data:www-data /var/www/html/laravel_app sudo chmod -R 775 /var/www/html/laravel_app/storage sudo chmod -R 775 /var/www/html/laravel_app/bootstrap/cache Step 10: Test the Laravel Installation Visit your server's IP address or domain in your web browser: http://192.168.224.135/ You should see the Laravel welcome page. Optional: Set Up SSL with Let's Encrypt To secure your Laravel application with SSL, use Certbot: sudo apt install certbot python3-certbot-apache -y Obtain and configure an SSL certificate: sudo certbot --apache -d example.com -d www.example.com Certbot will handle the installation and configuration of the SSL certificate. Step 11: Finalize the Setup Finally, ensure everything is working: http://192.168.224.135/ Your Laravel 11 application should now be fully configured and accessible via your domain or IP address.