-
Notifications
You must be signed in to change notification settings - Fork 1
Production server
This is how to create a production server for your website or webservice (service).
The production server is a server where you do the following.
- Checkout the git-repo of your service, for example
git/service. - Copy the essential files, needed only for production, to for example
htdocs/service. - Configure Apache with a virtual host to serve from the base dir
htdocs/service.
You need the following.
- A server with Apache and PHP, according to the basic requirements.
These are the steps to setup the structure for a website or webservice named anax.se.
Ensure your Makefile is updated with the details on setup of the produktion server. Here is a sample of that section in the Makefile for a site called anax.se.
# --------------------------------------------------------------------------
#
# Specifics for website projects
#
WWW_SITE := anax.se
SERVER_ADMIN := mos@$(WWW_SITE)
BASE_URL := https://$(WWW_SITE)/
GIT_BASE := git/$(WWW_SITE)
HTDOCS_BASE := $(HOME)/htdocs
LOCAL_HTDOCS := $(HTDOCS_BASE)/$(WWW_SITE)
Clone your source repo and save it as git/anax.se and move into that directory.
Copy your local source and install a copy with the essentials into htdocs/anax.se.
make local-install # Install and setup the directory structure
make local-publish # Copy parts of git source to production structure
Continue to setup the apache virtual host for http://anax.se.
Start by reviewing the configuration files that will be generated.
make virtual-hosts-echo
Then create an entry for a hostname local.anax.se to allow for local access. This makes it easier to test your configuration and allows for the DNS to be updated at a later stage.
make etc-hosts
Make updates to the Makefile is needed, based on your configuration. Then generate and install the configuration files and make Apache ready.
make virtual-hosts
If you need to do updates, just edit your Makefile and run make virtual-hosts again.
If it all worked out you can now access your website locally.
curl local.anax.se
Now you should update your DNS so that http://ananx.se will point to this production server. Remember that updates to the DNS might take some time before its active.
You may continue to setup the apache virtual host for HTTPS with https://anax.se.
We use the command certbot from LetsEncrypt to create a free SSL certificates.
Install the command if needed.
apt install certbot
Now we can generate and install the SSL certificate for our domain.
make ssl-cert-create
Start by reviewing the configuration files that will be generated.
make virtual-hosts-https-echo
Make updates to the Makefile is needed, based on your configuration. Then generate and install the configuration files and make Apache ready.
make virtual-hosts-https
If you want to rollback to HTTP you do this by replacing the configuration files with the HTTP setup.
make virtual-hosts
You can login to the production server and update like this.
git pull # Get the latest source
make local-publish # Copy to production
If you need to clean up the cache you can do like this.
make local-publish-clean # Copy to production and clean cache
make warm-cache # Access the site and warm the cache
You can also publish direct from your development server like this.
make production-publish # ssh to production and update it
.
..: Copyright (c) 2020 Mikael Roos, mos@dbwebb.se