Knowledge Base

How to install Laravel manually

This article describes how to install the Laravel PHP framework manually.

Although A2 Hosting servers are compatible with a wide variety of software applications, we cannot provide troubleshooting assistance for application-specific issues.

Installing Laravel

To install Laravel, follow these steps:

  1. Log in to your account using SSH.
  2. Laravel uses composer, a PHP dependency manager. To install Laravel, type the following commands. Replace project with the project name that you want to use:
    cd ~
    composer create-project laravel/laravel project

    This command installs the Laravel project in the /home/username/project directory, where username represents your username, and project represents the project name.

  3. To enable running Artisan by simply typing artisan at the command prompt, type the following commands. Replace username with your account username, and project with your project name:
    echo 'alias artisan="php /home/username/project/artisan"' >> ~/.bashrc
    source ~/.bashrc
    
    Artisan is the command-line interface to Laravel. When you create a Laravel project, Artisan is installed automatically in the project directory. For more information about Artisan, please visit http://laravel.com/docs/artisan.
  4. To make the Laravel project files accessible to web visitors, you must copy all of the files in the /home/username/project/public directory to the public_html directory. To do this, type the following command, replacing project with the project name:
     cp -r ~/project/public/* ~/public_html
    
    Alternatively, if you want to use a subdirectory beneath the public_html directory, copy the public files there instead. For example, the following command copies all of the public files to the laravel subdirectory:
     cp -r ~/project/public/* ~/public_html/laravel
    
    In this case, the Laravel site would be accessible at http://www.example.com/laravel, where example.com represents your domain name.
  5. In the public_html directory, open the index.php file in your preferred text editor, and then modify it as follows:
    • Locate the following line:
      require __DIR__.'/../vendor/autoload.php';
      Modify the path to include the directory where Laravel is installed. For example, if Laravel is in the project directory, you would change the line as follows:
      require __DIR__.'/../project/vendor/autoload.php'
    • Locate the following line:
      require __DIR__.'/../bootstrap/app.php';
      Modify the path to include the directory where Laravel is installed. For example, if Laravel is in the project directory, you would change the line as follows:
      require __DIR__.'/../project/bootstrap/app.php'
  6. Save your changes to the index.php file.
  7. In your web browser, go to http://www.example.com, where example.com represents your domain name. You should see the Laravel welcome page.

    Make sure you repeat steps 4 to 6 if you modify any of the public site files in the project directory.

 

More Information

For more information about Laravel, please visit https://laravel.com.