Before uploading
- Set
CI_ENVIRONMENT = productionin the server's.env - Set
app.baseURLto your live URL withhttps:// - Set the live database and email settings
- Remove
index.phpfrom URLs:app.indexPage = ''(the.htaccessinpublichandles rewriting)
On a VPS (recommended)
- Pull the code with Git
composer install --no-dev --optimize-autoloaderphp spark migrate- Make
writablewritable by the web server - Point the domain's document root to
public - Newer versions:
php spark optimizecaches config for speed
On shared hosting (cPanel / Hostinger)
- Upload the project outside
public_html(for example/home/user/myapp) - Copy the contents of
publicintopublic_html - In
public_html/index.php, fix the path toapp/Config/Paths.phpso it points intomyapp - Import the database with phpMyAdmin and set
.env
After going live
Check writable/logs for errors, make sure the Debug Toolbar is not shown, and back up the database before every update.
Example
Example — VPS deployment steps
Bash
cd /var/www/myapp
# 1. Get the latest code
git pull origin main
# 2. Install packages without dev tools
composer install --no-dev --optimize-autoloader
# 3. Run database migrations
php spark migrate
# 4. Clear the cache
php spark cache:clear
# 5. Permissions for the writable folder (first deploy)
sudo chown -R www-data:www-data writable
sudo chmod -R 775 writable
# Apache virtual host (document root must be public):
# DocumentRoot /var/www/myapp/public
# <Directory /var/www/myapp/public>
# AllowOverride All
# </Directory>
After these steps the site runs the new code. AllowOverride All lets public/.htaccess remove index.php from URLs.