Virtual Hosts Apache on Centos
Virtual Hosts Apache on Centos
I'm trying to configure an Apache Web server. I have two sites www.reposteria.com and www.littlebrothers.com, and a DNS server pointing to this Apache Web server with http://desarrollolinux.smartienda.cl/.
I need to use diferent directories for each sites
http://desarrollolinux.smartienda.cl/reposteria and http://desarrollolinux.smartienda.cl/littlebrothers.
The commands used to configure this sites are:
mkdir -p /var/www/reposteria.com/public_html
mkdir -p /var/www/littlebrothers.com/public_html
chown -R apache:apache /var/www/reposteria.com/public_html
chown -R apache:apache /var/www/littlebrothers.com/public_html
chmod -R 755 /var/www
mkdir /etc/httpd/sites-available
mkdir /etc/httpd/sites-enabled
nano /var/www/reposteria.com/public_html/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Reposteria</title>
</head>
<body>
<h1>Virtual OK Reposteria.com</h1>
</body>
</html>
cp /var/www/reposteria.com/public_html/index.html /var/www/littlebrothers.com/public_html/index.html
nano /var/www/littlebrothers.com/public_html/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Little</title>
</head>
<body>
<h1>Virtual OK Littlebrothers.com</h1>
</body>
</html>
nano /etc/httpd/conf/httpd.conf
IncludeOptional sites-enabled/*.conf
nano /etc/httpd/sites-available/reposteria.com.conf
<VirtualHost *:80>
ServerName www.reposteria.com
ServerAlias reposteria.com
DocumentRoot /var/www
</VirtualHost>
cp /etc/httpd/sites-available/reposteria.com.conf /etc/httpd/sites-available/littlebrothers.com.conf
nano /etc/httpd/sites-available/littlebrothers.com.conf
<VirtualHost *:80>
ServerName www.littlebrothers.com
ServerAlias littlebrothers.com
DocumentRoot /var/www/
</VirtualHost>
ln -s /etc/httpd/sites-available/reposteria.com.conf /etc/httpd/sites-enabled/reposteria.com.conf
ln -s /etc/httpd/sites-available/littlebrothers.com.conf /etc/httpd/sites-enabled/littlebrothers.com.conf
apachectl restart
nano etc/hosts
APACHE IP ADDRESS www.reposteria.com
APACHE IP ADDRESS www.ittlebrothers.com
apachectl restart
When I surf the Web using http://desarrollolinux.smartienda.cl/
I can see Virtual OK Littlebrothers.com, but if i use Virtual OK Littlebrothers.com/littlebrothers or Virtual OK Littlebrothers.com/reposteria I get this error:
Not Found
The requested URL /reposteria/ was not found on this server.
Does somebody can help me please?
Thanks!
I need to use diferent directories for each sites
http://desarrollolinux.smartienda.cl/reposteria and http://desarrollolinux.smartienda.cl/littlebrothers.
The commands used to configure this sites are:
mkdir -p /var/www/reposteria.com/public_html
mkdir -p /var/www/littlebrothers.com/public_html
chown -R apache:apache /var/www/reposteria.com/public_html
chown -R apache:apache /var/www/littlebrothers.com/public_html
chmod -R 755 /var/www
mkdir /etc/httpd/sites-available
mkdir /etc/httpd/sites-enabled
nano /var/www/reposteria.com/public_html/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Reposteria</title>
</head>
<body>
<h1>Virtual OK Reposteria.com</h1>
</body>
</html>
cp /var/www/reposteria.com/public_html/index.html /var/www/littlebrothers.com/public_html/index.html
nano /var/www/littlebrothers.com/public_html/index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Little</title>
</head>
<body>
<h1>Virtual OK Littlebrothers.com</h1>
</body>
</html>
nano /etc/httpd/conf/httpd.conf
IncludeOptional sites-enabled/*.conf
nano /etc/httpd/sites-available/reposteria.com.conf
<VirtualHost *:80>
ServerName www.reposteria.com
ServerAlias reposteria.com
DocumentRoot /var/www
</VirtualHost>
cp /etc/httpd/sites-available/reposteria.com.conf /etc/httpd/sites-available/littlebrothers.com.conf
nano /etc/httpd/sites-available/littlebrothers.com.conf
<VirtualHost *:80>
ServerName www.littlebrothers.com
ServerAlias littlebrothers.com
DocumentRoot /var/www/
</VirtualHost>
ln -s /etc/httpd/sites-available/reposteria.com.conf /etc/httpd/sites-enabled/reposteria.com.conf
ln -s /etc/httpd/sites-available/littlebrothers.com.conf /etc/httpd/sites-enabled/littlebrothers.com.conf
apachectl restart
nano etc/hosts
APACHE IP ADDRESS www.reposteria.com
APACHE IP ADDRESS www.ittlebrothers.com
apachectl restart
When I surf the Web using http://desarrollolinux.smartienda.cl/
I can see Virtual OK Littlebrothers.com, but if i use Virtual OK Littlebrothers.com/littlebrothers or Virtual OK Littlebrothers.com/reposteria I get this error:
Not Found
The requested URL /reposteria/ was not found on this server.
Does somebody can help me please?
Thanks!
Re: Virtual Hosts Apache on Centos
That's the same for both sites and should be different. That looks wrong for both of them.DocumentRoot /var/www
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Re: Virtual Hosts Apache on Centos
set DocumentRoot to /var/www/reposteria.com/public_html and /var/www/littlebrothers.com/public_html
Re: Virtual Hosts Apache on Centos
Thanks for the answers!
I have modified httpd.conf and add
DocumentRoot "/var/www/reposteria.com/public_html/"
DocumentRoot "/var/www/littlebrothers.com/public_html/"
After that I have restarted httpd service, and surf to http://desarrollolinux.smartienda.cl/reposteria/ but it does no work, I got the same answer from the server
Not Found
The requested URL /reposteria/ was not found on this server.
Do you have any other suggestions?
Regards!
I have modified httpd.conf and add
DocumentRoot "/var/www/reposteria.com/public_html/"
DocumentRoot "/var/www/littlebrothers.com/public_html/"
After that I have restarted httpd service, and surf to http://desarrollolinux.smartienda.cl/reposteria/ but it does no work, I got the same answer from the server
Not Found
The requested URL /reposteria/ was not found on this server.
Do you have any other suggestions?
Regards!
Re: Virtual Hosts Apache on Centos
try to apachectl configtest and see if it is ok
Re: Virtual Hosts Apache on Centos
Thanks!!
The syntax is ok....Just reboot the server and it works fine.
Now if I surf www.littlebrothers.com or www.reposteria.com both sites response.
I have a couple of questions, what if I want to surf like:
http://desarrollolinux.smartienda.cl/reposteria or http://desarrollolinux.smartienda.cl/littlebrothers. What should I do? Should I point DNS Server to www.littlebrothers.com and www.reposteria.com?
How can I create the following structure?
www.littlebrothers.com/payment
where payment is another directory to run index.html or index.php.
Regards!
The syntax is ok....Just reboot the server and it works fine.
Now if I surf www.littlebrothers.com or www.reposteria.com both sites response.
I have a couple of questions, what if I want to surf like:
http://desarrollolinux.smartienda.cl/reposteria or http://desarrollolinux.smartienda.cl/littlebrothers. What should I do? Should I point DNS Server to www.littlebrothers.com and www.reposteria.com?
How can I create the following structure?
www.littlebrothers.com/payment
where payment is another directory to run index.html or index.php.
Regards!
404 Error
I need to run a .html file from www.reposteria.com/payment, but when a try to surf to that address I got this 404 Error Not Found The requested URL /payment/ was not found on this server.
The DocumentRoot directive is:
DocumentRoot "/var/www/reposteria.com/public_html/payment"
The sites-available has a reposteria.com.conf whit this configuration:
<VirtualHost *:80>
#ServerAdmin webmaster@reposteria.com
ServerName www.reposteria.com
ServerAlias reposteria.com
DocumentRoot /var/www/reposteria.com/public_html/payment
ErrorLog /var/www/reposteria.com/error.log
CustomLog /var/www/reposteria.com/access.log combined
</Virtualhost>
Does anybody knows what shoul I do?
Thanks!
The DocumentRoot directive is:
DocumentRoot "/var/www/reposteria.com/public_html/payment"
The sites-available has a reposteria.com.conf whit this configuration:
<VirtualHost *:80>
#ServerAdmin webmaster@reposteria.com
ServerName www.reposteria.com
ServerAlias reposteria.com
DocumentRoot /var/www/reposteria.com/public_html/payment
ErrorLog /var/www/reposteria.com/error.log
CustomLog /var/www/reposteria.com/access.log combined
</Virtualhost>
Does anybody knows what shoul I do?
Thanks!
Re: 404 Error
It could be wrong selinux settings for /var/www/reposteria.com (+subdirectories):
ls -lZ /var/www/reposteria.com
ls -lZ /var/www/reposteria.com
Re: Virtual Hosts Apache on Centos
Let's keep all discussion about this in one thread rather than raising new ones all the time...
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke
Re: Virtual Hosts Apache on Centos
This is the security context of each one. I disable Selinux to make a prove but the server response is the same 404 Not Found The requested URL /payment/ was not found on this server.
ls -lZ /var/www/reposteria.com/
total 12
-rwxr-xr-x 1 root root ? 4733 Nov 13 15:09 access.log
-rwxr-xr-x 1 root root ? 1220 Nov 13 12:38 error.log
drwxr-xr-x 4 apache apache ? 53 Nov 13 15:18 public_html
ls -lZ /var/www/reposteria.com/public_html/
total 4
-rwxr-xr-x 1 root root ? 165 Nov 12 17:14 index.html
drwxr-xr-x 2 root root ? 24 Nov 13 15:22 payment
drwxr-xr-x 2 root root ? 24 Nov 13 13:07 webpay
s -lZ /var/www/reposteria.com/public_html/payment/
total 4
-rwxr-xr-x 1 root root ? 14 Nov 13 15:22 index.html
ls -lZ /var/www/reposteria.com/
total 12
-rwxr-xr-x 1 root root ? 4733 Nov 13 15:09 access.log
-rwxr-xr-x 1 root root ? 1220 Nov 13 12:38 error.log
drwxr-xr-x 4 apache apache ? 53 Nov 13 15:18 public_html
ls -lZ /var/www/reposteria.com/public_html/
total 4
-rwxr-xr-x 1 root root ? 165 Nov 12 17:14 index.html
drwxr-xr-x 2 root root ? 24 Nov 13 15:22 payment
drwxr-xr-x 2 root root ? 24 Nov 13 13:07 webpay
s -lZ /var/www/reposteria.com/public_html/payment/
total 4
-rwxr-xr-x 1 root root ? 14 Nov 13 15:22 index.html