How to Use Vultr's Laravel Marketplace Application

Laravel is a popular, open-source PHP web framework designed for building modern web applications with elegant syntax. It follows the Model-View-Controller (MVC) architectural pattern and provides powerful features like Eloquent ORM, Blade templating, built-in authentication, and comprehensive tooling for database migrations, task scheduling, and API development. The Vultr Marketplace provides a pre-configured Laravel environment with the complete LAMP stack, enabling quick deployment and setup on a Vultr server.
This guide explains deploying and using Vultr's Laravel Marketplace Application. You will deploy an instance, configure DNS and SSL, connect to a Vultr Managed Database, explore Laravel features, and implement security best practices for deployment.
Deploy Vultr's Laravel Marketplace Application
Log in to your Vultr Customer Portal and click the Deploy Server button.
Select your preferred server type.
Choose a server location.
Select a server plan with at least 2GB RAM and 2 CPU cores for production workloads.
Click the Configure button to proceed.
Under Marketplace Apps, search for
Laraveland select it as the Marketplace Application.Select the Limited Login option from the Additional Features section to create a limited user with sudo access.
Review your configurations and click the Deploy Now button to start deployment.
It may take up to 10 minutes for your server to finish installing Laravel and the LAMP stack.NoteAfter the instance shows the status of Running, navigate to the Server Overview page and copy the SSH connection details.
Initial Setup and Configuration
After deployment, configure DNS, verify the installation, and secure your Laravel application with SSL/TLS before exposing it to production traffic.
Create a DNS A record pointing to your server's IP address, such as
laravel.example.com.Connect to your Vultr server instance over SSH using the connection details from the Server Overview page.
Verify Laravel Installation
Check the Apache web server status.
console$ sudo systemctl status apache2
The service should show as
active (running).Navigate to the Laravel project directory.
console$ cd /var/www/html/my-laravel-app
Verify Laravel installation and check the version.
console$ php artisan --version
Output:
Laravel Framework 12.34.0Test the application by accessing
http://laravel.example.comin a web browser. You should see the default Laravel welcome page.
Configure Firewall Security
Secure your server by configuring the firewall to allow only necessary traffic before enabling SSL.
Allow SSH connections.
console$ sudo ufw allow OpenSSH
Allow HTTP and HTTPS traffic for Apache and Certbot.
console$ sudo ufw allow "Apache Full"
Enable the firewall.
console$ sudo ufw enable
Verify firewall status.
console$ sudo ufw status
Secure Laravel with SSL/TLS
Protect your Laravel application with HTTPS using Let's Encrypt certificates via Certbot.
Install Certbot and the Apache plugin.
console$ sudo apt install certbot python3-certbot-apache -y
Request an SSL certificate for your domain.
console$ sudo certbot --apache -d laravel.example.com
Follow the prompts and select the option to redirect HTTP traffic to HTTPS when asked.
Verify SSL certificate auto-renewal.
console$ sudo certbot renew --dry-run
Access your Laravel application securely at
https://laravel.example.com.
Configure Laravel Application
Set up your Laravel application environment, configure the database connection, and prepare for deployment.
Update Environment Configuration
Navigate to the Laravel project directory.
console$ cd /var/www/html/my-laravel-app
Edit the
.envfile.console$ nano .env
iniAPP_NAME="My Laravel App" APP_ENV=production APP_DEBUG=false APP_URL=https://laravel.example.com
Set
APP_DEBUG=falseto prevent sensitive information leakage.Save and close the file.
Set Proper Permissions
Set ownership to the web server user.
console$ sudo chown -R www-data:www-data /var/www/html/my-laravel-app
Set safe file permissions (644 for files, 755 for directories).
console$ sudo find /var/www/html/my-laravel-app -type f -exec chmod 644 {} \; $ sudo find /var/www/html/my-laravel-app -type d -exec chmod 755 {} \;
Set writable permissions for storage and cache directories.
console$ sudo chmod -R 775 /var/www/html/my-laravel-app/storage $ sudo chmod -R 775 /var/www/html/my-laravel-app/bootstrap/cache
Create a symbolic link for public storage.
console$ cd /var/www/html/my-laravel-app $ php artisan storage:link
This allows uploaded files and images to be publicly accessible.
Configure Apache Virtual Host
Edit the Apache configuration file for your Laravel application.
console$ sudo nano /etc/apache2/sites-available/laravel.conf
ini<VirtualHost *:80> ServerName laravel.example.com ServerAdmin admin@laravel.example.com DocumentRoot /var/www/html/my-laravel-app/public <Directory /var/www/html/my-laravel-app/public> Options -Indexes +FollowSymLinks AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/laravel-error.log CustomLog ${APACHE_LOG_DIR}/laravel-access.log combined </VirtualHost>
Replace
laravel.example.comwith your domain name.Disable the default site and enable Laravel site.
console$ sudo a2dissite 000-default.conf $ sudo a2ensite laravel.conf $ sudo a2enmod rewrite
Test Apache configuration.
console$ sudo apache2ctl configtest
Output:
Syntax OKReload Apache to apply changes.
console$ sudo systemctl reload apache2
Connect to Vultr Managed Database
Enhance your Laravel application's reliability and scalability by connecting to a Vultr Managed Database for MySQL. This provides automatic backups, monitoring, and maintenance.
Deploy a Vultr Managed Database for MySQL from the Vultr Customer Portal.
From the Managed Database dashboard, note the following connection details:
- Host
- Port
- Database name
- Username
- Password
Edit the Laravel
.envfile.console$ nano /var/www/html/my-laravel-app/.env
iniDB_CONNECTION=mysql DB_HOST=your-managed-db-host.vultr.com DB_PORT=16751 DB_DATABASE=defaultdb DB_USERNAME=vultradmin DB_PASSWORD=your_secure_password
Save and close the file.
Update Laravel's database configuration to require SSL connections.
console$ nano /var/www/html/my-laravel-app/config/database.php
Locate the
mysqlconfiguration array and add SSL settings.php'mysql' => [ 'driver' => 'mysql', 'url' => env('DATABASE_URL'), 'host' => env('DB_HOST', '127.0.0.1'), 'port' => env('DB_PORT', '3306'), 'database' => env('DB_DATABASE', 'forge'), 'username' => env('DB_USERNAME', 'forge'), 'password' => env('DB_PASSWORD', ''), 'unix_socket' => env('DB_SOCKET', ''), 'charset' => 'utf8mb4', 'collation' => 'utf8mb4_unicode_ci', 'prefix' => '', 'prefix_indexes' => true, 'strict' => true, 'engine' => null, 'options' => extension_loaded('pdo_mysql') ? array_filter([ PDO::MYSQL_ATTR_SSL_CA => env('MYSQL_ATTR_SSL_CA'), PDO::MYSQL_ATTR_SSL_VERIFY_SERVER_CERT => false, ]) : [], ],
Save and close the file.
Test the database connection.
console$ php artisan migrate:status
If the connection is successful, you'll see the migration table status.
Run database migrations to create tables.
console$ php artisan migrate
(Optional) Seed the database with initial data.
console$ php artisan db:seed
Explore Laravel Features
Laravel provides a rich set of features for building modern web applications. This section demonstrates core functionality.
Artisan CLI Commands
Artisan is Laravel's command-line interface for managing your application.
List all available Artisan commands.
console$ php artisan list
Create a new controller.
console$ php artisan make:controller ProductController
Create a new model with migration.
console$ php artisan make:model Product -m
Clear application cache.
console$ php artisan cache:clear $ php artisan config:clear $ php artisan route:clear $ php artisan view:clear
Task Scheduling
Laravel's task scheduler allows you to manage scheduled tasks within your application.
Edit the server's crontab.
console$ sudo crontab -e -u www-data
ini* * * * * cd /var/www/html/my-laravel-app && php artisan schedule:run >> /dev/null 2>&1
This runs Laravel's task scheduler every minute.
Define scheduled tasks in
app/Console/Kernel.php.
Queue Workers
For handling background jobs, configure Laravel's queue system.
Update the
.envfile to use the database queue driver.console$ nano /var/www/html/my-laravel-app/.env
iniQUEUE_CONNECTION=database
Save and close the file.
Create the jobs table.
console$ php artisan queue:table $ php artisan migrate
Start a queue worker.
console$ php artisan queue:work --tries=3
Set up Supervisor to keep the queue worker running.
console$ sudo apt install supervisor -y
Create a Supervisor configuration file for the Laravel queue worker.
console$ sudo nano /etc/supervisor/conf.d/laravel-worker.conf
ini[program:laravel-worker] process_name=%(program_name)s_%(process_num)02d command=php /var/www/html/my-laravel-app/artisan queue:work --sleep=3 --tries=3 --max-time=3600 autostart=true autorestart=true stopasgroup=true killasgroup=true user=www-data numprocs=1 redirect_stderr=true stdout_logfile=/var/www/html/my-laravel-app/storage/logs/worker.log stopwaitsecs=3600
Save and close the file.
Start the Supervisor worker.
console$ sudo supervisorctl reread $ sudo supervisorctl update $ sudo supervisorctl start laravel-worker:*
Check the worker status.
console$ sudo supervisorctl status
Best Practices and Configuration
Implement these recommendations to ensure your Laravel application runs securely and efficiently.
Enable Production Optimizations
Cache configuration files for faster loading.
console$ php artisan config:cache
Cache routes for better performance.
console$ php artisan route:cache
Cache views to reduce compilation overhead.
console$ php artisan view:cache
Optimize Composer autoloader.
console$ composer install --optimize-autoloader --no-dev
Security Hardening
Ensure the
.envfile is not accessible via the web.console$ sudo chmod 600 /var/www/html/my-laravel-app/.env
Disable directory listing in Apache (already configured in virtual host with
-Indexes).Keep Laravel and dependencies updated.
console$ composer update $ php artisan migrate
Implement rate limiting for API routes in
app/Http/Kernel.php.
Monitoring and Logging
Configure log channels in
config/logging.php.View Laravel logs.
console$ tail -f /var/www/html/my-laravel-app/storage/logs/laravel.log
View Apache error logs.
console$ sudo tail -f /var/log/apache2/laravel-error.log
Monitor application performance with Laravel Telescope (for development).
console$ composer require laravel/telescope --dev $ php artisan telescope:install $ php artisan migrate
Troubleshooting
This section covers common issues and diagnostic commands to help resolve problems with your Laravel application.
Check Service Status
Verify Apache is running.
console$ sudo systemctl status apache2
Check MySQL service (if using local MySQL).
console$ sudo systemctl status mysql
View recent Apache error logs.
console$ sudo tail -50 /var/log/apache2/error.log
Common Issues
500 Internal Server Error
Check Laravel logs for detailed error messages.
console$ tail -f /var/www/html/my-laravel-app/storage/logs/laravel.log
Ensure proper permissions.
console$ sudo chown -R www-data:www-data /var/www/html/my-laravel-app $ sudo chmod -R 775 /var/www/html/my-laravel-app/storage
Clear all caches.
console$ php artisan cache:clear $ php artisan config:clear $ php artisan route:clear
Database Connection Issues
Open Tinker to test the database connection.
console$ php artisan tinker
In the Tinker prompt, run:
sql> DB::connection()->getPdo();
Verify database credentials in
.envfile.Check if the Managed Database allows connections from your server's IP.
Permission Denied Errors
Fix ownership and permissions.
console$ sudo chown -R www-data:www-data /var/www/html/my-laravel-app $ sudo chmod -R 755 /var/www/html/my-laravel-app $ sudo chmod -R 775 /var/www/html/my-laravel-app/storage $ sudo chmod -R 775 /var/www/html/my-laravel-app/bootstrap/cache
Use Cases
Laravel excels in various real-world application scenarios:
- E-commerce Platforms: Build scalable online stores with Laravel's Eloquent ORM, payment gateway integrations, and inventory management capabilities.
- SaaS Applications: Develop multi-tenant SaaS platforms with Laravel's authentication, authorization, and subscription billing features.
- Content Management Systems: Create custom CMS solutions with Laravel's flexible routing, Blade templating, and media management.
- RESTful APIs: Build robust APIs for mobile and web applications with Laravel's API resources, authentication, and rate limiting.
- Real-time Applications: Implement real-time features like chat, notifications, and live updates using Laravel Echo and WebSockets.
- Enterprise Applications: Develop complex business applications with Laravel's comprehensive tooling, testing capabilities, and maintainable code structure.
Conclusion
In this guide, you deployed Vultr's Laravel Marketplace Application with a complete LAMP stack. You configured DNS, secured the application with SSL/TLS, connected to a Vultr Managed Database for enhanced reliability, and implemented best practices including caching, security hardening, and monitoring. With Laravel's powerful features and Vultr's infrastructure, you can build and deploy scalable, modern web applications efficiently.