Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Porting WAMP to LAMP 2

Status
Not open for further replies.

ChrisRChamberlain

Programmer
Mar 23, 2000
3,392
GB
Hi all

The following code is extracted from WAMP on Windows, the file being C:/wamp/bin/apache/Apache2.2.10/conf/httpd.conf
Code:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

The following code is also extracted from WAMP on Windows, the file being C:/wamp/bin/apache/Apache2.2.10/conf/extra/httpd-vhosts.conf, IOW, the 'Included' file.
Code:
<VirtualHost *:80>
[tab]ServerName [URL unfurl="true"]www.mysite1.com[/URL]
[tab]ServerAlias mysite1.com mysite1
[tab]DocumentRoot C:/wamp/[URL unfurl="true"]www/mysite1[/URL]
[tab]ErrorLog C:/wamp/[URL unfurl="true"]www/mysite1/logs/error.log[/URL]
[tab]CustomLog C:/wamp/[URL unfurl="true"]www/mysite1/logs/access.log[/URL] common
</VirtualHost> 

<VirtualHost *:80> 
[tab]ServerName [URL unfurl="true"]www.mysite2.com[/URL]
[tab]ServerAlias mysite2.com mysite2
[tab]DocumentRoot C:/wamp/[URL unfurl="true"]www/mysite2[/URL]
[tab]ErrorLog C:/wamp/[URL unfurl="true"]www/mysite2/logs/error.log[/URL]
[tab]CustomLog C:/wamp/[URL unfurl="true"]www/mysite2/logs/access.log[/URL] common
</VirtualHost> 

<VirtualHost *:80> 
[tab]ServerName [URL unfurl="true"]www.mysite3.com[/URL]
[tab]ServerAlias mysite3.com mysite3
[tab]DocumentRoot C:/wamp/[URL unfurl="true"]www/mysite3[/URL]
[tab]ErrorLog C:/wamp/[URL unfurl="true"]www/mysite3/logs/error.log[/URL]
[tab]CustomLog C:/wamp/[URL unfurl="true"]www/mysite3/logs/access.log[/URL] common
</VirtualHost>

The code allows n websites to exist in their own folders below C:/wamp/www/ on Windows.

In Ubuntu Server 9.04, there exists a file /etc/apache2/httpd.conf, which is empty by default.

The file /etc/apache2/apache2.conf has an include directive to the empty file, /etc/apache2/httpd.conf.

So does the WAMP code from C:/wamp/bin/apache/Apache2.2.10/conf/extra/httpd-vhosts.conf go in the empty file, /etc/apache2/httpd.conf, or perhaps in an included file in /etc/apache2/sites-available?

TIA

Chris

FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 
It should work fine if you put it in /etc/apache2/sites-available. If it doesn't, try adding this file name to the Include directive. As a matter of fact, you can name the file with your vhost containers anything you want as long as it is pointed to by the Include directive. Some distros have many config files so they use a wild card such as httpd/conf.d/*.conf. This way, anything in the /conf.d directory with a .conf extension will be Included when the main config file is read.
 
RhythmAce

Thank you for your response and suggestion, which will be tried shortly.

Puzzled as to why there is an empty file /etc/apache2/httpd.conf, and therefore its purpose?

FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 
I agree, putting the virtual host directives in the sites-available (or sites-enabled) will work fine.

The httpd.conf file can be used too, but I don't think that it is the common place to do this. My understanding is that the httpd.conf file is where you want to put global declarations that will modify or affect the behavior of all of the hosts. For what its worth, mine is blank too.

 
In real life httpd.conf is the default configuration file that httpd (apache) looks for when it starts up. This can be changed by pointing to a different config file on the command line or in a start up script. This seems to be what Ubuntu has done.
 
Added
Code:
Include /etc/apache2/sites-enabled/httpd-vhosts.conf
to /etc/apache2/apache2.conf

If the httpd-vhosts.conf is empty, the default index.html is found over the internet via
Populating httpd-vhosts.conf with the barebones code
Code:
<VirtualHost *:80>
    ServerName [URL unfurl="true"]www.mysite1.com[/URL]
    ServerAlias mysite1.com mysite1
    DocumentRoot "var/[URL unfurl="true"]www/mysite1"[/URL]
</VirtualHost>

<VirtualHost *:80>
    ServerName [URL unfurl="true"]www.mysite2.com[/URL]
    ServerAlias mysite2.com mysite2
    DocumentRoot "var/[URL unfurl="true"]www/mysite2"[/URL]
</VirtualHost>
gives a page load error for either website.

What might be missing, please?

FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 

Followed instructions in the article in the previous post, and when trying
Code:
sudo /etc/init.d/apache2 reload
get this error message
Could not reliably determine the server's fully qualified domain name, using 127.0.11 for ServerName
followed by
VirtualHost *:80 -- mixing * ports and non* - ports is not supported, proceeding with undefined results
followed by
NameVirtualHost *:80 has no VirtualHosts

FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 
The sever name and server alias appear to be wrong.
The server name should be mysite1.com or mysite2.com. The server alias should be or The server alias allows www. to be pre-pended as a canonical name for the sites.

Otherwise, except for being a bit minimalistic, the host declarations look correct to me.

Also make sure that you have an index.html in the location pointed to by the document root, i.e. in that directory.
 
Noway2

Thanks for your comments
Code:
<VirtualHost *>
        ServerAdmin webmaster@example.com
        ServerName  [URL unfurl="true"]www.example.com[/URL]
        ServerAlias example.com

        # Indexes + Directory Root.
        DirectoryIndex index.html
        DocumentRoot /home/[URL unfurl="true"]www/www.example.com/htdocs/[/URL]

        # CGI Directory
        ScriptAlias /cgi-bin/ /home/[URL unfurl="true"]www/www.example.com/cgi-bin/[/URL]
        <Location /cgi-bin>
                Options +ExecCGI
        </Location>


        # Logfiles
        ErrorLog  /home/[URL unfurl="true"]www/www.example.com/logs/error.log[/URL]
        CustomLog /home/[URL unfurl="true"]www/www.example.com/logs/access.log[/URL] combined
</VirtualHost>
That's the code from the article that was modified to suit, which is at odds with your suggestion.

The good news is, apart from the reported errors when attempting
Code:
sudo /etc/init.d/apache2 reload
it works. [smile]


FAQ184-2483​
Chris [pc2]
PDFcommander.com
motrac.co.uk
 
Ok, now I get it. You have stumbled on to one of the most important things to keep in mind - and one that I am so used to that I didn't think about.

*** Whenever you make a change to the configuration files you MUST restart apache to get it to take affect. ***

Using the reload command is considered to be the brute force way of doing it. A more gentle method is to use /etc/init.d/apache2 force-reload.

Glad that is working for you in any case.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top