Add Sub-domain and install WordPress
And we can also install a sub-domain of our domain using similar step as adding secondary domain.
Add sub-domain using DNS Setting
- Go to DNS Setting in your DO Control Panel.
- Select / “view” the domain you want.
- Click “Add Record” and select “A“.
- In “Hostname” field, input the sub-domain, for example: “subdomain“.
- In “IP Address” field, input your droplet IP Address (should be the same as “@” A Record if you want to host it in the same droplet.
So for example we create a sub-domain of our “secondary-domain.com”, with the above setup, the sub-domain we create is “http://subdomain.secondary-domain.com”.
Visit your sub-domain url
When you visit “http://subdomain.secondary-domain.com” you’ll see the same content as your main site (that hosted on “var/www”) which is “http://example-domain.com”.
Assign “public_html” folder for your sub-domain
Same with the step above, we create a file “subdomain.secondary-domain.com” in “/etc/apache2/sites-enabled” and add content:
- <VirtualHost *:80>
- ServerName subdomain.secondary–domain.com
- DocumentRoot /var/web/subdomain.secondary–domain.com
As you see, we do not create “ServerAlias” config for this sub-domain.
The next step is the same as configuring secondary-domain.com, we need to create the the path, and check that the sub-domain linked to the DocumentRoot path after we restart apache.
Crete Snapshot of Our Server
After all configured correctly, if you want to re-use the server setup to another droplet, we can create an image / snapshot of our server.
Power Off / Turn Off Our Server.
Using PuTTY type this command:
You’ll be disconnected from your server, because it’s now off.
Create Snapshot Image
Go to DO Control Panel, and navigate to “Droplet > Your Droplet”. Click “Snapshot > Take a Snapshot”.
After you create the snapshot you can restore your server to this state or create another droplet using this “image”.
All Done Enjoy 🙂