Articles RSS Feed

32MB.ORG

A blog running on 32 MB VPS
Category How To has 5 Posts

Quick VPS Configuration with Minstall

Posted April 2, 2013, 2:12 pm in How To
In need of an automated script for bootstraping your freshly installed VPS? Have a look at Minstall. Minstall is an easy configuration script to remove unwanted process from your VPS, it's a bash script written by a nice guy from KnightSwarm named Maxexlcoo. I've been using this script to configure some of my recent servers. It has NGINX, MySQL, Exim, and PHP bundled.

Backup 32MB.ORG to Dropbox

Posted July 18, 2012, 1:25 am in How To
There are lots of backup method out there, one of my fav is backup my VPS to a free storage service from Dropbox. I'm using a script from Dave Hope, based on another script from Andrea Fabrizi. Run it as root, or you can automate it using Crontab. It looks like I have something to report about using pre tag here, meanwhile you can download the script here.

Save the script as DropboxBackup.sh chmod +x and run it as root. If you want to automate it, create new Crontab as follow:

$ crontab -e
# m h  dom mon dow   command
0 0 1 * *       /bin/bash /path/to/DropboxBackup.sh
That will auto backup-ing your specified folder once in a month.

Building 32MB.ORG Pt. 3: Setting Up Virtual Host for Your Domain

Posted July 13, 2012, 1:05 pm in How To

Now we have a working web server with PHP-CGI and SQLite installed, and it's running pretty well with less than 20 MB RAM used. Don't know how to squeeze more RAM usage, but I think less than 32 MB is enough. We need to add a domain, so we can have a fully working blog. I don't think DNS server will fit this VPS, so I'm using another VPS as my DNS server and point the A record to my IP. Lighttpd supports both Name-based and IP-based virtual hosts. Here's how I add a virtual host to Lighttpd:

1. After login to your VPS and becoming root, create a directory for your domain. I'm using 32mb.org for example, so I created 32mb.

mkdir -p /home/lighttpd/32mb
mkdir -p /home/lighttpd/32mb/public
2. Setup a public directory owner to web server user, lighttpd or www-data.
chown lighttpd:lighttpd /home/lighttpd/32mb/public
3. In case you forgot, allow a web server user to access our logs.
chown -R lighttpd:lighttpd /var/log/lighttpd
4. Open Lighttpd Configuration file.
nano /etc/lighttpd/lighttpd.conf
5. Add support for your domain, put it at the end of the file.
$HTTP["host"] =~ "(^|\.)32mb\.org$" {
server.document-root = "/home/lighttpd/32mb/public"
accesslog.filename = "/var/log/lighttpd/32mb/access.log"
server.error-handler-404 = "/e404.php"
}
That's means:
  • $HTTP["host"] =~ "(^|\.)32mb\.org$" - It will match request for both www.32mb.org and 32mb.org
  • server.document-root = "/home/lighttpd/32mb/public" - Server document root. You must set ftp/ssh user home directory to this root only
  • accesslog.filename = "/var/log/lighttpd/32mb/access.log" - Server error log file
  • server.error-handler-404 = "/e404.php" - Web server error 404 handler file
6. Restart your web server.
/etc/init.d/lighttpd restart
7. Remember to point your domain A record to your VPS IP. Test. 8. Done. Now we have a fully working domain pointed to our VPS.

Building 32MB.ORG Pt. 2: Installing Lighttpd, SQLite, and PHP

