How do I set up my hosts and httpd.conf files using a static IP address - linux

I set Centos 6.3 up on a Rackspace box, using a static IP address (not a FQDN). I will be setting up virtual hosts on this box, and it seems to be working fine, but when I restart the HTTPD server, I get an error message "could not reliably determine the server's fully qualified domain name, using xx.xxx.xx.xx for ServerName" (xx.xxx.xx.xx is the static IP address for the server).
My /etc/hosts has the following in it:
27.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
xx.xxx.xx.xx name-used-for-rackspace
name-used-for-racspace is a name (not a FQDN) I used when I created the server (you have to enter a name).
I assume that I may not have to change anything in /etc/hosts, but what do I put in httpd.conf? right now, I have the following in that file:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName localhost
<Directory /var/www/html>
allow from all
Options +Indexes
</Directory>
</VirtualHost>
I also tried setting ServerName to xx.xxx.xx.xx, but I got the same error message.

This error is because you are not using a FQDN. It should not affect the operation of the webserver.
To get rid of the message on startup you'd need to configure your hosts file with the correct domain and IP address. Your httpd.conf should also use the same name (where you have localhost specified).
As long as your server is starting and you don't plan on assigning a domain to your webserver, this error can be ignored.
Example virtual host with FQDN:
<VirtualHost *:80>
ServerName www.domain.net
ServerAlias domain.net *.domain.net
ServerAdmin administrator#domain.net
DocumentRoot "/home/domain/htdocs"
<Directory "/home/domain/htdocs">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
CustomLog "/home/domain/logs/access-www.log" common
ErrorLog "/home/domain/logs/error-www.log"
<IfModule mpm_peruser_module>
ServerEnvironment apache apache
</IfModule>
</VirtualHost>
Example hosts file:
127.0.0.1 localhost localhost.localdomain gentoo1
x.x.x.x gentoo1.domain.net

You need to configure the network connection with your static IP, see reference below. Otherwise, your web server is working, but it's not accessible externally.
https://access.redhat.com/knowledge/docs/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Configuring_IPv4_Settings.html
Then put the static IP in the httpd.conf after server name.

Related

Virtual host on WAMP server works for Firefox only

I have installed WAMP Server and added virtual host.
Strange thing:
On Firefox (my default browser) everything works ok.
On other browsers (Chrome, IE, Opera) the localhost is ok. I can run
php files in default directory/subdirectories, phpMyAdmin works ok as
well. But virtual host is not accessible (error
DNS_PROBE_FINISHED_NXDOMAIN or DNS_PROBE_FINISHED_BAD_CONFIG - see comments in hosts file).
Can you help me to find, why virtual hosts does not work on other browsers than default Firefox?
I am not experienced in this stuff, so it is possible that I do some very basic mistake.
More details:
I run WAMP Server 3.2.6 (64 bit) on Windows 10
I use port 8080 because of some
port conflict (probably Skype)
Adding Virtual Host via WAMP was
"easy", but I have to modify host file (port 8080 was missing).
Windows hosts file:
127.0.0.1 localhost
# with line "127.0.0.1 localhost" browser returns DNS_PROBE_FINISHED_NXDOMAIN
# without line "127.0.0.1 localhost" browser returns DNS_PROBE_FINISHED_BAD_CONFIG
127.0.0.1 localhost:8080
::1 localhost
127.0.0.1 sb:8080
::1 sb
httpd-vhosts.conf file:
# Virtual Hosts
NameVirtualHost *.8080
<VirtualHost *:8080>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www/"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:8080>
ServerName sb
DocumentRoot "d:/weby/sb/www/"
<Directory "d:/weby/sb/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>

/etc/hosts configuration not being detected

