Website Deployment: From Domain and Hosting to a Live HTTPS Site
What is website deployment?
Website deployment is the process of moving a finished website from your computer to a server connected to the internet, so visitors can reach it through a domain name. It covers pointing DNS at the server, uploading code, setting production configuration, enabling HTTPS, preparing the database and planning backups, so that each later release is repeatable and safe.
Key deployment terms
- Domain name: the human-readable address, such as
example.in, that you rent yearly from a registrar. - DNS record: an entry that maps the domain to a server. An
Arecord points to an IPv4 address,AAAAto an IPv6 address andCNAMEto another hostname. - TTL (time to live): how long resolvers may cache a record before asking again. Lower it a day before you change servers so the switch spreads faster.
- Document root: the folder the web server serves publicly, such as
public/in CodeIgniter or Laravel. - Environment: a copy of the site with its own settings, usually development, staging and production.
- Release: one deployed version of the code, ideally tied to a Git commit or tag.
If DNS is new to you, read how DNS resolves a name to an address first; most "my site is not showing" problems after a launch are DNS or caching issues.
Shared hosting with cPanel vs a VPS
| Aspect | Shared hosting (cPanel) | VPS |
|---|---|---|
| Server management | Done by the host | Done by you: updates, firewall, web server |
| Access | File Manager, SFTP, sometimes SSH and Git | Full root access over SSH |
| Flexibility | Fixed PHP versions and limited extensions | Install any software and configure freely |
| Suits | Brochure sites, small WordPress or PHP sites | Custom apps, queues, multiple sites, higher traffic |
| Skills needed | Basic | Comfort with Linux commands and security hardening |
Shared hosting is a sensible start because the host patches the operating system for you. A VPS gives control, but every security update becomes your responsibility.
Uploading code: Git versus SFTP
SFTP (file transfer over SSH) works everywhere, but manual uploads are easy to get wrong: a forgotten file or a half-finished upload can break the live site. Prefer plain SFTP over FTP, which sends passwords unencrypted.
A Git-based deploy is more reliable. The server pulls a known commit, so every release is traceable and easy to roll back. Keep your workflow from the Git and GitHub guide and deploy only from main or a tag.
ssh [email protected]
cd /var/www/myapp
git fetch --tags
git checkout v1.4.0
composer install --no-dev --optimize-autoloader
php spark migrate # CodeIgniter 4; Laravel uses: php artisan migrate --force Production configuration and HTTPS
Production settings differ from your laptop: errors must be logged, not shown, and credentials must come from the server, not from Git. Create the .env file directly on the server and restrict its permissions.
# .env on the production server (never committed)
CI_ENVIRONMENT = production
app.baseURL = 'https://example.in/'
database.default.hostname = localhost
database.default.database = myapp
database.default.username = myapp_user
database.default.password = change-meHTTPS is expected on every site. Let's Encrypt is a free certificate authority whose certificates are short-lived, so renewal must be automated. On cPanel, the host usually provides AutoSSL or a Let's Encrypt button. On a VPS, Certbot obtains and renews certificates:
sudo certbot --nginx -d example.in -d www.example.in
sudo certbot renew --dry-run # confirms automatic renewal will workAfter HTTPS works, redirect all HTTP requests to HTTPS with a 301 and update the base URL so links and assets do not load over plain HTTP.
Databases, backups and zero-downtime basics
Use migrations (version-controlled schema changes) rather than editing tables by hand on the live server. Before running them, take a backup. For MySQL databases, mysqldump creates a consistent dump of InnoDB tables:
mysqldump --single-transaction -u myapp_user -p myapp > backup-2026-11-10.sql
mysql -u myapp_user -p myapp < backup-2026-11-10.sql # restore- Back up the database and uploaded files on a schedule, and keep at least one copy off the server.
- Test a restore regularly; a backup you have never restored is only a hope.
- For near-zero downtime, deploy each release into its own folder, install dependencies there, then switch a
currentsymlink withln -sfn releases/v1.4.0 currentand reload PHP-FPM so OPcache picks up the new code. - Write migrations that are backwards-compatible (add a column first, remove the old one in a later release) so old and new code can run briefly side by side.
A repeatable deployment checklist
- Run tests locally and merge to
main; tag the release. - Back up the database and uploaded files.
- Pull the tagged code on the server or upload the build over SFTP.
- Install production dependencies and run migrations.
- Clear or warm caches, then reload PHP-FPM or the web server.
- Check the home page, a form, the login and the error log. Keep the previous release ready for a rollback.
Moving an existing site to a new domain or URL structure also needs redirects; see migrating a site without losing search traffic.
Practical exercise: deploy a small PHP site with HTTPS
- Push a small PHP project with a
public/folder and a.env.examplefile to a Git repository. - On a test server or hosting account you control, clone the repository outside the document root and point the domain or subdomain at
public/. - Create the
.envfile on the server, runcomposer install --no-dev, and run migrations. - Issue a Let's Encrypt certificate, add an HTTP-to-HTTPS redirect, and run
certbot renew --dry-runor confirm AutoSSL is active. - Take a
mysqldumpbackup, restore it into a second empty database, and confirm the row counts match.
You are done when the site loads over HTTPS, https://yourdomain/.env returns a 404 or 403, and you can redeploy with one documented set of commands. The Advanced PHP course practises this release process on real projects.
Common mistakes
- Pointing the document root at the project folder instead of
public/, which can expose.envand source code. - Leaving
display_errorson in production, which shows file paths and queries to visitors. - Running migrations without a fresh backup, leaving no way back if a change fails.
- Editing files directly on the live server, so the server and Git no longer match.
- Forgetting to automate certificate renewal, so the site shows a security warning when the certificate expires.
Frequently asked questions
How long does a DNS change take to work?
It depends on the TTL of the old record and on resolver caches. Changes are often visible within minutes to a few hours; lowering the TTL in advance shortens the wait.
Do I need a VPS for a PHP or WordPress site?
No. Shared hosting runs most small PHP and WordPress sites well. Move to a VPS when you need custom software, background workers or more control.
What is a staging environment?
A private copy of the live site with production-like settings where you test a release before it reaches visitors. It should use its own database and must not be indexed by search engines.