Book Review: How to Implement Design Patterns in PHP
Installing Xdebug for use with Eclipse or Netbeans on Linux
Getting Set up with Ogre 3D on Ubuntu
Symfony 2 Crash Course
Using PHP pspell Spell Check Functions with a Custom Dictionary
Nice n' Easy JQuery Image Rotator

Creating a new site on Apache and Ubuntu 24.04

Monday, 11 August 25, 5:54 pm
Setting up new sites on Apache2 is very easy these days. I'm writing the steps down here for future reference.

Create the Apache vhost

First thing to do is create the config for the new site as a separate file at /etc/apache2/sites-available/DOMAIN.NAME.conf:
<VirtualHost *:80> ServerName DOMAIN.NAME ServerAlias www.DOMAIN.NAME   DocumentRoot /var/www/DOMAIN   <Directory /var/www/DOMAIN> # DirectoryIndex my_landing_page.html Options -Indexes Options FollowSymLinks AllowOverride All Require all granted </Directory>   ErrorLog ${APACHE_LOG_DIR}/DOMAIN-error.log CustomLog ${APACHE_LOG_DIR}/DOMAIN-access.log combined </VirtualHost>
Next, enable it:
sudo a2ensite DOMAIN.NAME.conf sudo systemctl reload apache2
Your site is now up and running. If the DNS is not currently pointing at the new location, e.g. if this is a site being migrated from elsewhere, you can put the domain and new IP in your hosts file locally in order to test everything is working. Once you're happy, update the DNS to make the new server public.

Run Certbot for the new domain

Assuming you want to enable HTTPS for the new site, once DNS is pointing to the new server, run Certbot:
sudo certbot --apache -d DOMAIN.NAME -d www.DOMAIN.NAME
Certbot will detect the new Apache config, verify domain ownership by creating files on your server, issue and install the certificate, and additionally set up an HTTP to HTTPS redirect - you don't have to do this yourself in .htaccess.

Please enter your comment in the box below. Comments will be moderated before going live. Thanks for your feedback!

Cancel Post