Am configuring a local linux development environment utilizing apache, i can access the url:
http://localhost:8080
but not the configured virtualhost entries which are also present in the /etc/hosts file e.g if i enter:
http://admin:8080
in my browser redirects me to www.admin.com, which is an external address.
/etc/hosts file has the following entries:
127.0.0.1 localhost admin jobboard
127.0.1.1 rob-VirtualBox
Apache config(virtual hosts reference the above entries admin and jobboard):
Listen 8080
Port 8080
ServerName 127.0.0.1:8080
DocumentRoot "/var/www/html/BigRedSkyASAP/virtualhosts"
<Directory "/var/www/html/BigRedSkyASAP/virtualhosts">
NameVirtualHost *:8080
<VirtualHost 127.0.0.1:8080>
ServerName admin
# set the document root
DocumentRoot "/var/www/html/BigRedSkyASAP/virtualhosts/Client-asap.bigredsky.com"
# set the directory settings
<Directory "/var/www/html/BigRedSkyASAP/virtualhosts/Client-asap.bigredsky.com">
Options All Includes Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.1:8080>
ServerName jobboard
# set the document root
DocumentRoot "/var/www/html/BigRedSkyASAP/virtualhosts/JobBoard-asapdev.bigredsky.com"
# set the directory settings
<Directory "/var/www/html/BigRedSkyASAP/virtualhosts/JobBoard-asapdev.bigredsky.com">
Options All Includes Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Apache and Computer was restarted after changes to config files were saved.
Is their some other hosts configuration file which needs to be modified? Running linux mint OS.
Thanks in advance.
in the virtual host config try this for admin
ServerAlias admin
that should resolve the admin website to local server
furthermore check whether you are under any proxy...you should turn it off...
create one more vhost entry for admin
<VirtualHost 127.0.0.1:8080>
ServerName admin

Subdomain not working on Apache/Linux

I'm trying to set up a subdomain for on a client's web server. It's a CentOS server running Apache. So say the website is "example.com". I'm trying to create "bugs.example.com".
So far, I've added to the vhost.conf file the subdomain info:
<VirtualHost *:80>
ServerName bugs.example.com
ServerAlias bugs.example.com
DocumentRoot /var/www/www.bugs.example.com
<Directory "/var/www/www.bugs.example.com">
AllowOverride ALL
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I've added the server's IP address and the subdomain to /etc/hosts:
111.222.333.444 bugs.example.com
I've created the directory for the website files, and an index page at:
/var/www/www.bugs.example.com/index.html
Sadly, I still get a "Server not found" error when I go to bug.example.com. What am I missing here? The example.com domain name is registered through GoDaddy.com. Is there something that needs to be done there?

virtualhost without real domain name

I've this configuration for my virtual host and runs with real domains. For testing purpose I need create same virtual host with non real domain (i.e. domain10). Considerated that the browser check the name of domain of virtual host, I think using something like 127.0.0.1. But I've no idea to realize this.
<VirtualHost *:80>
ServerAdmin info#domain10.org
ServerName domain10.org
ServerAlias domain10.org
DirectoryIndex index.html index.htm index.php
DocumentRoot /home/domain10.org/
<Directory /home/domain10.org/>
Options -Includes -Indexes -FollowSymLinks -ExecCGI +MultiViews
AllowOverride none
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
You can use the /etc/hosts file for this purpose. There should already be a line in it beginning with 127.0.0.1. Just add domain10.org to the list of hosts that resolves to this address.
For example, if the existing line is:
127.0.0.1 localhost localhost.localdomain
Just extend it to:
127.0.0.1 localhost localhost.localdomain domain10.org
Then (on this machine only) domain10.org will resolve to 127.0.0.1. If you are testing on the same machine, you can enter http://domain10.org/ in your browser to reach your local web server.
If you need to reach this host over the Internet, then a different approach is needed. Look for a line for the external IP address of the server in its /etc/hosts file and modify it similar to the above instructions. If such a line does not exist, add one.
On the client machine, do the same (using /etc/hosts for a Linux box or %WINDIR%\system32\drivers\etc\hosts for a Windows box). You should then be able to reach the server from the client using this name.

Creating subdomains in Amazon EC2

How can I create subdomains on Amazon EC2?
Is adding virtual host in httpd.conf is enough.. or any other changes also needs to be done?
Thanks
Depends on your server software. But as you mention httpd.conf, chances are good that you run Apache on a Linux distribution. If that's the case then yes, adding a virtual host is enough. Here is one way of doing it:
Purchase a domain. If you have one, skip this, we'll take example.com for this example.
Find the external IP or DNS for your EC2 instance. You probably want to associate an Elastic IP to your instance, otherwise the IP of your instance will change on reboots.
Create a DNS record for your domain, for instance a CNAME record to point to your Elastic IP/DNS name:
subdomain.example.com => ec2-xx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com
Make sure your httpd.conf contains a line to allow virtual hosts:
NameVirtualHost *:80
Create a virtual host directive:
httpd.conf:
<VirtualHost *:80>
ServerName subdomain.example.com
ServerAdmin webmaster#subdomain.example.com
DocumentRoot /var/www/example.com/subdomain
<Directory /var/www/example.com/subdomain>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/subdomain.example.com.error.log
LogLevel warn
CustomLog /var/log/apache2/subdomain.example.com.access.log combined
</VirtualHost>
6. Restart Apache
/etc/init.d/apache2 restart

Resources