The cart is empty

Before installing Laravel, it's important to ensure that your server meets the following requirements:

  • PHP 7.3 or higher
  • Composer (PHP package manager)
  • SSH access to the server

Step 1: Log in to the Server

First, log in to your server using SSH. If you have a Linux server, you can use the following command:

ssh username@your_server

Step 2: Install PHP and Other Dependencies

Before installing Laravel, you need to have PHP and some of its extensions installed. Use your system's package manager to install PHP and the necessary extensions. For example, on Debian or Ubuntu, you can use:

sudo apt update
sudo apt install php php-cli php-mbstring php-xml php-curl git unzip

Step 3: Install Composer

Composer is a dependency management tool for PHP that allows easy installation and updating of libraries. You can install Composer using the following commands

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
sudo mv composer.phar /usr/local/bin/composer

Step 4: Install Laravel

After installing Composer, you can proceed to install Laravel. First, navigate to the directory where you want to install Laravel. Then, use Composer to create a new Laravel project:

cd /path/to/your/directory
composer create-project --prefer-dist laravel/laravel project_name

Step 5: Configure the Web Server

For Laravel application to function properly, you need to configure your web server to point requests to the public directory of your Laravel application. Below is an example configuration for Nginx:

server {
    listen 80;
    server_name your_domain.com;
    root /path/to/your/directory/project_name/public;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    index index.php;

    charset utf-8;

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

    location ~ /\.(?!well-known).* {
        deny all;
    }
}

After saving the configuration, restart your web server:

sudo systemctl restart nginx

Step 6: Secure Your Application

Before deploying your application, don't forget to secure your server and application. This includes setting up a firewall, protection against attacks, software updates, and using secure login credentials.

Congratulations, Laravel is now installed on your server and ready for developing your web application.