where should i define my virtual hosts? conf/httpd.conf or conf.d/user.conf - apache

i have seen more than one tutorial that i have been using trying to get suPHP running on my centos 6.5 box.
first off, standard lamp virtual hosts tutorials always add virtual hosts into /etc/httpd/conf/httpd.conf however, a different tutorial that i was looking at (http://invision-web.net/web/install-configure-apache-php-suphp-virtual-hosts-centos/) puts the virtual hosts into /etc/httpd/conf.d/user.conf
is there a right or wrong way to do this? is one better than another?
also, i understand that httpd.conf is the main apache config file, but what exactly is the user.conf file?

The virtual host configurations should normally go in main Apache configuration file httpd.conf. In the article link you posted above the configuration
creates a virtual host for user invision on domains
n1.invision-web.net and www.invision-web.net
. Unless you have multiple site users which require configuration at a per-user level, this is not necessary. The article does not make this clear at all.
user.conf is for per-user configuration. For example, where sites have multiple users (e.g. access to http://www.mysite.com/~pedro (delivering content from the home directory or sub-directory of user pedro) can be configured in the users.conf file. More details in Apache docs.

Related

Multiple Apache Virtual Host Files with one Document root?

I've set up a single VPS running Apache, with an application installed in /var/www/html/. I have a domain [example-1.com] to the server IP.
I'd also like the same application to be served on [example-2.com]. Something similar to creating an 'Alias' domain.
Is it possible to have two Virtual Host Files configured at one document root?
Yes, no problem. The document roots can point wherever you want them to. If the configuration of the second virtualhost is the same, you could also use the ServerAlias directive.

Apache Virtual Host Configuration

I am using Apache 2.4 on Raspbian and I want to create a virtual host to serve files on my external hard drive on my website. I searched it on the internet and found many guides to make it but this seemed the simplest: http://www.thegeekstuff.com/2011/07/apache-virtual-host/
However, the files "httpd.conf" and "httpd-vhost.conf" which are mentioned in the guide do not exist in my system (I searched the whole system). Therefore I can't configure those files and hence, my virtual host. When I was searching the information about location of https.conf on the internet, I learnt that it does not exist anymore. However, I couldn't find the information about what to do in this situation.
I have been searching it online for hours but I couldn't find the answer. I do not know how to set up my virtual host. I would greatly appreciate your help.
Debian derivatives keep their config files in /etc/apache2/
To create a new virtual host, create a new config file in /etc/apache2/sites-available/. You can use 000-default.conf as a template (but you'll need to add ServerName directives as you'll be creating a specific default host rather than the fallback).
Then run a2ensite YOUR-CONFIG.conf to turn it on, and service apache2 restart to restart the HTTP server so it picks up the new configuration.

WAMP localhost and phpmyadmin setup

I have inherited a WAMP setup, but needed my http://localhost to point to a different directory "C:/Users/[user.name]/htdocs" due to many dependencies.
I made the following changes in httpd.conf
DocumentRoot "C:/Users/[user.name]/htdocs"
<Directory "C:/Users/[user.name]/htdocs">
where the original path was "c:/wamp/www/"
Now the WAMP default path for phpMyAdmin http://localhost/phpMyAdmin is not working anymore.
Is it possible to fix that via either C:\wamp\alias\phpmyadmin.conf or httpd-vhosts.conf somehow?
Can I suggest a better solution to your requirement to have a site running that does not live in the WAMPServer default location i.e. \wamp\www or \wamp\www\somefolder
If you revert all your httpd.conf changes to the out of the box state and then create a Virtual Host to run the site you have located in your \user.... folder.
Virtual Hosts are a standard Apache feature that allows you to run may sites from a single instance of Apache, a bit like a shared hosting package setup.
You would then have the benefits of the WAMPServer homepage running on localhost and all the other alias's tools as well.
You can then run your site using a nice url for example sitename.dev and the virtual host definition also allows you to setup any site specific requirements without effecting any other site you may want to run.
There is a HowTo Setup Virtual Hosts here on SO

Apache URI path recognition / mapping?

I have a website for all intents and purposes is called.
www.foobar.com
Which in my server path is /var/www/
I tried to create a new folder in /var/ called "analytics", with the hope that if I typed www.foobar.com/analytics I could access that folder.
However that does not work because it is actually looking for /var/www/analytics instead of /var/analytics
So how can I have multiple directories mapped to a URI?
For phpmyadmin I can access www.foobar.com/phpmyadmin with the phpadmin folder is in a completely different directory. So it must be possible.
However I tried googling but could not find any answers so I guess I do not have the right description of what this functionality is on Apache webservers.
Any help would be appreciated.
You have to create virtual directories in Apache.
If you are using Apache2, then can you go to the directories
/etc/apache2/sites-available and /etc/apache2/sites-enabled.
You have probably only the default virtual directory enabled.
You can make a copy of a virtual directory in the map /sites-available.
A virtual directory starts with specifying what the root directory is.
Then can you use the commands a2ensite and a2dissite in order to enable or disable the virtual directories respectively.
After a change in enabled/disabled virtual directories do you need to restart/reload the apache server.
If you use .htaccess file, do not forget to set AllowAccess (in the tag Directory) to at least FileInfo or .htaccess will be ignored.
If you want to make those directories different hosts, then can you make aliases in /etc/hosts.
On my home computer have I aliases for the ip addresses 27.0.0.1 and 27.0.1.1.
That gives me the possibility to have two different sites at the same time.

Host multiple domains with apache

I'm trying to set up an ubuntu server to act as a dns server and host a simple webpage, some git repos, and some software for issue tracking, code review, and the like. I settled on Phabricator as the issue tracking/ code review software of choice, since it seemed to be a good all-in-one solution. I've got my server hosting my webpage and git repos, so that part seems to be working ok. Now here's the issue I've run into (from Phabricator configuration instructions):
If you haven't already, set up a domain name to point to the host you're installing on. You can either install Phabricator on a subdomain (like phabricator.example.com) or an entire domain, but you can not install it in some subdirectory of an existing website
I have no idea where to even begin setting up another domain name on my server. How do I set up a second domain name for Phabricator to use?
I see a lot of guides online that say to modify resolv.conf to add a dns entry, however mine looks like this:
Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.1.1
and I'm not sure what I should change to get dns entries to show up here.
I'm assuming you have only one IP address, which means you should be using virtual name-based hosting. There are a number of tutorials for doing this, but in short:
Create a virtual host configuration file in:
/etc/apache2/sites-available
For example:
nano /etc/apache2/sites-available/phabricator
Run:
a2ensite phabricator (in this example, but use the configuration file name you used above)
apache2ctl restart
The configuration file (which can be named whatever you'd like) needs to contain a number of items. A simple example would look like this:
<VirtualHost *:80>
DocumentRoot /www/example1
ServerName www.example.com
</VirtualHost>
DocumentRoot is the full path to the root of your site, usually where index.html, index.php, or the like is located. The default is /var/www. You could put somethig like /home/phabricator or /var/www/phabricator, but make sure you install Phabricator in the directory you specify.
ServerName is the full FQDN of your site, such as "www.google.com" or "phabricator.yourdomain.com" or even "phabricator.local". Basically it's the same value as you have set in your DNS for your A record, or in your /etc/hosts file. If you don't know about /etc/hosts, then disregard that part.
You'll probably need a few more directives in your configuration file, but you can find what's available on Google. I would suggest following some tutorials to get your configuraiton right.
But overall, you just need to create a virtual host config file, enable it, then restart the server, which is what the above instructions do. Apache will respond to the web request based on the site you put into your address bar.
P.S. Just noticed your DNS part of the question. Do you have DNS set up publicly to point a domain (example.com) or subdomain (something.example.com) to your server's IP address?