Category Archives: Linux

Installing Nginx from source Ubuntu Server 9.10

0
Filed under Linux, Programming, Projects, Servers, Tech

Distro: Ubuntu 9.10 Server

First install the build-essential package

sudo apt-get install build-essential

Then download the source code, v. 0.7.63 was the current stable version as of writing this post.

wget http://sysoev.ru/nginx/nginx-0.7.63.tar.gz

Extract the source code

tar zxvf nginx-0.7.63.tar.gz

Enter the directory

cd nginx-0.7.63

Configure the build, I enabled the flv streaming and zip modules.

./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=www-data --group=www-data --with-http_flv_module --with-http_gzip_static_module --http-log-path=/var/log/nginx/access.log --http-proxy-temp-path=/var/tmp/nginx/proxy/

If you find that there are errors with the pcre and openssl packages run the following command to install the deps.

sudo apt-get install libssl-dev libpcre3-dev

Now compile the source code

make

Install the binaries

sudo make install

You are finished! I plan on covering how to setup nginx to serve static content and proxy php requests to apache.

Ubuntu 9.04 thoughts after one cup of coffee

0
Filed under Linux

Having Ubuntu 9.04 freshly installed I brewed a cup of hazelnut coffee, sat down, and played. After one cup of coffee I found that the newest Ubuntu version feels much faster then 8.10. This could have to do with the move to ext4, which I am using. The desktop ‘magic’ is also much more clean and does not get in my way. Did i mention my dell booted in ~9 seconds?

Great weekend

0
Filed under Cars, Linux, Servers

So far this weekend has been great! I solved my electrical issues with my Z06 and even installed all the parts I needed to. Also I switched frankkumro.com to a new host ( asmallorange ) and the speed difference is amazing :) I do have some tighter storage restrictions but until I get to 90% of the disk I wont worry about it.

Argh…hosting

0
Filed under Linux, Servers, Tech

