Nginx and PHP-fastCGI installed, but can't see my site!

My site, webstrider.com, is a relatively static, php-based site, but located on a sometimes rather slow server that a couple of times a year is down for hours. I decided to move it to a Linode 512 for improved speed and reliability. I have hosted sites on shared servers running cPanel, so have limited exposure to linux, but am otherwise rather experienced as a programmer and sys admin.

On my new Linode 512 I first installed Apache2, MySQL and PHP5. The site was nice and fast, but the PHP code that reads and updates RSS feeds, and rotates banner ads, simply didn't work – I could see the site ok, but the banners and RSS feeds just sat there. I figured I might as well just get bold and try Nginx and PHP-fastCGI.

I uninstalled Apache2 and MySql with apt-get purge, then carefully followed the steps in "Nginx and PHP-FastCGI on Ubuntu 10.04 LTS".

The last step they say is to upload test.php to the public_html folder and look at it in a browser.

Since webstrider.com is an active site, I don't want to change the DNS name server until I know it works on the new server. So in instead of going to webstrider.com/test.php. I entered the IP address in the browser, which worked fine when I was running Apache, but when I did that after installing nginx, etc, all I see is "welcome to nginx!" If I append /test.php, I get a 404 error.

I went back and reviewed everything and cannot find any mistakes. Of course I have rebooted the server, so everything is fresh. All files have been uploaded to public_html, but when I try to see them it's as though they simply aren't there.

I am stumped. Any suggestions would be greatly appreciated.

5 Replies

Probably "virtual host"config. You can fake it with telnet…

telnet your.host 80
GET /test.php HTTP/1.0
Host: webstrider.com
 <blank line=""></blank> 

The "Host:" line tells the webserver what virtual host to pick.

A couple options that might be easier…

Add an entry to the hosts file of your local machine (i.e., the one where you're running the web browser) to associate webstrider.com to your Linode's IP address. Remember to remove or comment out that line when you want to revert to the normal behavior!

Create a DNS entry for dev.webstrider.com and use that to test. You will need to configure Nginx to recognize that name alongside webstrider.com and may also have to configure your web application.

Thanks for the suggestions! I my Linux noob status is not too much of a hindrance..

Stephen - did you mean use telnet (I use PuTTy) to open a session and just type in those commands? I don't know enough yet about linux to understand what is going on in your suggestion however.

Vance - I edited the host file on my system, and it still goes to the "real" webstrider.com, even after a system restart. And for creating a DNS entry for dev.webstrider.com, did you mean doing so thru the linode DNS manager?

But I can't help but wonder, since I am getting a response from my linode (welcome to nginx) when I go to the IP address, and a 404 error when I enter, for instance, 'index.php', perhaps I could make more progress if I can figure out where it defaults to as a starting point, ie, the public_html folder or someplace else.

-Ed

OK, some progress to report – I discovered that when I go to my site via the IP address, I get the 'welcome to nginx' message, and discovered that it defaults to the var/www/nginx-default/ directory, which I verified by copying another .html file to that directory. I also ran the test.php file with the call to phpinfo(), and all I get is the code of the page as text, in other words, NO PHP!

..I probably need to review the steps again, more carefully.

Some background…

In the olden days, there was a 1:1 relationship between web servers and IP addresses. So you typed foo.example.com into your web browser. It looked in DNS and got the address 12.34.56.78, then made a connection to that address to retrieve the page. The server might have been a machine with that IP address hosting a single web site. Or it could have several IP addresses and be hosting multiple sites, and knew which one was being requested by the destination IP address (IP-based virtual hosting).

People soon realized that we'd quickly burn through the available IPv4 space if we gave each site its own address. Thus, name-based virtual hosting was born. The only gotcha is that the browser had to have support - it indicates which site it's trying to reach by sending the "Host: foo.example.com" line as sweh suggests.

Nowadays, all browsers have such support, so name-based virtual hosting is the standard setup for any machine running multiple sites. But if you type an IP address into your browser, it doesn't know which host you want, so you'll get whatever the web server considers to be the "default" site.

On to your questions…

sweh was describing a way that you can directly interact with a web server. It's possible with PuTTY, assuming your version supports the Telnet connection type.

The line that you add to your hosts file should read:

12.34.56.78  webstrider.com

using your Linode's real IP address, of course. I don't know if anything special is needed on Windows to get it to recognize the change; you might find some answers on a Windows-specific forum.

You would create a DNS entry for dev.webstrider.com on your current DNS provider, which looks to be Cloudflare.

But it sounds like you need to get the PHP issue sorted out first. I'm not familiar with Nginx so can't help you there.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct