LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 06-27-2011, 09:28 AM   #1
qlands
Member
 
Registered: Sep 2010
Posts: 67

Rep: Reputation: 0
Unhappy How to configure Apache Virtual hosts is Slackware?


Hi,

I am trying to configure Apache to handle virtual hosts. For this I un-commented the line in httpd.conf that say

Quote:
Include /etc/httpd/extra/httpd-vhosts.conf
Then I included the following in httpd-vhosts.conf:

Quote:
<VirtualHost *:80>
<Directory /var/www/git.localhost/gitorious/public>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from All
</Directory>

DocumentRoot /var/www/git.localhost/gitorious/public
ServerName git.localhost

ErrorLog /var/www/git.localhost/log/error.log
CustomLog /var/www/git.localhost/log/access.log combined

# Gzip/Deflate
# http://fluxura.com/2006/5/19/apache-...strano-support
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Far future expires date
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresActive On
ExpiresDefault "access plus 1 year"
</FilesMatch>

# No Etags
FileETag None

RewriteEngine On

# Check for maintenance file and redirect all requests
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
</VirtualHost>
The problem is that when I use the browser to go to http://localhost/ I get the content of the virtual server. When I go to http://git.localhost/ the browser change it to http://www.git.localhost/ and I get:

Quote:
Server not found
What am I doing wrong?
 
Old 06-27-2011, 11:29 AM   #2
willysr
Senior Member
 
Registered: Jul 2004
Location: Jogja, Indonesia
Distribution: Slackware-Current
Posts: 4,661

Rep: Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784Reputation: 1784
Do you have that entry on your DNS or /etc/hosts file?
 
Old 06-27-2011, 01:57 PM   #3
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
I always leave the ServerName, DocumentRoot and log directives for the main server in httpd.conf.

Then I configure httpd-vhosts.conf something like this:

Code:
NameVirtualHost *:80

# main server
<VirtualHost *:80>
    ServerName server
    DocumentRoot /srv/httpd/htdocs
</VirtualHost>

# first virtual host
<VirtualHost *:80>
    ServerName books
    DocumentRoot /mnt/www/books
    <Directory />
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
Note that this is my local setup. There has to be a virtual host for the main server and one for each virtual host you define. In this case I add this lines to my hosts file:

Code:
127.0.0.1		server
127.0.0.1		books
So when I type http://server in a browser, apache displays the first virtual host, and when I use http://books, then it displays the second one.
 
Old 06-28-2011, 01:59 AM   #4
qlands
Member
 
Registered: Sep 2010
Posts: 67

Original Poster
Rep: Reputation: 0
Hi,

I follow your instructions and now when got to localhost it shows the main server with the default Apache page saying "It works!". But then when I got to git.localhost the browser say "waiting for git.localhost" and then falls to localhost and the default apache page.

I have the following in etc/hosts:
Quote:
127.0.0.1 localhost
127.0.0.1 git.localhost
172.26.17.70 darkstar darkstar.ilri.org
Then I have the following httpd-vhosts.conf:

Quote:
NameVirtualHost *:80

#Main server
<VirtualHost *:80>
<Directory "/srv/httpd/htdocs">
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>

ServerName localhost
DocumentRoot "/srv/httpd/htdocs"
ErrorLog /var/log/httpd/error_log
</VirtualHost>

#Git server
<VirtualHost *:80>
<Directory "/srv/httpd/git.localhost/gitorious/public">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from All
</Directory>

DocumentRoot "/srv/httpd/git.localhost/gitorious/public"
ServerName git.localhost

ErrorLog /var/www/git.localhost/log/error.log
CustomLog /var/www/git.localhost/log/access.log combined

# Gzip/Deflate
# http://fluxura.com/2006/5/19/apache-...strano-support
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

# Far future expires date
<FilesMatch "\.(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
ExpiresActive On
ExpiresDefault "access plus 1 year"
</FilesMatch>

# No Etags
FileETag None

RewriteEngine On

# Check for maintenance file and redirect all requests
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
</VirtualHost>
Might it be a waiting time for the transport module to run the rails application?

Thanks in advance.
 
Old 06-28-2011, 12:50 PM   #5
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
Try using <Directory /> instead of <Directory "/srv/httpd/git.localhost/gitorious/public">. And check your logs to see if there's any indication of what's happening.

You can also try running

Code:
httpd -S
to check your virtual host configuration.

Last edited by Diantre; 06-28-2011 at 12:54 PM. Reason: Just remembered "httpd -S"
 
Old 06-29-2011, 02:28 AM   #6
qlands
Member
 
Registered: Sep 2010
Posts: 67

Original Poster
Rep: Reputation: 0
Hi,

Thanks for your support. I removed the "" from the configuration file. Here is the output of httpd -S:

