Deploying a Laravel AI Project on a VPS
(Apache VirtualHost + SSL + GitHub SSH Setup)
In this guide, we'll launch a subdomain like ai.kitmote.com from scratch.
The structure we will establish:
- Apache VirtualHost
- SSL (Let's Encrypt)
- GitHub SSH deploy
- Laravel folder structure compatible operation.
1️⃣ Apache VirtualHost Installation
📁 Project directory
First, make sure the project is in the right place:
mkdir -p ai.kitmote.com
cd ai.kitmote.com
The Laravel project will be here.
📄 Create a VirtualHost file
Write this inside:
ServerName ai.kitmote.com
ServerAlias www.ai.kitmote.com
DocumentRoot /var/www/ai.kitmote.com/public
<Directory /var/www/ai.kitmote.com/public>
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/ai_error.log
CustomLog ${APACHE_LOG_DIR}/ai_access.log combined
</VirtualHost>
🔧 Enable Apache modules
🔗 Activate the site
If it's available, disable it by default:
🔄 Apache restart
✅ Test
From the browser:
It should open if you have Laravel.
2️⃣ SSL Setup (Let's Encrypt)
📦 Certbot setup
sudo apt install certbot python3-certbot-apache -y
🔐 Get SSL
Questions:
- Email → Log in
- Redirect HTTP → Select YES (important)
🔁 Auto-renew control
✅ Test
3️⃣ GitHub SSH Key Setup
The most reliable method for production deployment is SSH.
🔑 Generate SSH key
Enter → Enter → Enter
🔍 Get public key
Copy what comes up.
🔗 Add to GitHub
GitHub →
👉 Settings → SSH and GPG Keys → New SSH Key
🔌 Test
Output:
4️⃣ Uploading the Project to the Server
git clone git @github.com:USERNAME/REPO.git .
⚠️ Correct permissions
sudo chmod -R 755 /var/www/ai.kitmote.com
Laravel exclusive:
5️⃣ Laravel Installation Steps
📦 Addictions
⚙️ ENV
nano .env
🔑 Generate Key
🗄️ Migration
⚡ Cache optimization
php artisan route:cache
php artisan view:cache
6️⃣ Production Recommendations
🔥 Queue (optional)
Recommended with a supervisor.
🔍 Log check
🔄 Post-deployment update
composer install --no-dev
php artisan migrate --force
PHP Artisan Optimize
7️⃣ Common Mistakes
❌ 403 Forbidden
Is AllowOverride enabled?
Is Apache rewrite active?
❌ 500 Error
→ .env error
→ storage permissions
❌ 502 / blank page
Is Apache running?
🎯 Result
With this structure:
- ✅ Domain → VPS connected
- ✅ Apache → Laravel is running
- ✅ SSL → active
- ✅ GitHub → Automatic deployment ready
Keywords: Ferhat Gölge, homepage, portfolio, blog, Laravel, software developer