Debian Nginx 0.7/PHP 5.3/MySQL 5.1 Install Guide

This script is based of 21Andy’s work, and Lowendbox’s work.

Please note that this script has been deprecated in favor of Xeoncross’s updated Lowendscript. This post remains here just for historical purposes.

Link: https://github.com/Xeoncross/lowendscript

The main differences compared to Andy’s and Lowendbox’s work are:
PHP 5.3 vs 5.2
Nginx 0.7 vs 0.6
MySQL 5.1 vs 5.0
Cleaner repos (for those Debian templates with broken repositories)

To run this script, enter in:

wget http://www.putdispenserhere.com/wp-content/uploads/setup-cheap-debian.sh
bash setup-cheap-debian.sh

Afterward, run this to setup WordPress:

bash setup-debian.sh wordpress blog.example.com

Make sure you change blog.example.com to match your domain.

Script source:

#!/bin/bash

mv /etc/apt/sources.list /etc/apt/sources.list.backup

cat > /etc/apt/sources.list <<END
#############################################################
################### OFFICIAL DEBIAN REPOS ###################
#############################################################

###### Debian Main Repos
deb http://ftp.us.debian.org/debian/ lenny main contrib non-free 

###### Debian Update Repos
deb http://security.debian.org/ lenny/updates main contrib non-free 
deb http://ftp.us.debian.org/debian/ lenny-proposed-updates main contrib non-free 
deb http://volatile.debian.org/debian-volatile lenny/volatile main contrib non-free 

##############################################################
##################### UNOFFICIAL  REPOS ######################
##############################################################

###### 3rd Party Binary Repos
#### DotDeb Backports - http://www.backports.org
deb http://packages.dotdeb.org oldstable all
deb-src http://packages.dotdeb.org oldstable all
deb http://php53.dotdeb.org oldstable all
deb-src http://php53.dotdeb.org oldstable all
END

wget http://www.dotdeb.org/dotdeb.gpg
cat dotdeb.gpg | apt-key add -
apt-get update

apt-get upgrade

#wget --no-check-certificate https://github.com/lowendbox/lowendscript/raw/master/setup-debian.sh

wget http://dl.dropbox.com/u/1120738/setup-debian.sh

bash setup-debian.sh system

bash setup-debian.sh exim4

bash setup-debian.sh mysql

bash setup-debian.sh nginx

bash setup-debian.sh php

cat > ./restart.sh <<END
#!/bin/bash
invoke-rc.d nginx restart
invoke-rc.d php-cgi restart
invoke-rc.d mysql restart
END

invoke-rc.d nginx stop

cat > /etc/apt/preferences <<END
Package: nginx
Pin: release a=lenny-backports
Pin-Priority: 990
END

cat >> /etc/apt/sources.list <<END
deb http://backports.debian.org/debian-backports lenny-backports main
END

apt-get update

apt-get -t lenny-backports -y --force-yes install "nginx"

bash ./restart.sh

apt-get update

apt-get -y install unattended-upgrades

cat > /etc/apt/apt.conf.d/10periodic <<END
APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";
END

