LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices

Reply
 
LinkBack Search this Thread
Old 01-12-2013, 04:51 AM   #1
Rafael25
Member
 
Registered: Jul 2012
Posts: 50

Rep: Reputation: Disabled
Thumbs up Default NGINX Page


Hi,

I have installed NGINX on CentOS 5.x and its working smooth. However if I access mydomain.com in the browser, it throws a 404 error.

What I need to accomplish is :
1) If I access mydomain.com , it should fetch for a default index.php or index.html in the directory allocated(root directory) for that domain and display the same. If there is no such file, then it should display a default custom page(i.e a Welcome Page).

2) If I access mydomain.com/test.php and if test.php is not found only then it should display the 404 error page.

3) Also, I want a common error handler for all the server blocks created(for each domains).

I need the configurations for the same. Any help is greatly appreciated.
 
Old 01-15-2013, 08:03 AM   #2
rmacd
LQ Newbie
 
Registered: Jan 2013
Location: Scotland
Distribution: Debian
Posts: 16

Rep: Reputation: 2
Just an initial thought, I'm sure you know nginx will not do a great deal with a php file on its own, unless you've set up eg FastCGI somewhere for nginx to connect to.

Out of interest, what brought you to choose nginx over, say, Apache? It's not to say it's a great tool, it just sounds like messing with configs (ie to say, getting others to write them for you) might not be quite what you're looking for at the moment. Regardless...

For 1) I would set up a server block which catches all, sticks it in a regex and looks for the site directory:

Code:
server {
    server_name   ~^(www\.)?(?<domain>.+)$;

    location / {
        root   /path/to/$domain;
        index index.html index.php;

        ...

    }
}
2) If there's no test.php it's going to return as a 404 anyway...

3) For all server blocks/for each domain - rather ambiguous - are you wanting to serve up exactly the same error page across all domains? If so take a look at error_page in nginx wiki, there are a couple of solutions you could use.
 
Old 01-21-2013, 01:14 AM   #3
Rafael25
Member
 
Registered: Jul 2012
Posts: 50

Original Poster
Rep: Reputation: Disabled
Thanks a lot.. It helped me a lot.
 
Old 01-21-2013, 02:04 PM   #4
rewards
Member
 
Registered: Dec 2010
Posts: 128

Rep: Reputation: 0
Hello,

I have the same problem. Can you please tell me in details what you have done step by step? Which files you edited and where they are located? Thanks
 
  


Reply

Tags
error, nginx


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: DMCA Nonsense: Your Default Login Page Is A Ripoff Of Our Default Login Page! LXer Syndicated Linux News 0 01-03-2013 01:03 PM
nginx redirect error page cbtshare Linux - Server 0 10-10-2009 01:30 PM
I cant change the default test page in apache server to add my page.y nhemapriya Linux - Newbie 3 05-13-2004 12:35 PM
setting default page size and default tray lived4eva Linux - General 1 11-04-2003 02:39 PM
New Virtual Servers Default to Default Server Page? DigiDave Linux - Software 4 10-18-2003 03:23 AM


All times are GMT -5. The time now is 07:58 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration