apache2 - add virtual server that uses subdomain with PHP and Cloudflare DNS
In this article we would like to show how to add subdomain as virtual server for apache2 that uses PHP engine with Cloudflare DNS / CDN.
Preseted article configures Open Web Analitics that:
- was installed in own separated folder,
- will be available from:
https://owa.my-domain.com
.
It is necessary to configure apache2 server at first and later Cloudflare DNS.
1.1. login as root to yours server,
1.2. create new configuration file in sites-avaialble
directory with command:
xxxxxxxxxx
nano /etc/apache2/sites-available/open-web-analytics.conf
1.3. put inside following configuration:
xxxxxxxxxx
<VirtualHost *:80>
ServerName owa.my-domain.com
DocumentRoot /var/www/html/open-web-analytics
DirectoryIndex index.php
</VirtualHost>
Where:
owa.my-domain.com
- subdomain used with Open Web Analitics,/var/www/html/open-web-analytics
- directory path with installed Open Web Analitics,index.php
- script that runs Open Web Analitics.
1.4. enable open-web-analytics
site
Use following command:
xxxxxxxxxx
a2ensite open-web-analytics.conf
Output:
xxxxxxxxxx
Enabling site open-web-analytics.
To activate the new configuration, you need to run:
systemctl reload apache2
1.5. Reload apache2 configuration witout restarting
Run following command:
xxxxxxxxxx
systemctl reload apache2
2.1. login to Cloudflare panel: https://dash.cloudflare.com/login
2.2. select your domain on main page - will be visible after login operation

2.3. go to DNS configuration

2.4. add new DNS record by clicking to: + Add record
2.5. select following configuration:
xxxxxxxxxx
Type: A
Name: owa
IPv4 address: 77.55.222.88
Where: owa
and 77.55.222.88
can be replaced by own configuration.
It will give us traffic from
https://owa.my-domain.com
to server located on77.55.222.88
where virtual server described byServerName owa.my-domain.com
will be used.

2.6. save configuration and check if new record appeared

3.1. go to following address: https://owa.my-domain.com
,
3.2. as result you should see:
