Laravel is a powerful and popular PHP framework used for building modern web applications. In this tutorial, we will guide you through the installation of the Laravel PHP Framework with Apache 2 on Ubuntu 22.04.

Step 1: Update the System

Start by updating your system to ensure all packages are up-to-date. Run the following command:

sudo apt update && sudo apt upgrade

Step 2: Install Apache 2

Apache 2 is a widely used web server. Install it with the following command:

sudo apt install apache2

After installation, start and enable Apache:

sudo systemctl start apache2
sudo systemctl enable apache2

Step 3: Install PHP and Required Extensions

Laravel requires PHP and several extensions. Install them using the following command:

sudo apt install php libapache2-mod-php php-mbstring php-xml php-bcmath php-json php-zip

Step 4: Install Composer

Composer is a dependency manager for PHP and is required for Laravel. Download and install Composer with the following commands:

curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

Step 5: Install Laravel

Now, navigate to your Apache root directory and install Laravel using Composer:

cd /var/www/html
sudo composer create-project --prefer-dist laravel/laravel mylaravelapp

Set the correct permissions:

sudo chown -R www-data:www-data /var/www/html/mylaravelapp

Step 6: Configure Apache for Laravel

Next, configure Apache to serve your Laravel application. Create a new virtual host file:

sudo nano /etc/apache2/sites-available/laravel.conf

Add the following content to the file:


    <VirtualHost *:80>
        ServerAdmin admin@example.com
        DocumentRoot /var/www/html/mylaravelapp/public
        ServerName your_domain.com

        <Directory /var/www/html/mylaravelapp/public>
            AllowOverride All
        </Directory>

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

Enable the new configuration and restart Apache:

sudo a2ensite laravel.conf
sudo systemctl restart apache2

Step 7: Test the Laravel Application

To check if everything is set up correctly, open your browser and navigate to http://your_domain.com. You should see the default Laravel welcome page.

Conclusion

Congratulations! You have successfully installed the Laravel PHP framework with Apache 2 on Ubuntu 22.04.

If you're looking for a reliable hosting solution to deploy your Laravel application, consider using Windows VPS UK services. A Windows VPS offers great flexibility and performance for hosting both PHP and other server applications. With VPS UK Windows, you can enjoy secure and scalable hosting solutions.

Whether you're looking for a Windows Virtual Private Server Hosting or need a Virtual Dedicated Server, you can find affordable and powerful options through Windows VPS Hosting UK. Many businesses across Europe, including Italy and the UK, rely on Windows VPS Italy and UK VPS Windows to handle their hosting needs, whether it's for development, testing, or production environments.

Explore more hosting options at Windows VPS UK, where you can find tailored hosting services, including Windows Virtual Dedicated Server Hosting for high-performance requirements and Windows Virtual Private Servers for scalable hosting needs.

Hai trovato utile questa risposta? 0 Utenti hanno trovato utile questa risposta (0 Voti)