Status
Not open for further replies.

William Palmer

Banned
Banned
165
2009
0
0
FUCK APACHE AND GET THE REAL SHIT
_________________________________________________________________

So over the past couple of days ive been playing around with web servers and from my point of this webserver i will teach you how to install today is BY Far better then apache or lighttpd


Apache - uses to much shit that is loading unwanted services
Lighttpd- waste way to much ram aka leaks it

we will be installing Nginx

Why?

well i have find out that
it is by far the best uses less resources and its way faster

You can install these on
Debian, emerge on Gentoo, ports on FreeBSD , and windows

By via Apt-get usually

i will be installing it on ubuntu as thats what i have as my second os on my pc

We will be installing from source


First install these dependency files

Code:
sudo aptitude -y install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev


Create a directory to store Nginx

Code:
mkdir ~/sources

Change to that directory

Code:
cd ~/sources/


Now we need to download it

Code:
wget http://sysoev*****nginx/nginx-0.7.64.tar.gz

Code:
tar -zxvf nginx-0.7.64.tar.gz

then go into the folder

Code:
cd nginx-0.7.64

and there you go now moving onto the building blahblah blah blah blah shit

_________________________________________________________________

We will compile it telling it where to install and to include SSL

Code:
./configure --sbin-path=/usr/local/sbin --with-http_ssl_module

now its time to install it

Code:
make
sudo make install

And start it up

Code:
sudo /usr/local/sbin/nginx

Now test it up go into your internet and type in your ip address you should see welcome

moving on

Now were going to stop it

Code:
sudo kill `cat /usr/local/nginx/logs/nginx.pid`

whola now its installed

__________________________________________________________________


Now its time to make it start up restart or stop when needed

So now lets create a file

Code:
sudo nano /etc/init.d/nginx

and paste this

Code:
#! /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

Code:
sudo chmod +x /etc/init.d/nginx
sudo /usr/sbin/update-rc.d -f nginx defaults



now its time to edit the .conf

Code:
sudo nano /usr/local/nginx/conf/nginx.conf

Delete the content best way to do it is CTRL-K

and put this in there
Code:
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/*;

____________________________________________________________________________


now its time to create the Virtual Host File and symlinks
The Nginx file structure is fucked up for sites so we need to fix that

First we need to make some new folders

Code:
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 is their
corresponding symlinks which will be referenced by Nginx' config file.


What are VHOST and sysmlinks?

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.




so now we need a default vhost file, and that goes in the sites-available folder

Code:
sudo nano /usr/local/nginx/sites-available/default

and paste this

Code:
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 symlink

Code:
sudo ln -s /usr/local/nginx/sites-available/default /usr/local/nginx/sites-enabled/default

now its time to boot up

Code:
sudo /etc/init.d/nginx start


and there you have it
 
18 comments
i like this tut, very in depth and you know if william palmer posted it, its a good idea to follow >.<

cheers
dotty
 
Well thanks DOT im no longer going to use apache i realized apache uses way to much shit that is not needed and its pathetic not to mention they heavy 0Day exploits out for it
 
yea true but cant you configure it to only use what you need. I havent gone far through it yet but from what I have done everything is customizable.
 
Well it all depends on what you want to do u can do this right here

Code:
./configure \
  --prefix=/usr \
  --sbin-path=/usr/sbin/nginx \
  --conf-path=/etc/nginx/nginx.conf \
  --error-log-path=/var/log/nginx/error.log \
  --pid-path=/var/run/nginx/nginx.pid  \
  --lock-path=/var/lock/nginx.lock \
  --user=nginx \
  --group=nginx \
  --with-http_ssl_module \
  --with-http_flv_module \
  --with-http_gzip_static_module \
  --http-log-path=/var/log/nginx/access.log \
  --http-client-body-temp-path=/var/tmp/nginx/client/ \
  --http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/
There is also loads of addons for you as well
 
Of course its been out longer every hosting company uses this why not use something most ppl dont know about? hell i would + it would be funny if some one did try to exploit a apache exploit against Ngnix lol
 
nginx is my fav :D
but it will be dificult to get some help regarding some advanced configuration due to lack of big community like apache..
 
Good for you william, you're the first person to not choose Litespeed (pointless cracking somethin when two other apps exist which run much much faster).

Going back to your original post though, LightTPD has been used on most servers I own or owned without problems, even under extreme load or special situations (such as a site which generates downloads on-the-go).

I've never had a single memory issue with it. So either it doesn't like your system, you didn't try it or you just set it up wrong.

Either way though, nginx is equally as good. Each have their own benefits, neither is better than the other.
 
Status
Not open for further replies.
Back
Top