Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Mon Feb 20, 2012 5:13 pm 
Offline
Junior Member

Joined: Thu Feb 16, 2012 6:06 am
Posts: 22
Website: http://doodleskull.com
Location: Helsinki, Finland
I have always wanted a website. And now I almost have it.

There is a problem.

I was told that static sites are the way to go. That I should get one. Jekyll, Github, haml, Ruby, version control, for the love of god no PHP, and all that stuff. Whatever. Much better than the old stiff WordPress mammoth. Static site would be like a young-born circus elephant compared to that. And I did. It involved all kinds of black geek sorcery from my point of view but eventually my hipster sass-compass Octopress site was ready. I nearly lost my mind and job along the process, so good thing I got finally something done.

It all went well until I talked with some hacker guy about my hosting. "Cool. Octopress. So where you host that thing of yours?", he asked. "Oh, it's on Webfaction", I replied. "WHAT?!", he yelled. "DUDE YOU HAVE A STATIC SITE AND IT'S ON SHARED HOSTING!?! THAT'S LIKE KEEPING A SUPERMODEL IN A LOCKED SHED IN YOUR BACKYARD!!!!" At this point, I kindly asked him to not to use caps lock again during our conversation. He replied with a hurricane of zeros and ones, which I believe contained several curse words translated into binary code. After that he wrote just one word to me. Linode. Taking account the fact we have recently talked about web hosting, I presumed it was a last resort suggestion for finding salvation from the damnation of shared web hosting.

So I got my Linode account. Installed nginx, Apache and so on. I set the hostname. I named my linode "moonshine". I chose Ubuntu 10.04 LTS as my Linux distribution. Then I had to configure the nginx server.

Sweet. Mother. Of. God.

Remember those old video games which had the final enemy boss level? Yeah. The nginx.conf file became that for me. So in my case the final boss fight came up with trying to create a website, not while playing a video game. Which is much worse. There's all these code blocks, locations, server names and what not. And yes. I read the Linode tutorial on basic nginx configuration. It's just too hard for me. Hard like "lasso a unicorn, find the Holy Grail and solve the European Economic crisis with them." Like yes, I know the things I need but I really don't know how can solve that with them. Very illogical. So, where should start to configure the nginx.conf file so I can beat my final boss and get through this battle as hero? A hero with a working website.

Thanks for your answers, in advance.

P.S. I did look through the forums if there would have been any post like mine. I believe there wasn't.


Last edited by doodleskull on Mon Feb 20, 2012 6:50 pm, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Mon Feb 20, 2012 6:30 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
LOL, this is one of the most hilariously written (albeit verbose) questions I've seen in a long time.

If you followed any tutorial that involves compiling nginx from source, I dunno.

If you just did "apt-get install nginx", then maybe I can help you.

Don't touch /etc/nginx/nginx.conf. There's nothing in that file that needs to be edited right now.

Instead, go to /etc/nginx/sites-available. There should be a file named "default" there. Don't touch that one, either. Create another file with whatever name you want. Let's say the filename is "doodleskull". Put the following lines in there:

Code:
server {
    listen 80;
    server_name example.com www.example.com;
    root /wherever/your/static/site/is/located;
}

Replace both occurrences of "example.com" with your domain. Replace the path with the name of the directory where you uploaded your static site. (If you haven't uploaded it yet, do it first.) Don't forget the semicolon at the end of each line.

Done? Now issue the following commands:
Code:
ln -s /etc/nginx/sites-available/doodleskull /etc/nginx/sites-enabled/doodleskull
/etc/init.d/nginx reload

That's it. You can put a lot of other things in that configuration file to customize your server's behavior, but if it's a static site you shouldn't have to do much more than that.


Last edited by hybinet on Mon Feb 20, 2012 6:35 pm, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Mon Feb 20, 2012 6:34 pm 
Offline
Senior Member
User avatar

Joined: Sun Dec 27, 2009 11:12 pm
Posts: 1038
Location: Colorado, USA
I had static on my site once, it turned out to be a loose ground wire.


Top
   
 Post subject:
PostPosted: Mon Feb 20, 2012 7:19 pm 
Offline
Junior Member

Joined: Thu Feb 16, 2012 6:06 am
Posts: 22
Website: http://doodleskull.com
Location: Helsinki, Finland
Finally, the reinforcements have arrived. However, my friends, this battle took a dramatic turn.

I don't have /etc/nginx/sites-available directory. I do have /etc/apache2/sites-available folder, though. But that's a bit like saying "I do have a Volvo" when someone asks if you have a Ferrari in your garage.

I installed nginx by following this guide: http://library.linode.com/web-servers/nginx/installation/ubuntu-10.04-lucid
This guide downloads and compiles nginx to: /opt/nginx
There's not /sites-available sub-folder either.

I also installed nginx from the Ubuntu packages by using the command:
Code:
apt-get install nginx
Thus, there seems to be two nginx directories in /opt: /nginx and /nginx-1.0.12

So... I installed nginx... twice?


Top
   
 Post subject:
PostPosted: Mon Feb 20, 2012 8:41 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
So it seems that you have not one, not two, but three web servers installed on your Linode!

1) Apache
2) nginx (ubuntu package)
3) nginx (compiled)

