| Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
|
10-08-2012, 01:59 PM
|
#1
|
|
Member
Registered: Nov 2011
Posts: 125
Rep: 
|
Subdomain Problem
Hi
I created the following in apache
Code:
<VirtualHost *:8080>
ServerName subdomain.domain.com
ServerAlias subdomain.*
DocumentRoot /var/www/html/subdomain
</VirtualHost>
And then, in domin.com.hosts file I added the following line.
Quote:
|
subdomain IN A xxx.xx.xx.xx
|
and in nginx, i added the following
server {
listen 80;
server_name subdomain.domain.com;
.........
}
But when i try to access it is not working.
What am i missing / doing wrong?
|
|
|
|
10-08-2012, 02:20 PM
|
#2
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,676
|
at what point do you tell nginx to connect to port 8080? Why are you using port 8080 in the first place? Do you have a Listen statment in apache for it? Is it listening from a network check?
|
|
|
|
10-09-2012, 01:54 AM
|
#3
|
|
Member
Registered: Nov 2011
Posts: 125
Original Poster
Rep: 
|
Quote:
Originally Posted by acid_kewpie
at what point do you tell nginx to connect to port 8080? Why are you using port 8080 in the first place? Do you have a Listen statment in apache for it? Is it listening from a network check?
|
I have two domains on this server.
But this subdomain is not loading.
|
|
|
|
10-09-2012, 02:06 AM
|
#4
|
|
Member
Registered: Aug 2011
Location: Chennai,India
Distribution: Redhat,Centos,Ubuntu,Dedian
Posts: 527
Rep: 
|
Quote:
I have two domains on this server.
But this subdomain is not loading.
|
Since you are running your virtualhost in port 8080.Default apache listen on port 80.Have you made entry in apache httpd.conf to listen to virtualhost 8080
Listen 8080 --HTTPD.CONF
<VirtualHost *:8080>
..
|
|
|
|
10-09-2012, 02:11 AM
|
#5
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,676
|
Quote:
Originally Posted by agriz
I have two domains on this server.
But this subdomain is not loading.
|
repeating yourself is not useful. Please provide new useful information that answers the questions asked.
|
|
|
|
10-09-2012, 02:17 AM
|
#6
|
|
Member
Registered: Nov 2011
Posts: 125
Original Poster
Rep: 
|
Quote:
Originally Posted by acid_kewpie
repeating yourself is not useful. Please provide new useful information that answers the questions asked.
|
Yes, I have done that.
I didn't mean to repeat.
I made apache to listen. I guess otherwise, the two main domains won't work.
Obviously, for the first time, I spent lot of time to make it work. (This apache + nginx) I got some help here too.
Now i am struck in subdomain. Please let me know what kind of information do you need?
** Nginx is handling js,css,images (static files)
** Apache is handling php files.
Nginx is listening on port 80
Apache is listening on port 8080
|
|
|
|
10-09-2012, 02:20 AM
|
#7
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,676
|
so again, where in your nginx config do you reference port 8080? Actually, you need to ignore nginx for now... test using the domain purely with apache.
to avoid DNS mess etc, run:
curl -H "Host: subdomain.domain.com" 127.0.0.1:8080
and see what that does. Also check the contents of your access and errror logs, especially error on startup.
|
|
|
|
10-09-2012, 02:29 AM
|
#8
|
|
Member
Registered: Nov 2011
Posts: 125
Original Poster
Rep: 
|
location / {
proxy_pass http://127.0.0.1:8080;
}
This is found in nginx.
This is the output of curl
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>301 Moved Permanently</title>
</head><body>
<h1>Moved Permanently</h1>
<p>The document has moved <a href="http://www.subdomain.domain.com/">here</a>.</p>
</body></html>
|
|
|
|
10-09-2012, 02:34 AM
|
#9
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,676
|
No idea what's providing that back to you, but clearly there is no coverage for that domain name in your apache config, so either create the www ServerAlias or stop that redirect occurring.
|
|
|
|
10-09-2012, 03:08 AM
|
#10
|
|
Member
Registered: Nov 2011
Posts: 125
Original Poster
Rep: 
|
I have these lines in domain.com
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
I guess this one is making the subdomain.domain.com to www.subdomain.domain.com
But the document root is "subdomain" which has also one htaccess file there.
Why should it take the htaccess from domain.com?
|
|
|
|
10-09-2012, 03:11 AM
|
#11
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,676
|
does /var/www/html/subdomain the .htaccess file?
|
|
|
|
10-09-2012, 03:12 AM
|
#12
|
|
Member
Registered: Nov 2011
Posts: 125
Original Poster
Rep: 
|
Is virtualhost order in htaccess important?
This is the order in htaccess
domain.com
subdomain.domain.com
domain2.com
---------- Post added 10-09-12 at 03:12 AM ----------
Quote:
Originally Posted by acid_kewpie
does /var/www/html/subdomain the .htaccess file?
|
RewriteEngine On
RewriteBase /subdomain
ErrorDocument 404 /404.php
|
|
|
|
10-09-2012, 03:13 AM
|
#13
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,676
|
if there is no suitable matching virtualhost for the host requested then the first virtualhost in the list is used.
|
|
|
|
10-09-2012, 03:19 AM
|
#14
|
|
Member
Registered: Nov 2011
Posts: 125
Original Poster
Rep: 
|
<VirtualHost *:8080>
DocumentRoot "/var/www/html/domain"
ServerName domain.com
<Directory "/var/www/html/domain">
allow from all
Options -Indexes
</Directory>
ServerAlias *.domain.com
</VirtualHost>
<VirtualHost *:8080>
ServerName subdomain.domain.com
ServerAlias subdomain.*
DocumentRoot /var/www/html/domain/subdomain
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "/var/www/html/domain2"
ServerName domain2.com
<Directory "/var/www/html/domain2">
allow from all
Options -Indexes
</Directory>
ServerAlias *.domain2.com
</VirtualHost>
|
|
|
|
10-09-2012, 03:25 AM
|
#15
|
|
Moderator
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 42,676
|
why are you using a virtualhost for a subdomain that's in a directory underneath the main domain?
This looks handy: http://stackoverflow.com/questions/9...older-redirect
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:26 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|