Posted July 1, 2012, 8:26 am in How To
For Blite! to works, I need a web server, PHP, and SQLite. Choose Lighttpd (Lighty) for web server software, PHP 5.3 with CGI, SQLite ext. and Xmlprc so I can use Blogspam.net for spam protection. The "pstree" result look like this:
andri@32mb:~$ pstree
init-+-cron
     |-dropbear---dropbear---sh---pstree
     |-kthreadd/708---khelper/708
     |-lighttpd---php5-cgi---4*[php5-cgi]
     `-sendmail-mta
After preparing my new box, next step is installing SQLite:
apt-get install sqlite
then Lighttpd:
apt-get install lighttpd
install the PHP scripting language and its supporting files:
apt-get install php5-cgi php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
edit the php.ini file:
nano /etc/php5/cgi/php.ini
scroll down through the text of the php.ini file until you come to a line beginning with cgi.fix_pathinfo (use ctrl+w for search), uncomment the line so it look like this:
; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  $
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not $
; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.  Se$
; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A sett$
; of zero causes PHP to behave as before.  Default is 1.  You should fix your s$
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://php.net/cgi.fix-pathinfo
cgi.fix_pathinfo = 1
Next step is add a user to the system which the Lighttpd server can use. This is performed as a standard UNIX useradd procedure as follows:
useradd -d /home/lighttpd -m -s /bin/bash lighttpd
now, open the lighttpd.conf configuration file:
nano /etc/lighttpd/lighttpd.conf
Add mod_fastcgi and uncomment mod_rewrite in case we need it. File will look like this:
server.modules = (
        "mod_access",
        "mod_alias",
        "mod_compress",
        "mod_redirect",
        "mod_rewrite",
        "mod_fastcgi",
)

server.document-root        = "/var/www"
server.upload-dirs          = ( "/var/cache/lighttpd/uploads" )
server.errorlog             = "/var/log/lighttpd/error.log"
server.pid-file             = "/var/run/lighttpd.pid"
server.username             = "lighttpd"
server.groupname            = "lighttpd"

index-file.names            = ( "index.php", "index.html",
                                "index.htm", "default.htm",
                               " index.lighttpd.html" )

url.access-deny             = ( "~", ".inc" )

static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" )

include_shell "/usr/share/lighttpd/use-ipv6.pl"

dir-listing.encoding        = "utf-8"
server.dir-listing          = "enable"

compress.cache-dir          = "/var/cache/lighttpd/compress/"
compress.filetype           = ( "application/x-javascript", "text/css", "text/html", "text/plain" )

include_shell "/usr/share/lighttpd/create-mime.assign.pl"
include_shell "/usr/share/lighttpd/include-conf-enabled.pl"

fastcgi.server = ( ".php" => ((
"bin-path" => "/usr/bin/php5-cgi",
"socket" => "/tmp/php.socket",
"max-procs" => 1,
"bin-environment" => (
"PHP_FCGI_CHILDREN" => "4",
"PHP_FCGI_MAX_REQUESTS" => "1000"
),
)))
Save ctrl+o and close ctrl+x, and then change the lighttpd log folder owner to lighttpd:
chown -R lighttpd:lighttpd /var/log/lighttpd
check if Lighttpd process with pidof lighttpd, if a number, or series of numbers show up, then it means Lighttpd is currently running. In this case, restart Lighttpd for the new configurations to take effect:
/etc/init.d/lighttpd restart
If Lighttpd isn't running already, start it by entering the following:
/etc/init.d/lighttpd start
point your browser to your VPS IP, see if its working.

That should be it, now we need a working domain for our blog id. Will talk about it on the next post.

Building 32MB.ORG Pt. 1: Preparing the Box

Posted July 1, 2012, 2:27 am in How To
IPXCore doesn't provide a Debian 6 minimal install on their SolusVM control panel. So, I have to remove several process that considered "not-needed". After updating and upgrading, apt-get update && apt-get -y upgrade and installing Nano, Localpurge and Dropbear apt-get -y install nano localepurge dropbear I removed following process:
/etc/init.d/saslauthd stop
/etc/init.d/apache2 stop
/etc/init.d/xinetd stop
/etc/init.d/samba stop
/etc/init.d/bind9 stop
/etc/init.d/ssh stop
and prevent them to run on restart/start-up:
update-rc.d saslauthd remove
update-rc.d apache2 remove
update-rc.d xinetd remove
update-rc.d samba remove
update-rc.d bind9 remove
update-rc.d ssh remove 
Start Dropbear as a replacement for OpenSSH, make it running by default by changing its config:
nano /etc/default/dropbear
set NO_START=1 to NO_START=0 and add some config for security, change the port and prevent root login:
# disabled because OpenSSH is installed change to NO_START=0 to enable Dropbear
NO_START=1 ;change to 0 

# the TCP port that Dropbear listens on
DROPBEAR_PORT=22 ;change to whatever port you want

# any additional arguments for Dropbear
DROPBEAR_EXTRA_ARGS="" ;add -w to prevent root login
You can also replace Syslog by Syslog-ng:
/etc/init.d/syslog stop
update-rc.d syslog remove
apt-get install -y syslog-ng

After reboot you will have a box running by (not more than) 10MB RAM. Done for now, next post will be installing Lighttpd, PHP, and SQLite, and then Blite! itself.

Source