By SprX
I tried multiple tutorials online but up to no avail.
I want to point my new domain (eg newdomain.com) to a folder in /var/www/html/new/.
I bought the domain off namecheap.com and have set the custom DNS to dns1-3.digitalocean.com. Next, I made the DNS changes in the Networking area in the control panel. https://i.imgur.com/9tbsT4C.png
Afterwards, I created a Apache’s VirtualHost in /etc/apacheites-available
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/mew
ServerAlias newdomain.com
ServerName newdomain.com
<Directory /var/www/html/new>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass / http://IP-ADDRESS/new/ Keepalive=On
ProxyPassReverse / http://IP-ADDRESS/new/
ProxyPreserveHost On
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
After restarting Apache2, my primary + new domain doesn’t seem to be loading at all.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
You don’t need the ProxyPass configuration unless you’re passing the request over to an address that uses a port other than 80/443. For example, if you were running a NodeJS app that was running on a port such as 2365, and you wanted it to respond on a port 80 (i.e. without having to attach a port to the URL), then you would use ProxyPass.
For a standard domain setup, you really only need
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /path/to/domain01.com
ServerName domain01.com
ServerAlias www.domain01.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /path/to/domain01.com>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
So if that’s your base and you want domain02.com to point to /new in the same directory as your existing domain, you’d setup another server block and use something such as:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /path/to/domain01.com/new
ServerName domain02.com
ServerAlias www.domain02.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /path/to/domain01.com/new>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
Require all granted
</Directory>
</VirtualHost>
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.