VPS Special Offer: Get 20% OFF Your First Month + 10% OFF Monthly Renewals, or Save 20% When You Go Yearly

Installing Laravel with HostsNix

Installing Laravel Laravel is the most popular PHP framework for building modern web applications, and HostsNix supports automated Laravel project creation with everything configured correctly out of the box —…

Installing Laravel#

Laravel is the most popular PHP framework for building modern web applications, and HostsNix supports automated Laravel project creation with everything configured correctly out of the box — Nginx routing, Composer dependencies, environment configuration, and database setup.

Creating a Laravel Project#

  1. Navigate to Websites from the sidebar
  2. Click “+ Add New Website”
  3. Enter your domain name
  4. Select PHP 8.2 or 8.3 — Laravel 11 requires PHP 8.2 or higher. PHP 8.3 is recommended for the best performance with latest Laravel
  5. Choose “Laravel” as the framework
  6. Enable “Create Database” (recommended) — This creates a MySQL database and automatically configures the .env file with the correct credentials
  7. Click “Create”

HostsNix will handle the entire setup process:

  • Creates a fresh Laravel project using composer create-project
  • Installs all Composer dependencies
  • Configures the .env file with your database credentials, app URL, and application key
  • Generates the application encryption key (php artisan key:generate)
  • Sets proper file permissions (writable storage/ and bootstrap/cache/)
  • Configures Nginx to serve from the public/ directory with proper rewrite rules for Laravel routing

Nginx Configuration#

The Nginx virtual host is automatically configured with Laravel-optimized settings:

  • Document root points to /rknix/www/yourdomain.com/htdocs/public (Laravel’s public directory)
  • try_files directive routes all requests through index.php for Laravel’s routing
  • Static files (CSS, JS, images) are served directly by Nginx for best performance
  • Common security headers are pre-configured

If you need to customize the Nginx configuration (e.g., for API rate limiting or custom headers), use the Vhost Configuration option in Website Settings.

Running Artisan Commands#

For Laravel development tasks like migrations, seeding, and queue management, you’ll need SSH access. Connect to your server and navigate to your project directory:

cd /rknix/www/yourdomain.com/htdocs

# Run migrations
php artisan migrate

# Seed the database
php artisan db:seed

# Clear all caches
php artisan optimize:clear

# Start the queue worker
php artisan queue:work

Environment Configuration#

You can edit the .env file directly from the HostsNix File Manager. Common settings you might want to adjust:

  • APP_ENV — Set to production for live sites
  • APP_DEBUG — Set to false in production (never leave debugging enabled on a public site)
  • APP_URL — Your full domain URL including https://
  • MAIL_* — Configure email settings for password resets and notifications
  • CACHE_DRIVER — Use file or redis for caching
  • SESSION_DRIVER — Use file, database, or redis

Troubleshooting#

“Permission denied” errors in storage: Laravel needs write access to storage/ and bootstrap/cache/. Set permissions to 775 for these directories using the File Manager.

Routes returning 404: The Nginx configuration may not be routing properly. Check Website Settings → Vhost Configuration and ensure the try_files directive includes /index.php?$query_string.

Composer memory errors: Large Laravel projects with many dependencies may need more PHP memory. Increase memory_limit in PHP Settings to 512M or higher.

Follow HostsNiX on Google