That can cause all sorts of trouble the next time you reboot your server, because whichever server grabs port 80 first will crash the other two.

First, get rid of Apache if you don't need it: apt-get remove apache2

Second, get rid of the compiled nginx. You're better off using the official package, because then you won't have to worry about security fixes all the time. I'd like to tell you that you can probably nuke /opt/nginx without damaging anything else, but...

There are some possible complications.

1. Why are there two nginx directories in /opt? The official package doesn't place anything in /opt. If both directories are from the compiled version, that's fine, you could delete them both... but if not, something smells fishy.

2. After installing nginx with apt-get, do you have /etc/nginx/sites-available now? Or at least /etc/nginx? If not, something smells even more fishy.

3. The tutorial also tells you to create an init script at /etc/init.d/nginx, which will probably stop working if you delete the compiled nginx. Unfortunately, this is the exact same location where Ubuntu's official nginx package places its own init script, so your file could have come from either source. You could try deleting the init script and run "apt-get install --reinstall nginx", but I can't guarantee that this will put the right init script in its place.


Top
   
 Post subject:
PostPosted: Wed Feb 22, 2012 3:26 am 
Offline
Junior Member

Joined: Thu Feb 16, 2012 6:06 am
Posts: 22
Website: http://doodleskull.com
Location: Helsinki, Finland
1. Got rid of Apache, with apt-get remove, that went well.

2. Got rid both nginx servers, only that I had to remove them manually from the /opt folder. I removed both nginx folders. Before that I tried 'make uninstall' in the nginx folders and 'apt-get remove nginx'. It didn't work.

3. After manually deleting nginx folder, installed nginx again from Ubuntu packages with 'apt-get install nginx'. I chose it to overwrite the old /etc/init.d/nginx script.

4. Created file 'doodleskull' in /etc/nginx/sites-available and put there what server to listen and appropriate root for actual site files.

5. So everything went fine, right? Nah, not so fast, my friend.

6. Pointed my domain name to Linode's servers from Namecheap. Nameservers, that is.

7. Long story short, didn't work, I see the site fine but page speed test sites (wanted to check if the page load time improved from Webfaction to Linode) gave all a 404 error. Eventually pointed nameservers back to Webfaction just to be sure that site is up with out 404's. Will try again later to solve this mammoth problem.

8. Don't know WTF to do next.

9. Thanks for the help though.

10. Actually there wasn't a thing number 10, but I wanted to end this with 10, because all lists on the internet come in tens.


Last edited by doodleskull on Wed Feb 22, 2012 4:16 pm, edited 1 time in total.

Top
   
 Post subject:
PostPosted: Wed Feb 22, 2012 11:28 am 
Offline
Linode Staff
User avatar

Joined: Fri Jan 29, 2010 8:44 am
Posts: 65
Location: New Jersey
This is the most amusing help thread I've read in a while.

Did you copy the sites-available file exactly? You'll want to add a line to tell nginx where to log errors:

Code:
error_log /path/to/site/logs/error.log;


Reload nginx and hit some of your pages. Check the error log you just specified for more details and come back to this thread if it's not clear.


Top
   
 Post subject:
PostPosted: Wed Feb 22, 2012 12:56 pm 
Offline
Senior Member
User avatar

Joined: Wed Mar 17, 2004 4:11 pm
Posts: 554
Website: http://www.unixtastic.com
Location: Europe
doodleskull wrote:
6. Pointed my domain name to Linode's servers from Namecheap. Nameservers, that is.


Wait. Did you configure linodes nameservers to return your linode's IP address for your domain name?

What is the domain name for your website?


Top
   
 Post subject:
PostPosted: Wed Feb 22, 2012 2:06 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
sednet wrote:
Wait. Did you configure linodes nameservers to return your linode's IP address for your domain name?
What is the domain name for your website?

