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#
- Navigate to Websites from the sidebar
- Click “+ Add New Website”
- Enter your domain name
- 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
- Choose “Laravel” as the framework
- Enable “Create Database” (recommended) — This creates a MySQL database and automatically configures the
.envfile with the correct credentials - Click “Create”
HostsNix will handle the entire setup process:
- Creates a fresh Laravel project using
composer create-project - Installs all Composer dependencies
- Configures the
.envfile with your database credentials, app URL, and application key - Generates the application encryption key (
php artisan key:generate) - Sets proper file permissions (writable
storage/andbootstrap/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_filesdirective routes all requests throughindex.phpfor 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 toproductionfor live sitesAPP_DEBUG— Set tofalsein 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 notificationsCACHE_DRIVER— Usefileorredisfor cachingSESSION_DRIVER— Usefile,database, orredis
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.