dear colleagues,

i am using linux cetos 5 and not really an expert understanding some linux configurations. ph5, mysql5, apache2 have been installed yesterday and now i am about to do some testing for my websites.

what i would just like to achieve is to do "Virtual HTTP Server" (port 80)browsing, meaning i'll just set to the router the IP address of my linux machine (e.g. ) and then access it to another computer by simply typing to the browser to view my webpage. i am able to do this in a windows xp machine but not in linux. i've searched the web about this problem, and here's what i have done so far:

- i edited httpd.conf file and added the following lines at the bottom:

NameVirtualHost
<VirtualHost >
DocumentRoot /var/www/virtual/mywebfolder
ServerName test
</VirtualHost>

- saved httpd.conf file then restarted apache

i also tried httpd -S and it's telling me syntax OK and doesn't give me an error. i really had a hard time finding what's the problem. i would really appreciate any help that you could give.

thanks in advance.

regards,
- hayunna

Dani AI

Generated

Short summary and concrete checks (next steps)

As noted, Apache is up on a private address and you want other machines to reach it. is correct: a hostname like "test" will only work if clients resolve it (DNS or hosts file). is also on point: the ServerName should be a real name that clients use.

Quick troubleshooting (do these in order)

  • Confirm Apache is listening on port 80 and on the expected interface:
netstat -tlnp | grep :80
  • From the server, verify Apache serves the site by IP and by localhost:
curl -I http://localhost
curl -I http://192.168.102.10
  • From a client machine check basic connectivity:
ping 192.168.102.10
telnet 192.168.102.10 80   # or: nc -vz 192.168.102.10 80

If IP works but the name does not

  • Either add the mapping on each client (quick for testing) or add it to your local DNS. Example hosts file entry:
# /etc/hosts  or Windows hosts file
192.168.102.10   www.test.com test

Config, permissions, firewall and SELinux to check

  • For CentOS 5 / Apache 2.2 make sure name‑based vhosts are enabled and consistent (NameVirtualHost must match the VirtualHost address/port). Restart after changes:
service httpd restart
chkconfig httpd on
  • Firewall: ensure port 80 is allowed:
iptables -L -n
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
service iptables save
  • File ownership/permissions and SELinux contexts for your DocumentRoot:
chown -R apache:apache /var/www/virtual/mywebfolder
chmod -R 755 /var/www/virtual/mywebfolder
getenforce
# temporary test only:
setenforce 0
# restore later with setenforce 1 or fix contexts:
chcon -R -t httpd_sys_content_t /var/www/virtual/mywebfolder

Finally, check the Apache error log for concrete messages:

tail -n 50 /var/log/httpd/error_log

Follow that sequence: network/listen -> IP test -> name resolution -> firewall/SELinux -> permissions -> logs. That will locate the blocker quickly.

Recommended Answers

All 2 Replies

The problem is you don't propagate the host name changes across your computers. You'd need a local dns for that. Or you could just edit the hosts file. I'm guessing that you can access it by typing the ip in?

Hello there:

I am not really clear on what you want. So let me ask, do you want to run the web server on a linux host, , and then access the web page from another computer?

I am assuming that both computers are on the same network since is a private IP. Another thing, instead of having it as ServerName test, I would suggest you change it to:

ServerName

and as well add a line like this:

ServerAlias *. *

Thanks.
--Willie

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.