echo 'Install complete'
Bookmark the permalink.
  • frostzire

    thanks

  • sandoz

    theres no directory for the default website, /var/www

  • admin

    Are you installing on Ubuntu? If not, then use mkdir -p /var/www

  • tom

    I haven’t run the script yet. I am running lighttpd on my VPS currently, but I will be interested to run Nginx in the future.

    Could you tell me if this script do the following? I am completely new to Nginx.

    1. enable url rewrite to have better looking urls? (judging from your blog, it seems to be the case)
    2. how about multiple domains on a single IP? Particularly, can http://www.putdispenserhere.com and putdispenserhere.com be directly to the same IP?

    • admin

      This script will first clean up your system (no more apache, bind, named, etc). It will replace OpenSSH with Dropbear, it will replace sendmail with exim4 and the syslogger to save ram.

      Next it will download and install mysql, configure it, and install exim4. Then it will download and install php5. Next it will download and install nginx. Finally you can run the wordpress setup (please note that it may be glitchy). I will have a new version of the script coming soon.

      1. Url rewriting is automatically enabled.
      2. Just run the wordpress setup to create more virtual hosts. You can set your DNS A records (both www and @) to your VPS IP. This is separate from Nginx although you can add and remove www. from the url automatically.

      • tom

        Thank you. I am looking forward to your new script, and I will definitely try Nginx to see how it is different from Lighty.

        Are there any reasons you chose Nginx over Lightty?

        • admin

          I am (more) familiar with Nginx and Apache, I haven’t tried lighttpd because of the lack of development. Secondly, it apparently doesn’t scale so well with small files, and third, Lowendbox and a setup script (which mine is based on) for Nginx that got everything working so I could tinker and learn. Fourth is that Nginx has a good following and it is quite well documented.

  • tom

    lines in 5, 79 of the script have the direction character (>) garbled. Maybe you want to change them.

    By the way, do you have a twitter account so that I can follow? I once put on google ads on my blog, but I feel it won’t worth it, and I just noticed your ‘ad-free’ proclamation.

    • admin

      Thanks for catching the error. It was just a display error, it doesn’t affect the script.

      I just have a personal twitter account that I follow tech news with. The reason I don’t use google ads is because I have about 20-50 visitors daily, and I hate seeing ads myself (I install adblock + firefox on any computer I can)

      • tom

        When do you plan to release your new script?

      • tom

        Which VPS are you using? How much do you pay for it?

        • admin

          The VPS powering this site is hosted with 123systems under the $21/year plan. It has 256MB RAM/512MB burst, 2 Core access, and is located in Chicago.

          I plan to release the updated script in a week or two hopefully. It will have php-fpm, and nginx 1.0.2 set up.

          • tom

            The price for 123system is good for its specs. Do you think if it is trustworthy? Any risks of overselling or frequent downtime?

            My current VPS expires in two weeks and I hope to migrate to a different one, hopefully setup it up with your new script.

  • admin

    The Chicago node has performed better than Dallas node for me in the past. Unfortunately the support for adding new templates is not very good (took a long time for Debian 6) and the $21/year offer is not available anymore. I think Semoweb’s offer is a better choice for $30/year at Lowendbox.

    • tom

      If it is possible, can you install “Comment Reply Notification” plugin? I will get notified whenever you post a reply.

      I have never used Openvz before, because I suspect they then to oversell. Current I am running 3 low-traffic blogs on a 256MB Xen box.

      Could share some experience on using Openvz? In specific, how to find a good and cheap Openvz VPS? By the way, what do you think of this VPS?

      http://www.lowendbox.com/blog/vazapi-openvz-san-jose-chicago/

      • admin

        I have rebuilt my blog DB (it was from 2.9 and somewhat buggy) and installed Disqus now. I’ve been planning both of these for a while now, just need a catalyst (and 5 hours of time :D ). The thing is, overselling isn’t necessarily bad. Overloading is bad. Overselling when managed properly doesn’t affect anyone negatively. I was tempted to go with the Vazapi offer, but it turns out that they are still in the bug fixing phase (apparently the I/O is quite low at 10MB/s.) This was the same when I signed up for Hostrail. Now their nodes are much faster with I/O (40-50MB/s).

        BuyVM has been a great provider, and Quickweb has some affordable boxes also (check their WHT thread).

        • tom

          BuyVM is forever sold out/out of stock and Quickweb is a bit expensive right now. Can you recommend one or two trust-worthy VPS? Thank you.

          • Anonymous

            You can buy 123systems VPS in Chicago ($25/year for 256mb/512mb burst 2 core with 10gb hdd) or Semoweb in Dallas ($30/year for 256mb/786mb burst 4 core with 15gb hdd)

  • tom

    By the way, when are you going to update this installation script, so that I can use it on my new vps. ;-)

    • Anonymous

      Sorry about that. I did the pptp install script as people were getting confused on LET board. I’ll get it done hopefully by this weekend. It will be great!

  • tom

    I have a question for this script:  what is the password for mysql? where can I set it?

    • Anonymous

      The password is in the directory where you downloaded the script (most likely /root) and it’s in the file “my.cnf”

  • tom

    I tried this script on my 123system vps. All works fine except when it comes to install a PHP-based application (ecshop), and I receive this warning and couldn’t continue with the installation:

    Warning: date_default_timezone_get(): It is not safe to rely on the system’s timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.
    I tried to modify php.ini but with no avail.

    Then I reinstalled the whole OS with Debian 5.0, and manually installed PHP5 packages and lighttpd, and the installation works fine. Do you have any idea why this error occurs? Is it related to PHP5 versions?

    I will wait to try your new script.

    By the way, I am happy with 123systems and thank you for your recommendation.

  • tom

    please ignore my previous comment. The problem is solved after I consulted the BBS of ecshop. Looking forward to an upgraded version of this script. Thank you for your help.

  • tom

    Could you help with setting up phpmyadmin? I tried but with no success with tutorials such as:

    http://joneslee85.wordpress.com/2010/02/28/howto-nginx-php5-mysql-phpmyadmin-ubuntu-shortest-setup/

    http://forum.slicehost.com/comments.php?DiscussionID=1519#Item_5

    I know you are not using phpmyadmin. Jut wonder if you have the time to look into the problem.

    • Anonymous

      I am currently using phpmyadmin with no problems. I add the phpmyadmin folder to the root of my blog and login with the details in the my.cnf file. Version 3.4.1 works without any problems other than the max upload size.

      • tom

        I ln -s the /usr/share/phpmyadmin to the root folder of my site, and it worked too.  I didn’t expect it was so simple and I messed with nginx server configuration for a few hours. Thank you again. It seems all is worked out so far.