2.8.4.2.1. Installing Laravel
Procedure
There are two ways to install the Laravel 9 base script package and dependent libraries below. The instruction is based on official documentation.
- Download the installer:
composer global require laravel/installer
- Define the path to your Laravel executable so that it runs from any directory on the filesystem:
export PATH="$PATH:~/.config/composer/vendor/bin"
- Change to the desired directory and create a new project:
laravel new name_theproject
Root directory
If the root directory of the site is different from www
(usually Laravel project files are located in the directory public
), then you can set the desired root directory in site settings or write the following directives in the file .htaccess:
# www/.htaccess <IfModule mod_rewrite.c> RewriteEngine on RewriteRule ^$ public/ [L] RewriteRule ((?s).*) public/$1 [L] </IfModule>
Also (if the root directory is specified via .htaccess), you need to create a .htaccess file in the directory public
and write the following directives in it:
# www/public/.htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^((?s).*)$ index.php?_url=/$1 [QSA,L] </IfModule>