Jump to content

Can't do Apache2 virtual hosts


SK_pt
 Share

Recommended Posts

Hi,

 

I'm a new linux user, I am using webmin to configure my Apache 2 web server.

 

I use Mandrake 10 Official.

 

I want to have this many websites in my workstation:

per example I have

/home/name/www/websiteA

/home/name/www/websiteB

/home/name/www/websiteC

 

and I want to access each one of them respectively by

http : / / localhost:81

http : / / localhost:82

http : / / localhost:83

 

In webmin I create

 

I then restart Apache2, and when trying to http://localhost:81, http://localhost:82 or http://localhost:83 it goes to this website http://localhost.be

 

or if I try with IP

http : / / 127.0.0.1:81, it says I can't connect.

 

In webmin I put

Address: Any

Port: 81

Document Root: /home/name/www/websiteA

Server Name: Default

 

then I do Save and restart Apache.... doesn't work, when I go to localhost:81 or 127.0.0.1:81 it doesnt' do a thing and I wanted it to go to /home/name/www/websiteA

 

any help is appreciatted

SK

Link to comment
Share on other sites

i've had luck getting virtual hosts to work using the hostname rather than the ports. i don't think i used webmin when i set it up, but edited the /etc/httpd/conf/httpd.conf by hand. (not sure that webmin is a problem, but i KNOW it can be done by hand and it isn't all that tough)

 

I would look at Apache's VirtualHost Examples to get an idea of what can be done.

 

According to the info on Running Different Sites on Different Ports, your httpd.conf should have something that looks like this:

 

Server configuration

Listen 80
Listen 8080

NameVirtualHost 172.20.30.40:80
NameVirtualHost 172.20.30.40:8080

<VirtualHost 172.20.30.40:80>
ServerName www.example1.com
DocumentRoot /www/domain-80
</VirtualHost>

<VirtualHost 172.20.30.40:8080>
ServerName www.example1.com
DocumentRoot /www/domain-8080
</VirtualHost>

<VirtualHost 172.20.30.40:80>
ServerName www.example2.org
DocumentRoot /www/otherdomain-80
</VirtualHost>

<VirtualHost 172.20.30.40:8080>
ServerName www.example2.org
DocumentRoot /www/otherdomain-8080
</VirtualHost>

 

Another thing to check: have you opened those other ports in your firewall? (Configure your computer -> security -> firewall)

Link to comment
Share on other sites

Im working in my own workstation, I presume firewall only checks outside accesses, as I also don't haev any software fierwall activated, and everything is done in 127.0.0.1

 

in the example you sent me what would I put instead of www.example1.com? since i dont' have DNS, domains whatever, I'm just a simple worker doing stuff pre being a domain, and all in my humble workstation?

 

I presume in my case I would do something like this, the onyl problem is about the ServerName

 

<VirtualHost 127.0.0.1:81>

ServerName ????

DocumentRoot /home/name/www/websiteA

</VirtualHost>

 

<VirtualHost 127.0.0.1:82>

ServerName ?????

DocumentRoot /home/name/www/websiteB

</VirtualHost>

 

another thing is that my Mandrake installed i presume 2 apaches so it's hard to understand whtich httpd.conf I need to work on.

Link to comment
Share on other sites

Guest emetib

for the servername, i would do 81.127.0.0.1 and so on. that's how i have my vhosts set up. i don't use the ports as you do, but the naming should be the same.

 

one thing though, have you adjusted your conf files to tell apache to listen to the other ports also? that could be it right there.

Link to comment
Share on other sites

hi,

 

still seems not to work I did in httpd.conf file

 

<IfDefine>

Port 81

Listen 81

</IfDefine>

 

in the end I putted the virtual hhost config

 

<VirtualHost localhost:81>

ServerName localhost

DocumentRoot "/home/user/wwwprj/websiteA"

</VirtualHost>

 

then in command line i did

apachectl restart

 

after that I went to my browser but after putting localhost:81 it didn't worked

 

is there something missing?

 

I put my http configuration here for u to see

### Main Configuration Section

### You really shouldn't change these settings unless you're a guru

###

ServerType standalone

ServerRoot /etc/httpd

#ServerName localhost

#LockFile /etc/httpd/httpd.lock

PidFile /var/run/httpd.pid

ScoreBoardFile /etc/httpd/httpd.scoreboard

ErrorLog logs/error_log

LogLevel warn

ResourceConfig /dev/null

AccessConfig /dev/null

DocumentRoot /var/www/html

 

 

### Dynamic Shared Object (DSO) Support

###

###

#LoadModule mmap_static_module modules/mod_mmap_static.so

LoadModule env_module modules/mod_env.so

LoadModule config_log_module modules/mod_log_config.so

LoadModule agent_log_module modules/mod_log_agent.so

LoadModule referer_log_module modules/mod_log_referer.so

#LoadModule mime_magic_module modules/mod_mime_magic.so

LoadModule mime_module modules/mod_mime.so

LoadModule negotiation_module modules/mod_negotiation.so

LoadModule status_module modules/mod_status.so

LoadModule info_module modules/mod_info.so

LoadModule includes_module modules/mod_include.so

LoadModule autoindex_module modules/mod_autoindex.so

LoadModule dir_module modules/mod_dir.so

LoadModule cgi_module modules/mod_cgi.so

LoadModule asis_module modules/mod_asis.so

LoadModule imap_module modules/mod_imap.so

LoadModule action_module modules/mod_actions.so

#LoadModule speling_module modules/mod_speling.so

LoadModule userdir_module modules/mod_userdir.so

LoadModule proxy_module modules/libproxy.so

LoadModule alias_module modules/mod_alias.so

LoadModule rewrite_module modules/mod_rewrite.so

LoadModule access_module modules/mod_access.so

LoadModule auth_module modules/mod_auth.so

LoadModule anon_auth_module modules/mod_auth_anon.so

#LoadModule dbm_auth_module modules/mod_auth_dbm.so

#LoadModule db_auth_module modules/mod_auth_db.so

LoadModule digest_module modules/mod_digest.so

#LoadModule cern_meta_module modules/mod_cern_meta.so

LoadModule expires_module modules/mod_expires.so

LoadModule headers_module modules/mod_headers.so

LoadModule usertrack_module modules/mod_usertrack.so

#LoadModule example_module modules/mod_example.so

#LoadModule unique_id_module modules/mod_unique_id.so

LoadModule setenvif_module modules/mod_setenvif.so

<IfDefine HAVE_SSL>

LoadModule ssl_module extramodules/libssl.so

</IfDefine>

LoadModule vhost_alias_module modules/mod_vhost_alias.so

 

# Reconstruction of the complete module list from all available modules

# (static and shared ones) to achieve correct module execution order.

# [WHENEVER YOU CHANGE THE LOADMODULE SECTION ABOVE UPDATE THIS, TOO]

ClearModuleList

#AddModule mod_mmap_static.c

AddModule mod_env.c

AddModule mod_log_config.c

AddModule mod_log_agent.c

AddModule mod_log_referer.c

#AddModule mod_mime_magic.c

AddModule mod_mime.c

AddModule mod_negotiation.c

AddModule mod_status.c

AddModule mod_info.c

AddModule mod_include.c

AddModule mod_autoindex.c

AddModule mod_dir.c

AddModule mod_cgi.c

AddModule mod_asis.c

AddModule mod_imap.c

AddModule mod_actions.c

#AddModule mod_speling.c

AddModule mod_userdir.c

AddModule mod_proxy.c

AddModule mod_alias.c

AddModule mod_rewrite.c

AddModule mod_access.c

AddModule mod_auth.c

AddModule mod_auth_anon.c

#AddModule mod_auth_dbm.c

#AddModule mod_auth_db.c

AddModule mod_digest.c

#AddModule mod_cern_meta.c

AddModule mod_expires.c

AddModule mod_headers.c

AddModule mod_usertrack.c

#AddModule mod_example.c

#AddModule mod_unique_id.c

AddModule mod_so.c

AddModule mod_setenvif.c

<IfDefine HAVE_SSL>

AddModule mod_ssl.c

</IfDefine>

AddModule mod_vhost_alias.c

 

###

### Global Configuration

###

# We now support multiple apache configurations on the same server. In

# common.conf, we put all directives that are common to all implementations

# (httpd, httpd-perl, etc.)

Include conf/commonhttpd.conf

 

 

###

### IP Address/Port and Proxied configuration section

###

# The APACHEPROXIED setting can be set in /etc/rc.d/init.d/httpd if you

# are using a proxy or accelerator, like the Apache-SGI or khttpd, so that

# the fast web server serves static content while Apache handles the

# cgi or php files

 

#BindAddress *

<IfDefine APACHEPROXIED>

Port 8080

Listen 8080

</IfDefine>

<IfDefine !APACHEPROXIED>

Port 80

Listen 80

</IfDefine>

<IfDefine !APACHEPROXIED>

Port 81

Listen 81

</IfDefine>

# Likewise, we can set apache as the server by default and send perl

# requests via ProxyPass to apache-mod_perl. It increases performance

# since the perl interpreter is only used for perl and the standard apache

# does all the html and image files, with a smaller footprint.

#

# If you install apache and apache-mod_perl, this is the default config.

# If you don't want two web servers to use perl, uninstall apache, and

# apache-mod_perl will not be proxied.

 

<IfDefine PERLPROXIED>

RewriteEngine on

RewriteRule ^proxy:.* - [F]

RewriteRule ^(.*\/perl\/.*)$ http://%{HTTP_HOST}:8200$1'>http://%{HTTP_HOST}:8200$1 [P]

RewriteRule ^(.*\/cgi-perl\/.*)$ http://%{HTTP_HOST}:8200$1 [P]

</IfDefine>

 

###

### Log configuration Section

###

 

#Single logfile with access, agent and referer information

#This is the default, if vlogs are not defined for the main server

CustomLog logs/access_log combined env=!VLOG

#If VLOG is defined in conf/vhosts/Vhost.conf, we use this entry

CustomLog "|/usr/sbin/advxsplitlogfile" vhost env=VLOG

 

 

###

### Virtual Hosts

###

# We include different templates for Virtual Hosting. Have a look in the

# vhosts directory and modify to suit your needs.

Include conf/vhosts/Vhosts.conf

#Include conf/vhosts/DynamicVhosts.conf

#Include conf/vhosts/VirtualHomePages.conf

 

 

###

### Performance settings Section

###

#

# 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. Rather than making you guess how many

# server processes you need, Apache dynamically adapts to the load it

# sees --- that is, it tries to maintain enough server processes to

# handle the current load, plus a few spare servers to handle transient

# load spikes (e.g., multiple simultaneous requests from a single

# Netscape browser).

#

# It does this by periodically checking how many servers are waiting

# for a request. If there are fewer than MinSpareServers, it creates

# a new spare. If there are more than MaxSpareServers, some of the

# spares die off. The default values are probably OK for most sites.

#

MinSpareServers 4

MaxSpareServers 10

 

#

# Number of servers to start initially --- should be a reasonable ballpark

# figure.

#

StartServers 4

 

#

# Limit on total number of servers running, i.e., limit on the number

# of clients who can simultaneously connect --- if this limit is ever

# reached, clients will be LOCKED OUT, so it should NOT BE SET TOO LOW.

# It is intended mainly as a brake to keep a runaway server from taking

# the system with it as it spirals down...

#

MaxClients 150

 

#

# MaxRequestsPerChild: the number of requests each child process is

# allowed to process before the child dies. The child will exit so

# as to avoid problems after prolonged use when Apache (and maybe the

# libraries it uses) leak memory or other resources. On most systems, this

# isn't really needed, but a few (such as Solaris) do have notable leaks

# in the libraries. For these platforms, set to something like 10000

# or so; a setting of 0 means unlimited.

#

# NOTE: This value does not include keepalive requests after the initial

# request per connection. For example, if a child process handles

# an initial request and 10 subsequent "keptalive" requests, it

# would only count as 1 request towards this limit.

#

MaxRequestsPerChild 500

 

Include conf/ssl/mod_ssl.conf

Include conf/ssl/ssl.default-vhost.conf

 

<VirtualHost localhost:81>

ServerName localhost

DocumentRoot "/home/joao/wwwprj/websiteA"

</VirtualHost>

Link to comment
Share on other sites

I am 100 percent sure I know your problem because I've had the same.

 

I use webmin to update my apache server, too. I also couldn't create virtual servers, but I fixed it by doing some tweaking.

 

1. Update webmin

2. Lower security level to normal

3. Log out and log on as root

4. Go to /etc/httpd/conf/

5. Take the file httpd.conf file and put it somewhere else thats safe. (in case you need it again)

6. Make sure a file called httpd2.conf is there, if not forget what I said at all.

7. Log out of root and back on to your user

8. Raise your security levels again.

9. Try it out and see if it works.

 

The reason I think this will fix your problem, is that webmin changes the wrong config file and when you remove the fake one its writing too, it automatically detects the right one which should be httpd2.conf, not httpd.conf. Also make sure to restart Apache after changes.

 

Good luck, this took me a while to figure out myself. I'm happy I could help someone with a similiar problem.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...