Multiple websites on Apache 2.2

Discussion in 'Server Operation' started by wiewioor, Nov 5, 2009.

  1. wiewioor

    wiewioor New Member

    Hello All!

    I've been running one site on Apache in a LAN network without any problems. But now I must run two sites on the same server.

    Both sites are in separate folders on the server but only one is running right (the first one I've set up).

    The new site is not displaying in browsers over the LAN at all ("Conection with server has been reset/lost during site load' - my translation) and on the PC where the server is it only displays pure .html (It Works! for instance) but not .php .

    Maybe my VirtualHosts are not set up properly?
    First site (working):
    Code:
    <VirtualHost 192.168.5.222:80>
    	ServerAdmin [email protected]
    	
    	DocumentRoot /var/www/joomla/
    	<Directory />
    		Options FollowSymLinks
    		AllowOverride None
    	</Directory>
    	<Directory /var/www/joomla/>
    		Options Indexes FollowSymLinks MultiViews
    		AllowOverride None
    		Order allow,deny
    		allow from all
    	</Directory>
    
    	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    	<Directory "/usr/lib/cgi-bin">
    		AllowOverride None
    		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    		Order allow,deny
    		Allow from all
    	</Directory>
    
    	ErrorLog /var/log/apache2/error.log
    
    	# Possible values include: debug, info, notice, warn, error, crit,
    	# alert, emerg.
    	LogLevel warn
    
    	CustomLog /var/log/apache2/access.log combined
    
        Alias /doc/ "/usr/share/doc/"
        <Directory "/usr/share/doc/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order deny,allow
            Deny from all
            Allow from 127.0.0.0/255.0.0.0 ::1/128
        </Directory>
    
    </VirtualHost>
    Second site (not working)
    Code:
    <VirtualHost 192.168.5.222:81>
    	ServerAdmin [email protected]
    	DirectoryIndex index.html index.php
    	DocumentRoot /var/www/f16niesprawnosci/www/
    	<Directory />
    		Options FollowSymLinks
    		AllowOverride None
    		Order deny,allow
    		Deny from all
    	</Directory>
    	<Directory /var/www/f16niesprawnosci/>
    		Options Indexes FollowSymLinks
    		AllowOverride All
    		Order allow,deny
    		Allow from all
    	</Directory>
    
    	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    	<Directory "/usr/lib/cgi-bin">
    		AllowOverride None
    		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    		Order allow,deny
    		Allow from all
    	</Directory>
    
    	ErrorLog /var/log/apache2/error.log
    
    	# Possible values include: debug, info, notice, warn, error, crit,
    	# alert, emerg.
    	LogLevel debug
    
    	CustomLog /var/log/apache2/access.log combined
    
        Alias /doc/ "/usr/share/doc/"
        <Directory "/usr/share/doc/">
            Options Indexes MultiViews FollowSymLinks
            AllowOverride None
            Order deny,allow
            Deny from all
            Allow from 127.0.0.0/255.0.0.0 ::1/128
        </Directory>
    
    </VirtualHost>
    And my ports.conf
    Code:
    NameVirtualHost 192.168.5.222:80
    Listen 80
    
    NameVirtualHost 192.168.5.222:81
    Listen 81
    
    <IfModule mod_ssl.c>
        # SSL name based virtual hosts are not yet supported, therefore no
        # NameVirtualHost statement here
        Listen 443
    </IfModule>
    apache2.conf
    Code:
    #
    
    ServerRoot "/etc/apache2"
    
    LockFile /var/lock/apache2/accept.lock
    
    PidFile ${APACHE_PID_FILE}
    
    Timeout 300
    
    KeepAlive On
    
    MaxKeepAliveRequests 100
    
    KeepAliveTimeout 15
    
    <IfModule mpm_prefork_module>
        StartServers          5
        MinSpareServers       5
        MaxSpareServers      10
        MaxClients          150
        MaxRequestsPerChild   0
    </IfModule>
    
    <IfModule mpm_worker_module>
        StartServers          2
        MaxClients          150
        MinSpareThreads      25
        MaxSpareThreads      75 
        ThreadsPerChild      25
        MaxRequestsPerChild   0
    </IfModule>
    
    User ${APACHE_RUN_USER}
    Group ${APACHE_RUN_GROUP}
    
    AccessFileName .htaccess
    
    <Files ~ "^\.ht">
        Order allow,deny
        Deny from all
    </Files>
    
    DefaultType text/plain
    
    HostnameLookups Off
    
    ErrorLog /var/log/apache2/error.log
    
    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
    
    LogFormat "%v:%p %h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
    LogFormat "%{Referer}i -> %U" referer
    LogFormat "%{User-agent}i" agent
    
    CustomLog /var/log/apache2/other_vhosts_access.log vhost_combined
    
    # Include generic snippets of statements
    Include /etc/apache2/conf.d/
    
    # Include the virtual host configurations:
    Include /etc/apache2/sites-enabled/
    I've been going through log files but found nothing.
    Any ideas? More info to give You better picture?
    All help will be appreciated.
     
  2. dalitso

    dalitso New Member

    I have managed to run more than 1 apache site site before using either a IP-based hosts or Name-based virtual hosts http://httpd.apache.org/docs/1.3/vhosts/name-based.html

    IP-based hosts is a simpler one for you do not need to configure DNS as opposed to Name-based where you need DNS to resolve the name of the virtual server.

    With IP-based, you need to create a virtual network interface under eth0. You can name it eth0:1

    Unfortunately, I only know how to create a virtual interface using webmin. So I can help you if you are familiar with webmin or you are willing to try webmin. Webmin is easy to learn anyway.

    The only disadvantage of IP-based hosts that I have noticed is that you can only host one site at a time over the internet should you require to make your sites available on the internet. On your LAN its ok though because you can simply browse to the correct IP address.

    Having that in mind, I would say name based hosts is much better, it uses one IP address for all apache virtual hosts. Its also easy to setup using webmin and virtualmin. Virtualmin will automatically handle your DNS settings for you.

    I'm not sure if there are ways of overcoming that limitation in IP-based hosts, I'm just speaking from my knowledge and experience.

    Let me know when you are ready.
     

Share This Page