English (change)
Installing & configuring Nginx web server, tweaking the default file structure, then setting up a vhost file with symlink is the subject of this copy/paste how-to. So open up that CLI and I'll explain.
So we're ready to install a star attraction, Nginx (pronounced "engine-x"). But why? Isn't Apache the best web server?
Apache has served me well for years, both locally and on remote hosts, and is still a desirable choice for many large sites.
But, kinda like Ubuntu, FireFox and jQuery, there's a new kid in town, and it's leaner, simpler to configure and use, and faster to serve. Enter the Nginx web server.
In 20 copy/paste steps .. from zero to hero, blank box to cute-as Linux server.
Scroll down for the full series index.
So, hey, shed shared & viva virtual! Hope it helps. the_guv
Watch the, er, guvideo for a better idea of how to do this.
Check out the_guv's YouTube channel at http://youtube.com/guvnrDOTcom
...or if you can't be bothered with that, or even if you can, here's the detail...
I don't profess to be an expert, just someone who has researched ultra-thoroughly. I concentrated primarily on the two most popular, best established web servers, Apache and Lighttpd, and the young Turk alternative, Nginx, about which geekdom is all aflutter. Here's a summary of my key findings:-
I've been using this light-weight server for my resource-heavy WordPress blog, guvnr.com, and am impressed with its solid performance. Also importantly, it doesn't have that Windows-like tendency, an Apache affliction too, of wasting resources by running a bunch of services that I just don't need.
Don't take my word for it. You shouldn't, because I haven't performed any benchmark tests. Google something like Apache vs Nginx" or Nginx vs Lighttpd and have a read. And here's the Nginx wiki.
There are two ways to install software on Linux; using the integrated installation tools or from sourcecode.
Normally, we install internally, using something like the Linux installer 'aptitude', but because this is such an important component of our VPS, I'm going to show you how to install from source. This method takes a little longer, but it's worth it because we'll have a much more up-to-date version.
.. With a web server, we shouldn't cut corners. That would be like buying a yellow Ferrari.
First up, we need some dependency files:-
sudo aptitude -y install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
And to create a directory in which to store the Nginx package:-
mkdir ~/sources
Change to that directory:-
cd ~/sources/
Now we get the latest stable Nginx release, nginx-0.7.64 *.
* As of 20th January 2010, edited by the_guv. You should still check it is still the latest, here, and amend the filename accordingly:-
wget http://sysoev.ru/nginx/nginx-0.7.64.tar.gz
Unzip it:-
tar -zxvf nginx-0.7.64.tar.gz
Go into the new unzipped folder:-
cd nginx-0.7.64
Compile with two options; where to install it, and including 'ssl' (to enable 'https' for secure connections, ie shopping and stuff):-
./configure --sbin-path=/usr/local/sbin --with-http_ssl_module
Install this baby:-
make sudo make install
Kick it up:-
sudo /usr/local/sbin/nginx
And test it by popping your IP address in a web browser. You should see "Welcome to nginx!"
Now stop it:-
sudo kill `cat /usr/local/nginx/logs/nginx.pid`
This is important, for example, upon reboot. We need a script for this. Create a file:-
sudo nano /etc/init.d/nginx
And paste this within:-
#! /bin/sh
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/local/sbin/nginx
NAME=nginx
DESC=nginx
test -x $DAEMON || exit 0
# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
. /etc/default/nginx
fi
set -e
case "$1" in
start)
echo -n "Starting $DESC: "
start-stop-daemon --start --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
start-stop-daemon --stop --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;
restart|force-reload)
echo -n "Restarting $DESC: "
start-stop-daemon --stop --quiet --pidfile \
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON
sleep 1
start-stop-daemon --start --quiet --pidfile \
/usr/local/nginx/logs/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC configuration: "
start-stop-daemon --stop --signal HUP --quiet --pidfile /usr/local/nginx/logs/$NAME.pid \
--exec $DAEMON
echo "$NAME."
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
exit 1
;;
esac
exit 0
Then give the file permissions and make the script run on reboot, else start/stop/restart when required:-
sudo chmod +x /etc/init.d/nginx sudo /usr/sbin/update-rc.d -f nginx defaults
Now open the Nginx configuration file:-
sudo nano /usr/local/nginx/conf/nginx.conf
...and strip out all the content, delete the lot. CTRL-K is the easy way to do that, if you were wondering.
And replace with this:-
user www-data www-data;
worker_processes 4;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay off;
keepalive_timeout 5;
gzip on;
gzip_comp_level 2;
gzip_proxied any;
gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript;
include /usr/local/nginx/sites-enabled/*;
}
The Nginx file structure is pretty messy for multiple sites, so we'll sort that.
First, layout some new folders:-
sudo mkdir /usr/local/nginx/sites-available sudo mkdir /usr/local/nginx/sites-enabled
...the first is for our virtual host (vhost) files, the second for their corresponding symlinks which will be referenced by Nginx' config file.
You have one of each per domain, and one of each for the default settings.
The symlink, or symbolic link, references the web server to the virtual host file.
The vhost file is a configuration file. It tells the web server, for example, things like where the web files live or the kind of URI structure you want.
For now, we need a default vhost file, and that goes in the sites-available folder. So:-
sudo nano /usr/local/nginx/sites-available/default
Now paste this:-
server {
listen 80;
server_name localhost;
location / {
root html;
index index.php index.html index.htm;
}
# redirect server error pages to the static page /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html
{
root html;
}
}
And enable it with this symlink:-
sudo ln -s /usr/local/nginx/sites-available/default /usr/local/nginx/sites-enabled/default
Boot it up again:-
sudo /etc/init.d/nginx start
...and check for that "Welcome..." page again, using your IP in a web browser.
Splendid. All pretty. And pretty well organised.
So that's Nginx up and running.
In Part 12 of this series Set Up an Unmanaged VPS (4 Newbies) I'm taking a quick detour, setting up FileZilla so we've got a Secure FTP (SFTP) connection. That'll be handy to help demonstrate Part 13, when we create another folder structure, this time for our sites and blogs, and pop up a couple of test pages.
Then, in Part 13, I'll show you how to use Subversion to more easily install and upgrade platforms and their modules/plugins. I'll example the popular WordPress scenario - and while we're about it we'll sort out WordPress caching and friendly-URLs.
And then, this, that, the other. Cue index ..
Serve multi sites & blogs on a budget .. at the fastest possible speed .. with the least downtime .. in the most secure environment .. and future-proofed for easy admin.
That's what the VPS Bible is about, stepped out in simple copy & paste guides.
From high traffic WordPress blogs to startup web hosts, here's what you need.
Set it up? Click here for the 21 part follow-up .. V-P-S Admin
Install/Upgrade WORDPRESS with SUBVERSION - VPS Bible #15 - GUVNR June 9th, 2009 at 11:38 am
[...] Part 11: * Nginx (better than Apache) Web Server [...]
Configure NGINX Multi-Site Virtual Hosts - VPS Bible Pt 13 - GUVNR June 9th, 2009 at 11:38 am
[...] Part 11: * Nginx (better than Apache) Web Server [...]
mnyman June 10th, 2009 at 6:34 pm
This has been really amazing, so thanks a bunch.
For those of us who are completely new at this, I get a warning when I "boot it up again" that says:
Starting nginx: [warn]: duplicate MIME type "text/html" in /usr/local/nginx/conf/nginx.conf:21
Looking in the file, I couldn't find anything duplicating. Do you know why this would happen? Having errors like these explained is especially comforting when we don't fully understand what is going on. Thanks again for all your work on this.
the_guv June 10th, 2009 at 11:10 pm
Hi Mnyman,
Hmmn, sorry to say, looks like you've made a typo. Unless .. is there any discrepancy between what I have set down from the start to where you are, and what you have done?
Tell you what though .. click on Contact and send me an email with the content of nginx.conf, and I'll take a look.
crazeworthy June 23rd, 2009 at 10:13 am
The problem is with line 20, there is a carriage return which puts application/xml+rss text/javascript; in a separate line. That conflicts with the include mime.types;
Just make sure that is removed and I think it should go smoothly. This is a great write up guv!
Matt June 23rd, 2009 at 4:24 pm
Great series!
Wanted to let you know that the install step didn't work for me. Used instruction here: http://www.ubuntugeek.com/howto-install-nginx-webserver-in-ubuntu-804-hardy-heron.html and it worked.
I'm definitely not saying your wrong (I'm the definition of a newbie) but wanted to let you know.
Thanks for a great tutorial!
crazeworthy June 23rd, 2009 at 5:23 pm
Previous comment was incorrect see link below:
http://forum.slicehost.com/comments.php?DiscussionID=3763
the_guv June 25th, 2009 at 1:42 pm
@crazeworthy - pleased you sorted that. tx for the tx!
can be a bit fiddly though. pay attention m8!
@matt - aye, me likes the ubuntu geek. dunno what went wrong for you, this method sure worked in testing, twice or thrice
@all - 1 tip .. don't try to copy the code direct from the post .. there's an icon at the top right of each code box, next to the printer icon. Click on that, and then copy/paste from there.
All that said, damn, any probs, lemme know.
***
UPDATE, FIX! RE: Nginx Warning on Start/Restart. Sorry folks, there was a mistake in the nginx.conf file, which was throwing a Warning (not an error, but annoying all the same.)
If you really wanna know, I had a duplicate MIME type "text/html" in the conf .. duplicate because the GZIP engine GZIP-ed that MIME type anyway, so it wasn't needed to be repeated in the conf. Anyhow, sorted.
oligolli June 27th, 2009 at 11:18 pm
Thanks for all these tuts, really helped a newbie here.
I'm a bit stuck with the permissions on the /wp-content/uploads folder. I admit I didn't follow your tutorials to the letter, mainly because I am using Centos, but the Nginx user (www-data in your example) confuses me a little.
Should the Nginx user be the owner of the uploads folder or in the same "webmasters" group?
Samuel July 6th, 2009 at 4:29 pm
When trying to start nginx using sudo /etc/init.d/nginx start I get the following error:
Starting nginx: start-stop-daemon: --start needs --exec or --startas
Try `start-stop-daemon --help' for more information.
:'(
the_guv July 7th, 2009 at 5:12 am
@ollygolli .. really depends what you want to do, but probably I could have been clearer about permissions.
a simple scheme would be to add your username to nginx' www-data group, while owning the html_public directory and within. for that, do this:-
usermod -G www-data username
sudo chown -R username:www-data /home/public_html/
or if you've got a bunch of sites for different users, chown username:www-data within their public folders, recursively:-
sudo chown -R username:www-data /home/public_html/somedomain.com/public
@Samuel .. real sorry, can't replicate that error. have you followed the series, sounds like your setup is different somehow.
@Samuel .. CORRECTION. more sorry! was a new plugin playing havoc. sorted now. apologies all.
gordon yeong July 17th, 2009 at 1:39 pm
nah this still doesn't work even when i joined lines 21 and 20 into line 20.
#
#
crazeworthy June 23rd, 2009 at 10:13 am
The problem is with line 20, there is a carriage return which puts application/xml+rss text/javascript; in a separate line. That conflicts with the include mime.types;
Just make sure that is removed and I think it should go smoothly. This is a great write up guv!
the_guv July 19th, 2009 at 11:32 am
@Gordon .. probably nothing to do with carriage return. what's not working .. as much info as you can and I'll try to help you isolate the problem or, if you sorted the issue, let us know how.
@Crazeworthy .. tx for the tip .. carriage rtn removed.
Patrick August 26th, 2009 at 4:55 am
Hello The_Guv,
I have problems with wordpress mu and the rewrite rules for nginx
I tried a lot of different codes but anything is work.
http://mu.wordpress.org/forums/topic/3410
I was making the chances in sudo nano /usr/local/nginx/sites-available/default
My wordpress mu blog is in the root http://www.blognetwerk.net/blogs/
I hope you can help me.
the_guv August 26th, 2009 at 12:29 pm
@Patrick .. read the comments from Trav19 on Setup WordPress on NGINX (FURLs & Cache) - VPS Bible Pt 13 .. I've not had time to play properly with my MU install yet, but think Travis found the answer.
Let me know how you get on. In fact, print the rule! And if it doesn't work, let me know and I'll have a think.
Pierre September 2nd, 2009 at 10:23 am
If you are a programmer, have a look at the source code.
Nginx is simply clearer than others, better engineered and stronger. It is made by more experienced people than all the others I have seen.
In my humble opinion, that's a piece of Art (and I know one thing or two on the subject).
Pierre.
Wai Wong September 16th, 2009 at 6:01 am
Is there a proper way to update nginx? Initially I installed with Nginx 0.7.61, the latest is now Nginx 0.7.62. I want to make sure I don't mess anything up.
thanks,
the_guv September 16th, 2009 at 5:48 pm
@Pierre .. big cheers, Sir. That's quite a project you've got there with G-WAN, BTW. Dunno I can wean off PHP quite so easily tho
@Wai .. You've got a point .. it's a pretty complex procedure to sum up quickly, but very important to add .. I'll add a guide on how to upgrade next week .. that's a promise.
[edit]sorry Wai .. I broke the promise. Then again, I also busted my motherboard
I do have this on teh list though, for the VPS ADMIN series ..
Maintain Unmanaged VPS (4 Newbies) .. V-P-S Admin
.. along with some additions to the Bible's sequel. On the way ..[/edit]
the_guv September 24th, 2009 at 2:15 pm
IMPORTANT NGINX UPGRADE ANNOUNCEMENT
@everyone ..
.. bozo-here upgraded the Bible last week to reflect the latest Nginx stable release - 0.7.62 - then forgot to mention it.
Apologies for any confusion to those folks who wondered why the version had changed overnight, and what if anything that meant ..
Actually, the change did impact one thing. In the section Serve Multiple Sites & Blogs with Virtual Hosts, a fastCGI shared library file became obsolete, now replaced by another, but anyone installing from this guide would have been prompted about this newly recommended file .. I know because I've tested it, and have had confirmation from Zereshk who followed this guide and kindly nudged me to amend that post, which I have.
NOW FOR THE MOST IMPORTANT BIT
Future note: As Nginx or other key application stable releases are upgraded, I'll be amending the Bible accordingly, the changes tested each time. Also, for the record, and as has been rightly requested by one or two folks, I'll be adding a How to Upgrade Nginx Safely guide in the VPS Admin section, pretty shortly, so watch for that.
Cheers all.
Anonymous October 13th, 2009 at 5:05 am
I would like to point out that WordPress.com actually uses LiteSpeed for a backend. nginx is still the best lightweight frontend in my opinion.
the_guv October 13th, 2009 at 11:31 am
@anon .. thank you. I stand corrected, as is the post. I think this clears it up.
Intriguingly, stated in this post, "we are not using nginx as a web server currently, but may switch at some point."
WordPress uses Nginx, currently, for their load-balancing.
thanh November 4th, 2009 at 11:06 pm
how do you go about upgrading to newer versions of nginx?
JIm Davis November 11th, 2009 at 3:25 pm
I have been using your online tutorial ... all is going well with one exception. When I issue the n2r
nginx stops but does restart ... the following error message is issued instead (see below). Since I am newbie am not sure how to correct this problem.
permission denied when trying to open a error log file at "/user/local/nginx/logs/error.log" error 13
It has something to do with not having master privileges. FYI I did work through all of the preceeding tutorial including creating my user name and aliases.
Thank you for effort ... very good job
Jim
agus November 12th, 2009 at 2:54 am
Hey Guv,
Cant wait for your guide on upgrading Nginx... I really need to get rid of 502 bad gateway problem with my site (this happens when the site gets very busy, and when this happens I have to reboot my server)
I am not sure upgrading will fix it, since it is really fastCGI problem if I am correct...
thanks!
agus
the_guv November 12th, 2009 at 6:33 am
@thanh & @agus .. sure, this guide is overdue .. bear with me, I've got a lot on at the mo but this should be done by the end of the month.
thank you, everyone, for your patience .. the Bible's taken a lot longer, well, months and more months longer, than I'd anticipated.
.. then again, hopefully it's better, more detailed than ever, at least, than I thought it would be, and as I said in VPS Bible Reflects New Nginx/WordPress Versions, with Future Commitment, now it looks like I'll never really finish it, just keep upgrading and adding to it, whether focusing on Nginx or other web servers, and also considering other VPS solutions .. I've got a bug about proxying in particular and, hey Agus this may help you, I've got a plan to test and write about a fastCGI alternative pretty shortly.
And then, quite aside from VPS stuff, I wanna be writing more about Linux Desktop solutions, and basically to encourage people to ditch that passe sh1te that is Windows .. and that's what The 25-Part Ubuntu KARMIC KOALA BIBLE was about .. terribly populist I know, and yes I am a cynical populist (damn, I used to write for the BBC, how cynical is that place!) .. er, it worked .. I'm getting published in a massive online place on 20th this month and, that aside, traffic quadrupled overnight, which was like a shot in the arm.
.. And I wanna be writing more about making the most of the web, as opposed to just writing about making the web .. so stuff like how to Twitter effectively or into using some of the best Firefox addons for fun and productivity .. but also stuff like how to SEO (Google loves my SEO) and loads on WordPress .. plus a few laughs here and there. So that's quite a lot, huh, and that's just about this site!
Hey folks .. let me know .. throw me some feedback .. I know I'm gaining some loyal community out there, born largely out of this VPS Bible, and I don't want to turn my back on or somehow abuse that. This is my first blog, and its direction is still evolving, and I have a lot to learn.
And re the Nginx upgrade piece, bear with me, for sure it is about time done! Er, yeah, that was the point of this reply, huh .. got ranting a bit .. you should hear me watching the news ..
agus November 14th, 2009 at 3:42 am
Thanks Guv... your a good man!
eran November 16th, 2009 at 9:51 pm
Hi
Many thanks for the site
Eran
the_guv November 18th, 2009 at 11:33 am
@eran .. You're welcome, thanks for the thanks.
Dimitris November 30th, 2009 at 4:19 pm
I follow the tutorial on my Centos 64 server and i stuck there:
sudo /usr/sbin/update-rc.d -f nginx defaults
command not found
I try it also as i am root:
/usr/sbin/update-rc.d -f nginx defaults
but again the same error
the_guv December 7th, 2009 at 9:58 am
@Dimitris .. sure, this guide is for Debian Linux, using Ubuntu 8.04 LTS (Long Term Support)
Barrie December 29th, 2009 at 6:56 pm
I have the same problem as Samuel and I have done nothing with plugins plus I do not have a clue on what to do.
When trying to start nginx using sudo /etc/init.d/nginx start I get the following error:
Starting nginx: start-stop-daemon: --start needs --exec or --startas
Try `start-stop-daemon --help' for more information.
Barrie December 30th, 2009 at 5:20 pm
I sent this message in yesterday and it was on the list but today it has gone
Starting nginx: start-stop-daemon: --start needs --exec or --startas
Try `start-stop-daemon --help' for more information.
So I have done a complete re-install and when I have finished the install and go again to the start nginx it comes up starting nginx and when I put me IP in no connection and nothing else. When asked the first time I get the welcome screen but not he last time.
Just what can the problem be
Barrie January 3rd, 2010 at 1:51 pm
I got my problem sorted by trial and error so my Pt 11 is working. Now can I get the server working when I figure out how to connect to the WWW with just Pt 11 only, or do I need the whole thing. I am a complete novice as you will notice.
the_guv January 9th, 2010 at 6:59 pm
@Barrie .. apologies, was AWOL!
Pleased you got Nginx to restart on demand .. I think the earlier problem Samual had, and that you had, was due to me accidentally reactivating a plugin to this site that affected that code snippet .. apologies but sorted.
Of the guide, for the average VPS, the only tutorials you can afford to miss are the WordPress references here and there, the option for Subversion and tat of FileZilla.
agus January 10th, 2010 at 8:50 am
Hi Guv,
Is the nginx upgrade guide coming?
Anyway If you don't mind, can you make a guide on how to make fastcgi restarts automatically after failure... this will be great(especially in my situation where it does fail quite frequently)...
Thanks Guv...
eran January 10th, 2010 at 8:50 pm
Hi
Posts in forum say that nginx has problems with spawn-cgi.
lighty has memory leaks problems.
So, what should I choose?
Thanks
Chad January 11th, 2010 at 1:57 am
Hi,
I get to the point of "kicking it up" and simply get this:
sudo /etc/init.d/nginx start
/etc/init.d/nginx: 20: Include: not found
Starting nginx: [emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
[emerg]: still could not bind()
Tried going through the whole thing again, but no joy. Such a n00b!
eran January 11th, 2010 at 9:42 pm
try
service httpd stop
apache takes the port .
the_guv January 13th, 2010 at 9:15 am
@agus .. er, yes and yes!
m8 .. big announcement on the way
ALL VPS guides are undergoing a facelift, and there's more .. will post the detail later today.
@eran .. Nginx, of course! FastCGI sys used here works no problem. Dunno what agus has done, but feedback is overwhelmingly positive.
.. that said, see above note .. there will be tutorial updates v soon (within 2 weeks) and if you can wait I'll have maybe a slightly better setup.
(Have to say tho.. Lighty has improved that memory issue, I know, though not sure how much .. am planning on benchmarking the two, along with Cherokee and some others, but not for a couple months yet.)
agus January 14th, 2010 at 2:09 pm
Hello Guv,
Yea I have no idea why fastcgi keeps failing.... I am running a DRUPAL site that gets around 10,000 to 20,000 visitors a day....
I am no tech savvy, I don't know, maybe my site needs more memory, mysql optimization, fastcgi tweaking, or all the above...
I suspect slow mysql query, or php process that may cause server to go time out and kills fastcgi...
I am on linode 360 (the cheapest one), and I do think its a great little VPS
I wish you would have done all the guide for DRUPAL instead... I am so jealous.. lol
your guide for wordpress is amazing.... the pretty url, no trailing slash, they all work flawlessly with Wordpress, but not Drupal...
Thanks Guv! Have a good day....
the_guv January 14th, 2010 at 3:07 pm
@ agus ...
AHA!! Drupal .. yes, no, this caching method is not ideal for Drupal! Doesn't sit pretty with their architecture.
Look, I do know how to do this but will need a little time to set it out, and ... hmmn .. read on Agus ...
@ALL ... I'd like to draw your attention to the fact that this guide is going to relocate to my new site vpsBible.com, launching end January.
The reason for the move is basically to try to monetize this beast I seem to have created so that, in turn, I can spend the time required to properly support and radically expand it.
At vpsBible, the bible will expand this year with stuff like:-
- CentOS (I can hear the cheers!)
- finishing current then expanding the VPS Admin series .. upgrade Nginx, backup all that
- benchmarking Nginx against Cherokee, Lighty, Apache etc
- alternative guides to Nginx
- email servers
- proxifying your VPS, elite proxy setup
- rewriting this guide for Lucid Lynx 10.04 (out April - it's Long Term Support so the most important release since 8.04, which this guide uses)
- more video
- and just for Agus .. Drupal! Oh, and some stuff like MODx
This doesn't mean Guvnr's had its chips or anything like that, it's just gonna concentrate on non-VPS stuff, so lots of Linux desktop, savvy surfing, some web dev, rants from my pants, stuff like that.
If you've got some benefit from this Bible, don't be a stranger! Please check out ...
Guvnr.com & vpsBible.com - Focussing on 2010
... which gives all the detail for the 2 sites, and even recalls this story about a belly dancer I met in Arabia.
And please, leave comments about this change, good or bad .. let me know what you think, and don't pull any punches.
agus January 14th, 2010 at 6:25 pm
VPSBible.com... I can smell success already...
You got what it takes to make it better and bigger and monier... nothing can stop you...
The truth is linode, slicehost, prgmr, and all will be grateful to you for doing this.... I can see their tech support keep telling beginner clients to check out your vpsbible for guides
the_guv January 15th, 2010 at 11:38 am
big cheers Agus .. really appreciate that. I've got that Drupal guide on the list! It's not so tough a post, so will knock out early Feb, (you can hold me to that!)
Simon January 20th, 2010 at 1:56 pm
Thanks for a really great guide, I've followed it through from beginning to end and got my VPS up and running with nginx and WordPress in just 5 hours - and it's lightning fast!
Just one thing that worries me - when I use top (or htop) it is showing that my www-data processes are using over half of my 256Mb memory. This seems very high, because I have set up only one domain running WordPress with no plugins, and there is zero traffic (it's a test site only I know about). Do you have any suggestions? Maybe some config I need to do?
the_guv January 20th, 2010 at 7:59 pm
@Simon .. sounds pretty normal, no worries. I'll endeavor to write up a piece about efficient use of RAM, vs memory leak. .. That's on the to do list!
Simon January 20th, 2010 at 8:52 pm
thanks for the advice, i'll stop worrying then!
interestingly, i just did a test using loadimpact.com ramping up to 50 simultaneous users and the memory usage never went above 133mb - it was only cpu usage that went up (a lot!).
Jakes January 21st, 2010 at 5:52 am
HELP!!
Hi Guys,
I am going nuts here! I have been following the tuts(Thanks Olly). I have a uBuntu 9.10 setup behind a router(Port 80 forwarded to 192.x.x.x)I setup my own domain and connection docs etc. My issue is that when I type in the localhost in the browser, I get the default Nginx welcome response. I have played around with the server listener connection settings, but I cannot get it to respond to my domain doc.All the site docs are where they should be...
server {
listen 192.168.x.x:80 default_server;
server_name domain.com;
rewrite ^/(.*) http://www.lopologa.com/$1 permanent;
}
server {
listen 80;
server_name http://www.domain.com;
access_log /home/public_html/domain.com/log/access.log;
error_log /home/public_html/domain.com/log/error.log;
location / {
root /home/public_html/domain.com/public/;
index index.php index.html;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
location ~ \.php$
I have read that you can 'force a default server". But it is not responding. What am I missing?
Regards,
Jakes
PS I can also ping my domain name from this box
the_guv January 22nd, 2010 at 3:51 am
@ Simon .. big cheers for loadimpact.com, nice tip will try it. good to hear everything hunky-dory.
@ALL! .. have updated Bible to reflect latest stable versions of Nginx adn WordPress. Following the guide (religiously!) everything went without a hitch so, hey, no ruddy excuses
Detail:-
VPS Bible Updated with New Nginx/WordPress Versions
the_guv January 22nd, 2010 at 8:18 am
@Jakes .. that's not your vhost for real, no? i mean, lots of domain.com there.
.. and this is for a local setup, huh? just to confirm that .. if so, try editing your hosts file:-
sudo nano /etc/hosts
.. adding an entry like:-
127.0.0.1 lopolonga.com
.. that forces your machine to resolve a site in development.
That help?
Simon January 22nd, 2010 at 12:20 pm
just wondering if you have plans to write a guide for bbpress as part of the vpsbible? i'm having problems getting it to work on nginx - the forums work ok, i just can't access the admin area.
googled around but can't find a comprehensive guide to nginx rewrite rules or whatever else it is i might need to change...
the_guv January 22nd, 2010 at 6:15 pm
@Simon .. on the list! Did you want that standalone, or rather as a sub-domain?
(Just installed Simple:Press as the forum for vpsBible.com. Fits like a glove, installs as a WordPress plugin, superb functionality and shares user login/out. .. that may help someone. Also, check out WP plugin Members by Justin Tadlock.)
Simon January 25th, 2010 at 4:15 pm
standalone in a sub-directory, i.e. mydomain.com is my wordpress site, then mydomain.com/forum is bbpress.
thanks for the simplepress pointer, will check it out, although i was reluctant to run my forums as a wp plugin due to bigger overhead compared to running a dedicated forum app, but maybe the difference is not worth the extra hassle...
JAKES January 26th, 2010 at 7:52 am
Hi Guvnr,
In response:
No the domain name is lopologa.com Editing the host file did not resolve the issue either. It now appears that apache is answering the local host call. I did not install it, nor can I see the apache process running.
I have run out of ideas...I have spent a lot of time on this and not sure where to go from here... My domain is just not responding...
Any ideas?
Thanks guys
Jakes
the_guv January 26th, 2010 at 10:44 am
@Jakes .. hmmn, well, er, there's always the pub?!
Apache installs as a dependent, so that's not terribly far-fetched, but you have gone off-course somewhere.
It does sound like you've got in a pickle and, to be honest - and I know you don't wanna hear this - I think you should start over. I mean literally from re-installing the distro, scrapping your build. In the long term, looking on the bright side, you'll understand your server, and Linux, better.
.. Sounds like you'll end up with a cleaner build too. Second time round, running this guide should take you about 4-5 hours, and that's double/triple-checking each and every step.
JAKES January 26th, 2010 at 10:16 pm
Yes, I was afraid that it will come to this...
Anyway, thank you for feedback...
Great site Olly!
Johnny February 2nd, 2010 at 1:25 am
Regarding the upgrading of nginx, which as of today there is a new version 0.7.65, I simply wget the new version, ./configure (and options), make, sudo make install, and everything is just fine. It does not overwrite your configurations. Of course, make a backup of your /usr/local/nginx directory for good measure but to all whom were wondering... it should work very painlessly. Aloha.
Johnny February 2nd, 2010 at 1:52 am
After my last comment, I came across this article which shows how to upgrade without any downtime which would, of course, be wonderful and prudent.
http://www.softwareprojects.com/resources/programming/t-recompileupgrade-nginx-binary-with-no-down-time-1520.html
Aloha.
the_guv February 3rd, 2010 at 9:22 am
@Johnny .. yes, your method works but there is a wee tad of downtime.
I've so far got a method that allows for 20 seconds downtime but doesn't need a reboot, basically doing what you do .. will work on that, downtime is simply unnacceptable, huh .. it's all about the blessed PIDS .. ruddy process IDs .. there is a way .. will look at that method you suggest, thank you. .. think I'll have to hassle the Nginx wiki chaps 'bout this, my syntax is wrong.