Quote:
httpd: Could not reliably determine the server's fully qualified domain name, using 172.26.17.70 for ServerName
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server localhost (/etc/httpd/extra/httpd-vhosts.conf:21)
port 80 namevhost localhost (/etc/httpd/extra/httpd-vhosts.conf:21)
port 80 namevhost git.localhost (/etc/httpd/extra/httpd-vhosts.conf:58)
Syntax OK
This is the error log:

Quote:
[Wed Jun 29 10:13:10 2011] [notice] Digest: generating secret for digest authentication ...
[Wed Jun 29 10:13:10 2011] [notice] Digest: done
[Wed Jun 29 10:13:11 2011] [notice] Apache/2.2.19 (Unix) DAV/2 Phusion_Passenger/3.0.7 configured -- resuming normal op
erations
I though the problem was the I did not have the AddHandler cgi-script .cgi or the Options ExecCGI or that I did not had ServerName localhost (to remove the "qualified domain name" error) in httpd.conf. But even with those options I get the same problem.

Thanks in advance.

Last edited by qlands; 06-29-2011 at 02:37 AM.
 
Old 06-29-2011, 04:12 AM   #7
Diantre
Member
 
Registered: Jun 2011
Distribution: Slackware
Posts: 515

Rep: Reputation: 234Reputation: 234Reputation: 234
Quote:
Originally Posted by qlands View Post
This is the error log:
No errors there. Look for entries with the word [error]. This is a fragment of my error log, notice the missing files:

Code:
Wed Jun 29 02:35:31 2011] [error] [client 127.0.0.1] File does not exist: /srv/httpd/htdocs/favicon.ico
[Wed Jun 29 02:35:37 2011] [error] [client 127.0.0.1] File does not exist: /mnt/www/books/favicon.ico
[Wed Jun 29 02:37:52 2011] [error] [client 127.0.0.1] File does not exist: /mnt/www/books/foo.html
If there are no errors, then great.

Quote:
Originally Posted by qlands View Post
I though the problem was the I did not have the AddHandler cgi-script .cgi or the Options ExecCGI or that I did not had ServerName localhost (to remove the "qualified domain name" error) in httpd.conf. But even with those options I get the same problem.
As I mentioned above, I use apache as my local webserver, only for my personal use, and I've never seen that "domain name" error. Take a look at my files:

hosts
Code:
127.0.0.1		localhost
127.0.0.1		argus
127.0.0.1		books

httpd.conf

Code:
Listen 127.0.0.1:80
ServerName argus:80
DocumentRoot "/srv/httpd/htdocs"
Those are the only entries modified, the rest are at default values.

httpd-vhosts.conf
Code:
NameVirtualHost *:80

<VirtualHost *:80>
    ServerName argus
    DocumentRoot /srv/httpd/htdocs
</VirtualHost>

<VirtualHost *:80>
    ServerName books
    DocumentRoot /mnt/www/books
</VirtualHost>
That's my very minimal setup for virtual hosts. It works for me. Perhaps if you try with a minimum configuration first and then start adding more configuration entries as you test the basics?

Take a look at apache's docs for virtual hosts: http://httpd.apache.org/docs/2.2/vhosts/

As a suggestion, try using [code][/code] tags to enclose your texts and examples, it keeps the formatting of the text intact.

Anyway, keep trying and good luck.
 
Old 03-21-2015, 04:56 PM   #8
akalinin
Member
 
Registered: Apr 2014
Location: Michigan
Distribution: slackware
Posts: 31

Rep: Reputation: Disabled
Cool

Quote:
Originally Posted by Diantre View Post
I always leave the ServerName, DocumentRoot and log directives for the main server in httpd.conf.

Then I configure httpd-vhosts.conf something like this:

Code:
NameVirtualHost *:80

# main server
<VirtualHost *:80>
    ServerName server
    DocumentRoot /srv/httpd/htdocs
</VirtualHost>

# first virtual host
<VirtualHost *:80>
    ServerName books
    DocumentRoot /mnt/www/books
    <Directory />
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>
Note that this is my local setup. There has to be a virtual host for the main server and one for each virtual host you define. In this case I add this lines to my hosts file:

Code:
127.0.0.1		server
127.0.0.1		books
So when I type http://server in a browser, apache displays the first virtual host, and when I use http://books, then it displays the second one.
Thank you for posting this. I thought apache on my Slackware setup was going flaky until I tried your way. Thanks, this really helped!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
APACHE - Virtual Hosts luca2 Linux - Networking 3 12-27-2005 07:32 PM
Configure virtual hosts in Apache 1.3.26 @ngelot Linux - Software 3 03-10-2005 02:13 AM
apache virtual hosts smaida Linux - Software 3 06-20-2004 04:28 PM
apache virtual hosts Red Squirrel Linux - Software 4 06-20-2004 09:05 AM
Apache Virtual Hosts quozt Linux - General 3 10-15-2003 09:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 12:04 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration