Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm a bit of a noob on setting up web servers, but I want to do it right. I'm using Ubuntu Server 10.04 LTS on a VPS and it's currently a fresh install, with a root user setup and SSH enabled. Aside from that, it's fresh.

I'm looking to set it up as a webserver for a website project I'm doing. I'm needing to install such things as Nginx, FastCGI, PHP5, MySQL, etc. But I need some help on trying to set it up in the proper way. Though I'm mainly talking about Nginx here, it's just the example... When I can be settled on where to put the stuff properly, I can then use the same formula for any other software I install.

I've read all about FHS and have looked at detail at how it explains what the different folders are for, but I want to make sure.

Say I'm compiling Nginx... There is options for where to install the actual program, where to put the configuration file, where to put the log files and where to the PID file etc. My current thoughts are this:

Nginx itself: /opt/nginx/ Nginx configuration file: /etc/nginx/ Nginx log files: /var/log/nginx/ Nginx PID: /var/run/

Does this sound right? Any other thoughts? Thanks

share|improve this question
Is there a reason you're compiling rather than using the package? – Matthew Flaschen Aug 8 '10 at 8:29
@matthew-flaschen For alot of things to be installed on this server, I will be using a package manager, but for Nginx I need to install it from the source as it is the latest version. The packaged one is very old (relatively speaking). – littlejim84 Aug 8 '10 at 10:06
He's compiling nginx for the dev version, although it seems he is unaware of the ubuntu ppa system. – chiggsy Aug 8 '10 at 10:36
@Chiggsy I've looked up the PPA system. Though I'm not totally sure of what it is, I'm curious to know what I ask generally for compiling software (in regards to where to correctly put things) as there is bound to be software in the future that will need compiling and knowing where to put things correctly will only give me more knowledge and help me in the future. Thanks for the suggestion. – littlejim84 Aug 8 '10 at 10:58
PPA == personal package archive. It's a way to build your own debian style package for a piece of software, and have it installed like any other. Nice touch because you can get the newest updates ( and bugs/bugfixes). – chiggsy Aug 8 '10 at 11:14
up vote 3 down vote accepted

Right, a more formal answer:

Don't start guessing on a ubuntu/debian system where to put things. Ubuntu has pretty up to date versions, and aptitude is a very good package manager. You really want your server to have the following traits:

  • To be secure
  • To be well organized, so that you know where things should be
  • To have a repeatable configuration, by some method. ( This is why I am big on the packages. Even without puppet, you can get a list of packages that are installed, and in an emergency just install that list and you are back to where you were, if you were hacked for example )

For Nginx, here is a how I get an updated package quite soon after they come out:

You mentioned that you were new. Use the package managers. In your case, aptitude. We used to build from source all the time, but since you did not mention 'firewall' or 'security' then time is short.

Software that you install locally to a system goes in /usr/local. /usr is owned by the package managers really.

As for /opt, I use it for really weird stuff, like macports on my laptop or things I'm trying out, like coldfusion server ...

Default nginx goes into /usr/local/nginx , which is very good since if you build from source , make uninstall ... most likely wont be there. is a really good basic resource. Read that too.

Once the reality of app dev with simultaneous server admin sinks in, you might want to check out and get hooked up with puppet. That's for later

The nginx I told you about has the following options:

nginx -V
nginx version: nginx/0.8.48
TLS SNI support enabled
configure arguments: --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --lock-path=/var/lock/nginx.lock --pid-path=/var/run/ --with-debug --with-http_dav_module --with-http_flv_module --with-http_geoip_module --with-http_gzip_static_module --with-http_image_filter_module --with-http_realip_module --with-http_stub_status_module --with-http_ssl_module --with-http_sub_module --with-http_xslt_module --with-ipv6 --with-sha1=/usr/include/openssl --with-md5=/usr/include/openssl --with-mail --with-mail_ssl_module --add-module=/build/buildd/nginx-0.8.48/modules/nginx-upstream-fair

Now, later in life you might want to recompile for some other modules. ( /usr/local ) ! But regardless, you'll see the debian/ubuntu way of laying this stuff out. at least. A beloved trick i use is to install some server I need to build and copy the base config files, then purge it.

Good luck. BTW create a user for yourself, research sudo, and disable root logins. First thing I do on a fresh server.

share|improve this answer
Thank you Chiggsy. Great answer and has pointed me to a few things I wasn't aware of. Thanks! – littlejim84 Aug 10 '10 at 7:32

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.