Installing Laravel
Comprehensive guide to deploying the Laravel framework on Web Hosting and VPS.
Laravel is a sophisticated, open-source PHP framework designed for modern web development. Following the MVC (Model-View-Controller) architectural pattern, it provides developers with an elegant syntax, a robust suite of tools, and an expansive ecosystem.
Before you begin, ensure that Composer—the essential dependency manager for PHP—is installed on your system.
Method 1: Using the Laravel installer (recommended)
This is the most efficient way to manage multiple Laravel projects.
-
Install the Laravel installer globally:
composer global require laravel/installer -
Configure your system path (to ensure the
laravelcommand is recognized):
For Ubuntu/Debian, add the following to your profile:export PATH="$PATH:$HOME/.config/composer/vendor/bin" source ~/.bashrc -
Spin up a new project:
laravel new project_name
Method 2: Installation via Composer create-project
If you prefer a one-off installation without the global installer, run this command in your desired directory:
composer create-project laravel/laravel project_name
Configuring the Document Root
By default, Laravel’s entry point is the /public directory. To ensure your site loads correctly, you must point your web server to this folder.
-
Option A: Update hosting settings (recommended).
In your control panel, change the site's "Document Root" or "Home Directory" to/path/to/your/project/public. -
Option B: Using .htaccess (Workaround).
If you cannot change the document root, create a.htaccessfile in your project root:
# .htaccess in project root
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule ^$ public/ [L]
RewriteRule ^((?s).*) public/$1 [L]
</IfModule>
Then, ensure the default .htaccess exists inside the /public folder:
# public/.htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
Post-installation tips
- Set permissions: for Laravel to run smoothly, the web server needs write access to specific folders:
chmod -R 755 storage bootstrap/cache
chown -R www-data:www-data storage bootstrap/cache # для Ubuntu/Debian
- Production readiness: for tasks like queues and scheduling, consider setting up Supervisor or a system Cron job.
- Official documentation: for the latest updates and deep-dive tutorials, visit the official laravel.com
Help
If you have any questions or need assistance, please contact us through the ticket system — we're always here to help!