(OP's username).com seems to have been registered thru Namecheap, hosted on Webfaction, and built with Octopress. This fits OP's description.

The same domain is also served by Linode's nameservers, and it points to an IP address in Linode's London datacenter.

Requesting the domain at the IP address returns a 404 from nginx/1.0.12. Interestingly, no version of Ubuntu supplies that particular version of nginx. The only repository that currently contains nginx/1.0.12 is dotdeb for Debian. OP trying a new distro? :P

Anyway, it's a bad idea to move an entire domain over until you're sure that your site is functioning properly. Moving nameservers is particularly dangerous because it can take a day or two to take effect, and another day or two to reverse any mistakes.

Does webfaction allow you to tweak the DNS? If so, try adding a subdomain with an A record that points at your Linode's IP address. Add the corresponding subdomain to your "doodleskull" configuration file (just append it to the "server_name" line), and reload nginx. Test away on the subdomain. If it works, move the main domain.


Top
   
 Post subject:
PostPosted: Wed Feb 22, 2012 5:58 pm 
Offline
Junior Member

Joined: Thu Feb 16, 2012 6:06 am
Posts: 22
Website: http://doodleskull.com
Location: Helsinki, Finland
Holy crap. Not only that I'm fat, ugly and broke I'm now also incompatible ever becoming a sys admin. How low one human can get?

Anyways. Let's continue to humiliate me & my skills publicly so all the people who can actually do this stuff can laugh at my expense.

Quote:
Did you copy the sites-available file exactly?


Umm, that would be a no. I just created 'doodleskull' file in the /etc/nginx/sites-available folder. It has only these lines in it and nothing else:

Code:
server { 
    listen 80;
    server_name derp.doodleskull.com doodleskull.com www.doodleskull.com;
    root /where/i/believe/my/site/is/located/but/dont/really/have/a/clue;
}


Moving on:

Quote:
Interestingly, no version of Ubuntu supplies that particular version of nginx. The only repository that currently contains nginx/1.0.12 is dotdeb for Debian. OP trying a new distro?


Okay... I re-installed nginx earlier from the Ubuntu package, or so I think at least. I might have also tried to build the Large Hadron Collider via the command line, which may have caused this. In other words, I don't have clue.

Webfaction allows me to tweak the DNS. I created "derp.doodleskull.com" and pointed it with a A record to my Linode's IP. Reloaded nginx, tested the subdomain, got a 404 again.

Oh, and the error log thing. I put that error log path also in the "doodleskull" file, reloaded nginx but the error log was empty. As are my ideas to get my website working. The battle continues.

Thanks again guys for the help.


Top
   
 Post subject:
PostPosted: Wed Feb 22, 2012 6:05 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
There's a symlink from /etc/nginx/sites-enabled/doodleskull to /etc/nginx/sites-available/doodleskull, right? I think there's a nifty script that automagically does this, but I can't recall what it is named.

Also, what does 'apt-cache policy nginx' say? That should spit out what the package manager thinks is going on.

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
 Post subject:
PostPosted: Wed Feb 22, 2012 6:15 pm 
Offline
Junior Member

Joined: Thu Feb 16, 2012 6:06 am
Posts: 22
Website: http://doodleskull.com
Location: Helsinki, Finland
Quote:
There's a symlink from /etc/nginx/sites-enabled/doodleskull to /etc/nginx/sites-available/doodleskull, right?


I'm not sure. I believe so?

Quote:
Also, what does 'apt-cache policy nginx' say?


This:

Code:
nginx:
  Installed: 0.7.65-1ubuntu2.2
  Candidate: 0.7.65-1ubuntu2.2
  Version table:
 *** 0.7.65-1ubuntu2.2 0
        500 http://us.archive.ubuntu.com/ubuntu/ lucid-updates/universe Packages
        100 /var/lib/dpkg/status
     0.7.65-1ubuntu2.1 0
        500 http://security.ubuntu.com/ubuntu/ lucid-security/universe Packages
     0.7.65-1ubuntu2 0
        500 http://us.archive.ubuntu.com/ubuntu/ lucid/universe Packages


Top
   
 Post subject:
PostPosted: Wed Feb 22, 2012 7:24 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
There is no thinking! There is only knowing! To know is to know, to think is to think!

ls -l /etc/nginx/sites-enabled/

:-)

Also, try "/etc/init.d/nginx restart" again, if you haven't in awhile... it's possible the old server is still running...

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
 Post subject:
PostPosted: Wed Feb 22, 2012 7:27 pm 
Offline
Senior Member

Joined: Fri May 02, 2008 8:44 pm
Posts: 1121
derp.doodleskull.com is still being served by nginx/1.0.12.

