: Directing Domain to Hosting Directory I just purchased a domain on Dreamhost, let's say foo.com. I already have hosting, let's say at 123.4.56.789, and have setup a directory foo.com which is
I just purchased a domain on Dreamhost, let's say foo.com. I already have hosting, let's say at 123.4.56.789, and have setup a directory foo.com which is accessible at 123.4.56.789/foo.com/. I can set the DNS to point foo.com to that IP, but how do I route it to that folder once it's there? My hosting has a really bad cPanel that gives me almost no help. Can I use .htaccess, or something else? What's the best way to accomplish this?
Edit in response to comment(s):
It's VPS hosting, so I have access to http.conf and other system files. Also, yes it's Apache.
More posts by @Hamaas447
2 Comments
Sorted by latest first Latest Oldest Best
It has been a while since I have had to do this so I am a bit rusty. Please excuse any errors.
Here are some Apache documentation links:
httpd.apache.org/docs/current/sections.html httpd.apache.org/docs/current/vhosts/
Here are some other reousrces that seem to be good:
code.tutsplus.com/articles/apache-2-basic-configuration-on-unix-like-systems--net-26607 www.digitalocean.com/community/articles/how-to-configure-the-apache-web-server-on-an-ubuntu-or-debian-vps
It seems like the default installation of Apache needs less configuration since earlier versions. It may be safe to assume that it will answer to requests on the server IP address and port 80.
There are several configuration files to be considered. You can find them in /etc/apache2 or /etc/local/apache2, and the directories sites-available and sites-enabled under the apache2 directory.
The sites-available/default file is the default configuration for your server. If you create no other sites, then this is the only site that will be served. If you only have one site, it is okay to modify this file. Common modifications would be to change the <directory /var/www/> directive to change the directory and to change the AllowOverride from None to All to allow the use of .htaccess files. It would be fine to expect to deploy a website within the /var/www/ directory and it should work.
Otherwise, if you want to host more than one site, then in the /etc/apache2/sites-available directory, create a site configuration file often named using the following scheme domain-name.tld.conf. Here is an example configuration:
<VirtualHost *:80>
SuexecUserGroup "#<user id>" "#<group id>"
ServerName mydomain.com
ServerAlias mydomain.com DocumentRoot /home/mydomain.com/www
ErrorLog /home/mydomain.com/log/mydomain.com_error_log
CustomLog /home/mydomain.com/log/mydomain.com_access_log combined
AddHandler cgi-script .php
DirectoryIndex index.php index.html
<Directory /home/mydomain.com/www>
Options -Indexes +IncludesNOEXEC +FollowSymLinks
allow from all
AllowOverride All
</Directory>
</VirtualHost>
The <user id> and <group id> need to be replaced with the user id and group id of the user that owns the site. The home, www, and log, directories have to be created in the /home directory and chown, chgrp, and chmod may need to be used to change the ownership and permissions of these directories.
When you are done, create a symbolic link with the same name of the config file you created in the sites-enabled directory pointing to the configuration file you just created.
That should do it. If I missed a step or something needs to be explained better let me know. I will add more or change anything I need to help.
Thanks to closetnoc for leading me on the right path by mentioning sites-available.
I used these two articles to solve it:
wiki.gandi.net/en/hosting/using-linux/tutorials/ubuntu/virtualhosts twohlix.com/2011/05/setting-up-apache-virtual-hosts-on-centos/
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.