Once again im noticing everytime that my sites are not available, and so are some clients. It might be time to switch hosts, although I don’t have time for that any time soon. I am really sick of playing these games…maybe its time for a VPS. It’s hard to justify it though due to minimal traffic on all the sites and cost :(

Dark Ubuntu Theme

0
Filed under Linux

While expirmenting with colors and themes on my VM today I actually created a theme I like. For a while I have wanted a darker theme, but never could find one I liked. This is a simple color change theme, nothing extra special, but I like it. The wallpaper was found while searching google, if you know the original author or link please let me know so I can give credit.

Screenshot of Desktop: http://files.frankkumro.com/Dark%20Blue%20Theme.jpg

Screenshot showing File Browser: http://files.frankkumro.com/Dark%20Blue%20Theme%20File%20Browser.png

Wallpaper URL: http://files.frankkumro.com/dark_ubuntu.jpg

Theme File Download: http://files.frankkumro.com/Dark%20Blue%202%20Theme.tar.gz

Ubuntu xcache

1
Filed under Linux, Servers

If you need to setup xcache for use in your nginx + php5 setup this tutorials will show you how.

Installation

  1. Update apt:
    sudo apt-get update
  2. Install xcache:
    sudo apt-get install php5-xcache

Configuration of xcache

  1. Edit the xcache config file:
    sudo vim /etc/php5/conf.d/xcache.ini

    and update the values for

    • xcache.size (set to desired memory size)
    • xcache.var_size (set to desired memory size)
    • xcache.cacher (set to On)
    • xcache.optimizer (set to On)

    If you don’t want admin access then set
    xcache.admin.auth = Off

Finishing Up

  1. Now that the configuration is complete we need to restart php:
    sudo /etc/init.d/init-fastcgi stop
    sudo /etc/init.d/init-fastcgi start
  2. Enjoy your xcached php goodness…

Ubuntu Nginx and PHP5

2
Filed under Linux, Servers

This post will go over the steps you need to get nginx running with php5. I am going to use a list to show the steps to take, please leave a comment if you see something that needs to be corrected or just want to leave feedback.

Installation

  1. Update apt:
    sudo apt-get update

  2. Install nginx:
    sudo apt-get install nginx


  3. Install php-cgi for use with mysql:
    sudo apt-get install php5-cgi php5-mysql


  4. We need a binary that comes with lighttpd to launch the php5 cgi:
    sudo apt-get install lighttpd


  5. Now remove lighttpd from startup since we will be using nginx:
    sudo update-rc.d -f lighttpd remove

Configuration of nginx,startup scripts,fastcgi

  1. Create a bash script that will spawn the php fcgi handlers:
    sudo vim /usr/bin/php-fastcgi


  2. and enter the following:

    #!/bin/bash
    /usr/bin/spawn-fcgi -a 127.0.0.1 -p 10005 -u www-data -g www-data -f /usr/bin/php-cgi

    Make sure to set www-data to the user and group that you want php running as.

  3. Make the script executable:
    sudo chmod +x /usr/bin/php-fastcgi


  4. Now lets at create an init script that will execute the above script on boot (this script is from a blog that I can’t remember the name of):
    sudo vim /etc/init.d/init-fastcgi

    and enter the following

    #!/bin/bash
    PHP_SCRIPT=/usr/bin/php-fastcgi
    RETVAL=0
    case "$1" in
    start)
    $PHP_SCRIPT
    RETVAL=$?
    ;;
    stop)
    killall -9 php-cgi
    RETVAL=$?
    ;;
    restart)
    killall -9 php-cgi
    $PHP_SCRIPT
    RETVAL=$?
    ;;
    *)
    echo "Usage: php-fastcgi {start|stop|restart}"
    exit 1
    ;;
    esac
    exit $RETVAL


  5. Make the script executable:
    sudo chmod +x /etc/init.d/init-fastcgi


  6. Add the script to run at bootup:
    sudo update-rc.d init-fastcgi defaults


  7. Now we will begin configuring nginx to proxy php request. First we need to setup a include file that will hold some fastcgi_param’s.
    sudo vim /etc/nginx/fastcgi.conf

    and enter

    #fastcgi.conf
    fastcgi_param GATEWAY_INTERFACE CGI/1.1;
    fastcgi_param SERVER_SOFTWARE nginx;
    fastcgi_param QUERY_STRING $query_string;
    fastcgi_param REQUEST_METHOD $request_method;
    fastcgi_param CONTENT_TYPE $content_type;
    fastcgi_param CONTENT_LENGTH $content_length;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

    #To use Nginx + Virtual Host + PHP you should ommit the SCRIPT_NAME
    #variable in order for PHP to choose the correct DOCUMENT_ROOT
    #fastcgi_param SCRIPT_NAME $fastcgi_script_name;

    fastcgi_param REQUEST_URI $request_uri;
    fastcgi_param DOCUMENT_URI $document_uri;
    fastcgi_param DOCUMENT_ROOT $document_root;
    fastcgi_param SERVER_PROTOCOL $server_protocol;
    fastcgi_param REMOTE_ADDR $remote_addr;
    fastcgi_param REMOTE_PORT $remote_port;
    fastcgi_param SERVER_ADDR $server_addr;
    fastcgi_param SERVER_PORT $server_port;
    fastcgi_param SERVER_NAME $server_name;
    # PHP only, required if PHP was built with --enable-force-cgi-redirect
    #fastcgi_param REDIRECT_STATUS 200;


  8. Edit the server conf and tell it where to proxy requests to:
    sudo vim /etc/nginx/sites-enabled/default


  9. In the server section add the following:

    location ~ .*\.php$ {
    include /etc/nginx/fastcgi.conf;
    fastcgi_pass 127.0.0.1:10005;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME /home/xxx/public_html/domian/public/$fastcgi_script_name;
    }

    *Update SCRIPT_FILENAME to point to your doc root*

  10. Update index list to enable index.php: *Thanks Brian*

    index index.html index.htm index.php;


  11. Restart nginx and start the php cgi handlers:

    sudo /etc/init.d/nginx restart
    sudo /etc/init.d/init-fastcgi start