Anything in /var/log/nginx/error.log or similarly named files? (The error_log line suggested by Stan_Theman won't do anything unless the www-data user has write permission to the appropriate directory.)

Just check /etc/nginx/sites-enabled/doodleskull and verify that it contains the same thing as /etc/nginx/sites-available/doodleskull. If the symlink has been set up correctly, whenever you edit one of those files, the other file should be modified too.

It's also possible that your old compiled nginx is still hanging around in RAM if you haven't rebooted yet. For some reason, apt-get doesn't automatically start the newly installed nginx ater installation is complete, which means that it may not be running. What does the command "ps aux" return? (edit: dang, hoopycat beat me to this suggestion.)


Top
   
 Post subject:
PostPosted: Wed Feb 22, 2012 7:34 pm 
Offline
Junior Member

Joined: Thu Feb 16, 2012 6:06 am
Posts: 22
Website: http://doodleskull.com
Location: Helsinki, Finland
In /var/log/nginx/error.log:

Code:
2012/02/22 15:14:16 [emerg] 16626#0: open() "/path/to/site/logs/error.log" failed (2: No such file or directory)
2012/02/22 17:27:33 [emerg] 17763#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2012/02/22 17:27:33 [emerg] 17763#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2012/02/22 17:27:33 [emerg] 17763#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2012/02/22 17:27:33 [emerg] 17763#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2012/02/22 17:27:33 [emerg] 17763#0: bind() to 0.0.0.0:80 failed (98: Address already in use)
2012/02/22 17:27:33 [emerg] 17763#0: still could not bind()


ps aux returns:

Code:
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.0  0.3   2736  1580 ?        Ss   Feb12   0:02 /sbin/init
root         2  0.0  0.0      0     0 ?        S    Feb12   0:00 [kthreadd]
root         3  0.0  0.0      0     0 ?        S    Feb12   0:01 [ksoftirqd/0]
root         4  0.0  0.0      0     0 ?        S    Feb12   0:09 [kworker/0:0]
root         5  0.0  0.0      0     0 ?        S    Feb12   0:00 [kworker/u:0]
root         6  0.0  0.0      0     0 ?        S    Feb12   0:00 [migration/0]
root         7  0.0  0.0      0     0 ?        S    Feb12   0:00 [migration/1]
root         8  0.0  0.0      0     0 ?        S    Feb12   0:00 [kworker/1:0]
root         9  0.0  0.0      0     0 ?        S    Feb12   0:00 [ksoftirqd/1]
root        10  0.0  0.0      0     0 ?        S    Feb12   0:00 [migration/2]
root        11  0.0  0.0      0     0 ?        S    Feb12   0:00 [kworker/2:0]
root        12  0.0  0.0      0     0 ?        S    Feb12   0:00 [ksoftirqd/2]
root        13  0.0  0.0      0     0 ?        S    Feb12   0:00 [migration/3]
root        14  0.0  0.0      0     0 ?        S    Feb12   0:00 [kworker/3:0]
root        15  0.0  0.0      0     0 ?        S    Feb12   0:00 [ksoftirqd/3]
root        16  0.0  0.0      0     0 ?        S<   Feb12   0:00 [cpuset]
root        17  0.0  0.0      0     0 ?        S<   Feb12   0:00 [khelper]
root        18  0.0  0.0      0     0 ?        S    Feb12   0:00 [kworker/u:1]
root        22  0.0  0.0      0     0 ?        S    Feb12   0:00 [xenwatch]
root        23  0.0  0.0      0     0 ?        S    Feb12   0:00 [xenbus]
root       149  0.0  0.0      0     0 ?        S    Feb12   0:04 [sync_supers]
root       151  0.0  0.0      0     0 ?        S    Feb12   0:00 [bdi-default]
root       153  0.0  0.0      0     0 ?        S<   Feb12   0:00 [kblockd]
root       163  0.0  0.0      0     0 ?        S<   Feb12   0:00 [md]
root       247  0.0  0.0      0     0 ?        S<   Feb12   0:00 [rpciod]
root       248  0.0  0.0      0     0 ?        S    Feb12   0:22 [kworker/0:1]
root       280  0.0  0.0      0     0 ?        S    Feb12   0:00 [kswapd0]
root       281  0.0  0.0      0     0 ?        SN   Feb12   0:00 [ksmd]
root       282  0.0  0.0      0     0 ?        S    Feb12   0:00 [fsnotify_mark]
root       286  0.0  0.0      0     0 ?        S    Feb12   0:00 [ecryptfs-kthr]
root       288  0.0  0.0      0     0 ?        S<   Feb12   0:00 [nfsiod]
root       291  0.0  0.0      0     0 ?        S    Feb12   0:00 [jfsIO]
root       292  0.0  0.0      0     0 ?        S    Feb12   0:00 [jfsCommit]
root       293  0.0  0.0      0     0 ?        S    Feb12   0:00 [jfsCommit]
root       294  0.0  0.0      0     0 ?        S    Feb12   0:00 [jfsCommit]
root       295  0.0  0.0      0     0 ?        S    Feb12   0:00 [jfsCommit]
root       296  0.0  0.0      0     0 ?        S    Feb12   0:00 [jfsSync]
root       297  0.0  0.0      0     0 ?        S<   Feb12   0:00 [xfs_mru_cache]
root       298  0.0  0.0      0     0 ?        S<   Feb12   0:00 [xfslogd]
root       299  0.0  0.0      0     0 ?        S<   Feb12   0:00 [xfsdatad]
root       300  0.0  0.0      0     0 ?        S<   Feb12   0:00 [xfsconvertd]
root       301  0.0  0.0      0     0 ?        S<   Feb12   0:00 [glock_workque]
root       302  0.0  0.0      0     0 ?        S<   Feb12   0:00 [delete_workqu]
root       303  0.0  0.0      0     0 ?        S<   Feb12   0:00 [gfs_recovery]
root       304  0.0  0.0      0     0 ?        S<   Feb12   0:00 [crypto]
root       866  0.0  0.0      0     0 ?        S    Feb12   0:00 [khvcd]
root       979  0.0  0.0      0     0 ?        S<   Feb12   0:00 [kpsmoused]
root       980  0.0  0.0      0     0 ?        S    Feb12   0:24 [kworker/2:1]
root      1006  0.0  0.0      0     0 ?        S    Feb12   0:35 [kworker/1:1]
root      1009  0.0  0.0      0     0 ?        S    Feb12   0:02 [kjournald]
root      1013  0.0  0.0      0     0 ?        S    Feb12   0:35 [kworker/3:1]
root      1034  0.0  0.1   2368   604 ?        S    Feb12   0:00 upstart-udev-br
root      1036  0.0  0.1   2236   560 ?        S<s  Feb12   0:00 udevd --daemon
root      1143  0.0  0.0   2232   288 ?        S<   Feb12   0:00 udevd --daemon
root      1145  0.0  0.0   2232   288 ?        S<   Feb12   0:00 udevd --daemon
syslog    1911  0.0  0.2  29460  1244 ?        Sl   Feb12   0:12 rsyslogd -c4
root      1929  0.0  0.1   2428   800 ?        Ss   Feb12   0:01 cron
root      1945  0.0  0.1   4760   656 ?        Ss   Feb12   0:00 nginx: master p
nginx     1947  0.0  0.2   5088  1432 ?        S    Feb12   0:00 nginx: worker p
root      1984  0.0  0.1   1840   556 hvc0     Ss+  Feb12   0:00 /sbin/getty -8
root      1995  0.0  0.1   2288   572 ?        Ss   Feb12   0:00 dhclient3 -e IF
root      2028  0.0  0.1   3600   916 ?        Ss   Feb12   0:00 /usr/sbin/ntpd
ntpd      2029  0.0  0.1   3496   928 ?        S    Feb12   0:02 /usr/sbin/ntpd
root      2037  0.0  0.4   5600  2124 ?        Ss   Feb12   0:22 /usr/sbin/sshd
root      3828  0.0  0.0      0     0 ?        S    Feb15   0:04 [flush-202:0]
root     16759  0.0  0.5   8408  2808 ?        Ss   16:07   0:00 sshd: root@pts/
root     16816  0.0  0.3   4628  1892 pts/3    Ss+  16:07   0:00 -bash
root     17688  0.0  0.5   8408  2808 ?        Ss   17:26   0:00 sshd: root@pts/
root     17745  0.0  0.3   4628  1892 pts/0    Ss   17:26   0:00 -bash
root     17768  0.0  0.5   8408  2812 ?        Ss   17:29   0:00 sshd: root@nott
root     17825  0.0  0.1   2052   784 ?        Ss   17:29   0:00 /usr/lib/openss
root     17832  0.0  0.2   2764  1052 pts/0    R+   17:31   0:00 ps aux


And ls -l /etc/nginx/sites-enabled/ gave:

Code:
total 0
lrwxrwxrwx 1 root root 34 2012-02-21 09:56 default -> /etc/nginx/sites-available/default
lrwxrwxrwx 1 root root 38 2012-02-21 10:22 doodleskull -> /etc/nginx/sites-available/doodleskull


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group