LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Virtual Hosts Setup (http://www.linuxquestions.org/questions/linux-server-73/virtual-hosts-setup-784539/)

LazerPhreak 01-25-2010 02:34 AM

Virtual Hosts Setup
 
Hello there! I asked this in a previous thread, but asked in a completely wrong way. After some research I found a better way to ask this. I need to set up virtual hosts I think. This is what I need.

I have a server set up with apache2 to host my website in /var/www/ (e.g. www.domain.com). My friend wants me to host her site as well. So I put her files in /var/www/rosie. What i want to happen is she go to www.domain.com/rosie/ to access her site. How can I set this up? Please be detailed because after much research I'm still confused.

Thanks!

EricTRA 01-25-2010 02:57 AM

Hello,

Have a look at http://www.howtoforge.com/. They have a lot of easy to follow step by step guides for what you're looking for.

Kind regards,

Eric

r3sistance 01-25-2010 04:17 AM

Wait....

You have a website www.domain.com what's document root is /var/www/ and you want your friend's site to be www.domain.com/rosie so you place her documents in /var/www/rosie/.

This shouldn't require any additional configuration what so ever. If it's not working are you sure you got the correct documentroot, that the documentroot is not really /var/www/html/?

LazerPhreak 01-25-2010 04:48 AM

I'm Positive. This is why I'm SO FRICKIN CONFUSED!!!!! help?!?!?!?! Before I pull out all my hair?

zhjim 01-25-2010 05:40 AM

Quote:

Originally Posted by LazerPhreak (Post 3839577)
Before I pull out all my hair?

Stop pulling hair. Push us the config your using for the apache.
/etc/apache2/apache.conf

Also give us a listing of /etc/apache2

LazerPhreak 01-25-2010 04:52 PM

Sorry for the aggravated response. That was at 6 am after near 13 hours straight working on it with failure. After a nights rest I'm ready to tackle it fresh.

Heres my directory listing of /etc/apache2:

Code:

-rw-r--r-- 1 root root  8135 2010-01-25 04:31 apache2.conf
-rw-r--r-- 1 root root  8097 2010-01-18 21:35 apache2.conf.bak
drwxr-xr-x 2 root root  4096 2010-01-25 04:13 conf.d
-rw-r--r-- 1 root root  551 2009-11-12 16:48 envvars
-rw-r--r-- 1 root root    0 2010-01-18 21:33 httpd.conf
-rw-r--r-- 1 root root 31063 2009-11-12 16:48 magic
drwxr-xr-x 2 root root  4096 2010-01-18 21:33 mods-available
drwxr-xr-x 2 root root  4096 2010-01-18 21:33 mods-enabled
-rw-r--r-- 1 root root  481 2010-01-25 04:43 ports.conf
drwxr-xr-x 2 root root  4096 2010-01-25 04:38 sites-available
drwxr-xr-x 2 root root  4096 2010-01-25 04:40 sites-enabled

This is apache2.conf
Code:

#
# Based upon the NCSA server configuration files originally by Rob McCool.
#
# This is the main Apache server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See http://httpd.apache.org/docs/2.2/ for detailed information about
# the directives.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.
#
# The configuration directives are grouped into three basic sections:
#  1. Directives that control the operation of the Apache server process as a
#    whole (the 'global environment').
#  2. Directives that define the parameters of the 'main' or 'default' server,
#    which responds to requests that aren't handled by a virtual host.
#    These directives also provide default values for the settings
#    of all virtual hosts.
#  3. Settings for virtual hosts, which allow Web requests to be sent to
#    different IP addresses or hostnames and have them handled by the
#    same Apache server process.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "/var/log/apache2/foo.l$
# with ServerRoot set to "" will be interpreted by the
# server as "//var/log/apache2/foo.log".
#
ServerTokens Prod
ServerSignature Off
### Section 1: Global Environment
#
# The directives in this section affect the overall operation of Apache,
# such as the number of concurrent requests it can handle or where it
# can find its configuration files.
#

#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# NOTE!  If you intend to place this on an NFS (or otherwise network)
# mounted filesystem then please read the LockFile documentation (available
# at <URL:http://httpd.apache.org/docs-2.1/mod/mpm_common.html#lockfile>);
# you will save yourself a lot of trouble.
#
# Do NOT add a slash at the end of the directory path.
#
ServerRoot "/etc/apache2"

#
# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
#
#
#<IfModule !mpm_winnt.c>
#<IfModule !mpm_netware.c>
LockFile /var/lock/apache2/accept.lock
#</IfModule>
#</IfModule>

#
# PidFile: The file in which the server should record its process
# identification number when it starts.
# This needs to be set in /etc/apache2/envvars
#
PidFile ${APACHE_PID_FILE}

#
# Timeout: The number of seconds before receives and sends time out.
#
Timeout 300
#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 15
##
## Server-Pool Size Regulation (MPM specific)
##

# prefork MPM
# StartServers: number of server processes to start
# MinSpareServers: minimum number of server processes which are kept spare
# MaxSpareServers: maximum number of server processes which are kept spare
# MaxClients: maximum number of server processes allowed to start
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers      5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild  0
</IfModule>

# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_worker_module>
    StartServers          2
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxClients          150
    MaxRequestsPerChild  0
</IfModule>

# event MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_event_module>
    StartServers          2
    MaxClients          150
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadLimit          64
    ThreadsPerChild      25
    MaxRequestsPerChild  0
</IfModule>

# These need to be set in /etc/apache2/envvars
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}

#
# AccessFileName: The name of the file to look for in each directory
# for additional configuration directives.  See also the AllowOverride
# directive.
#

AccessFileName .htaccess

#
# The following lines prevent .htaccess and .htpasswd files from being
# viewed by Web clients.
#
<Files ~ "^\.ht">
    Order allow,deny
    Deny from all
</Files>

#
# DefaultType is the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain


#
# HostnameLookups: Log the names of clients or just their IP addresses
# e.g., www.apache.org (on) or 204.62.129.132 (off).
# The default is off because it'd be overall better for the net if people

# had to knowingly turn this feature on, since enabling it means that
# each client request will result in AT LEAST one lookup request to the
# nameserver.
#
HostnameLookups Off

# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog /var/log/apache2/error.log

#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn

# Include module configuration:
Include /etc/apache2/mods-enabled/*.load
Include /etc/apache2/mods-enabled/*.conf

# Include all the user configurations:
Include /etc/apache2/httpd.conf

# Include ports listing
Include /etc/apache2/ports.conf

#
# The following directives define some format nicknames for use with
# a CustomLog directive (see below).
# If you are behind a reverse proxy, you might want to change %h into %{X-For$
#
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"$
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" comb$
LogFormat "%h %l %u %t \"%r\" %>s %O" common
LogFormat "%{Referer}i -> %U" referer
LogFormat "%{User-agent}i" agent

#
# Define an access log for VirtualHosts that don't define their own logfile
CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined


# Include of directories ignores editors' and dpkg's backup files,
# see README.Debian for details.

# Include generic snippets of statements
Include /etc/apache2/conf.d/

# Include the virtual host configurations:
Include /etc/apache2/sites-enabled/

Some further details that might help:
the destination is http://www.tweakercat.tk (linked to http://75.87.80.77)
So technically http://www.rosebuddweddings.tk (linked to the same) should take you to a white screen that says "This is a test" (index.html) from what I understand

my /var/www:
/var/www
/var/www/default
/var/www/default/index.html

/var/www
/var/www/rosebuddweddings
/var/www/rosebuddweddings/index.html

This is my sites-available setup:

file default:
Code:

NameVirtualHost *
<VirtualHost *>
ServerName www.tweakercat.tk
ServerAlias tweakercat.tk
DocumentRoot /var/www/tweakercat
</VirtualHost>

file www.rosebuddweddings.tk
Code:

<VirtualHost *>
ServerName www.rosebuddweddings.tk
ServerAlias rosebuddweddings.tk
DocumentRoot /var/www/rosebuddweddings
</VirtualHost>


r3sistance 01-25-2010 05:26 PM

From what I can see, you have two different domains, tweakercat.tk and rosebuddweddings.tk both of which are pointing to different DocumentRoots. tweakercat should host anything in /var/www/tweakercat and rosebuddweddings /var/www/rosebuddweddings. From here what is it you are trying to accomplish?

LazerPhreak 01-25-2010 05:33 PM

I'm Sorry, I'm going everywhere at once. What I wish to happen is www.tweakercat.tk to point to /var/www/default and www.rosebuddweddings.tk point to /var/www/rosebuddweddings. It seems to me everything on this side is set up properly, but when i go to either domain it sends me to /var/www/default. Maybe I'm forwarding the domains incorrectly? I have both the domains pointing to http://75.87.80.77 . from what I Understand my server should take care of sending the person o the right place. Am i thinking about this all wrong? If so, to what address should I forward the domain? Another thought: www.tk allows me to either forward a domain, use their free dns service, or use a custom dns service. I've just been forwarding the domain. Maybe the problem lies herein? Sorry, but it's kind of hard to ask a logical question, without having a clear problem. Thanks for being patient.

LazerPhreak 01-25-2010 05:59 PM

Holy shit I made an advancement. I changed my domain forwarding from domain forward to using their custom DNS for both domains. I set the A record on both to their specific domains and the ip to 75.87.80.77. IT WORKS!!!! Sorry for the long process to get here, but as I said, lack of clear problem = lack of clear question. Thanks for all your help and support!

r3sistance 01-25-2010 06:23 PM

If I am to understand this right, you were just using forwarding what just does a call on the IP and doesn't actually pass the domain information to the server, thus the server just passed back it's default and not the domains you intended to see? Now the server seems the domains from the requests and redirects people correctly?

LazerPhreak 01-25-2010 06:29 PM

That is correct. To be honest, I have no experience with linux servers, and only 6 months with linux at all. This whole thing has been a learn as I go, and indeed has taught me alot. Thank god I dont mind learning at the cost of looking like an idiot occasionally :) lol.

zhjim 01-26-2010 07:00 AM

Quote:

Originally Posted by LazerPhreak (Post 3840338)
That is correct. To be honest, I have no experience with linux servers, and only 6 months with linux at all. This whole thing has been a learn as I go, and indeed has taught me alot. Thank god I dont mind learning at the cost of looking like an idiot occasionally :) lol.

Doing god so far. And idiot would not provide the sites-available config when not asked for. And as you solved your problem on your own your going good :hattip:

Sometimes just a question from another person gets one self to the right point.

Cheers Zhjim


All times are GMT -5. The time now is 09:20 PM.