Thursday, November 29, 2007
My OpenVZ server isn't useful now as my slice at Slicehost is up and running and I think LAMP is my comfort zone. I have not managed to get LEMP running after all.
There are more optimization and tweaking I have to learn about Apache, MySQL and PHP so I'll stay with my 256slice for the moment.
Wednesday, November 28, 2007
apache2ctl configtestI have just
Syntax OKand nothing else. I'm so happy.
The key is the site files in
/etc/apache2/sites-enabled/, a typical one should look like this
of course with other directives as required.
I have also appended below line to
my.own.ip.number mysite.com www.mysite.comand to file
apache2ctl gracefulI have 82M used and 173M free from
free -m. Further tweak was commenting out mpm_worker_module and use prefork MPM (multi-Processing Module) which is default for Linux and recommended if PHP is run as a module.
Eventually have my subdomains setup correctly last night. Subdomain using namebased virtualhost is like an ordinary domain therefore the key is setting the DNS records right.
Say you want to have these sites
mysite.net and *.mysite.net
habari.mysite.net running Habari at folder /var/www/habari
wp.mysite.net running WordPress at folder /var/www/wp
You'll need DNS setup below (in the case of Slicehost)
mysite.net (name) my.own.ip.no (data) A (type)
mysite.net (name) ns3.slicehost.net (data) NS (type)
mysite.net (name) ns2..... (data) NS (type)
mysite.net (name) ns1..... (data) NS (type)
www (name) my.own.ip.no (data) A (type)
wp.mysite.net (name) mysite.net (data) CNAME (type)
habari.mysite.net (name) mysite.net (data) CNAME (type)
One other setup which may also be key is to add (create if it's not there) below lines to this file
# enable multiple virtual hosts
Also the first line
#NameVirtualHost * in all site config files stored under
/etc/apache2/sites-available should also be commented out.
Last night I also have Shorewall installed, transferred content from this site using WXR export to that WP test site. During import found that I have
chmod 777 . folder
/wp-content/ such that the
uploads folder can be created by the import script.
May be my apache or mysql aren't properly optimized yet as I found out from stat at SliceManager that CPU was running flat out. I did a soft reboot and it's now back to normal.
free -m gave me 88M used out of 256 which is weird as I remember seeing a lot more consumed last night.
Tuesday, November 27, 2007
First off there are few perl modules required such as
apt-get install perl libnet-ssleay-perl openssl libauthen-pam-perl libpam-runtime libio-pty-perl libmd5-perl
then I need to download the package from source
Last run the install script
dpkg -i webmin_1.370_all.deb. That will be it, simple, supposed to be.
I could then login by https://my.server.ip.no:10000/
Supposingly I don't have to install *AMP stack before this as Webmin will install Apache for me. I tried that but it just didn't finish.
At the end I did a
apt-get -r to remove webmin and started over again. I guess it would be better if I have Apache2 installed first and let webmin to auto detect it.
Thursday, November 22, 2007
I have rebuilt OS to ubuntu 7.10 and noticed that VPSLink has a lot more choices such as
CentOS 4 & 5,
Debian 3.1 & 4.0,
Fedora 7 & 8, Fedora Core 5 & 6,
Slackware 10.2 & 11.0,
Ubuntu 6.06, 6.10, 7.04 and 7.10
Now I'm pretty good at this the standard drill would be
adduser then edit file
/etc/sudoers followed by
upgrade. Did also a reboot
shutdown -r now, login again then
Next step was installing php5 by
apt-get install php5-cli php5-cgi php5-mysql php5-xcache. Following advice from here file
php.ini located in
/etc/php5/cgi/ was also edited.
Installation of MySQL wasn't smooth, I used a one liner to install
mysql-client mysql-server but
mysql-client showed error of
can't find package. It was OK to install
mysql-server however at the end of it starting up of
mysqld failed. Error was
* Starting MySQL database server mysqld ...fail!
invoke-rc.d: initscript mysql, action "start" failed.
dpkg: error processing mysql-server-5.0 (--configure):
subprocess post-installation script returned error exit status 1
dpkg: dependency problems prevent configuration of mysql-server:
mysql-server depends on mysql-server-5.0; however:
Package mysql-server-5.0 is not configured yet.
dpkg: error processing mysql-server (--configure):
dependency problems - leaving unconfigured
Errors were encountered while processing:
E: Sub-process /usr/bin/dpkg returned an error code (1)
which I have dealt with before.
The error was exactly as last time
/usr/bin/php-fastcgi: Permission Denied. Nginx was started OK but not PHP, search goes on!
Wednesday, November 21, 2007
I have been extremely busy at work so didn't spend much time tweaking my servers.
6.06 LTS has caused pain due to a few missing extenions such as PDO/PDO_MySQL and PHP not meeting requirement of Habari. That was a real good practice to learn downloading from source and compiling it. Setting up DNS and vhosts have also been a problem, thinking about it again perhaps I probably don't need virtual hosting as I will be merging 2 of my sites as one, so why the hassle?
Last night I successfully installed nginx at my Xen server however getting fastcgi to work proved to be not that easy. I guess I'll rebuild OS and start again.
Perhaps I'll give webmin a try when I'm tired of setting things up. My VPSLink plan is coming to an end very soon so I'll have to hurry up my learning on that server.
Thursday, November 15, 2007
It was troublesome but at last I did it. I googled it and found someone has done this before on 6.06 the good howto is here. The author was able to
pecl install pdo then downloaded from source and compiled in the server the
pdo_mysql driver. I wasn't that lucky I have to start from PDO extension first using the same method.
For PDO extension
tar zxvf PDO-1.0.3.tgz
Note that modding the configure file is not necessary for PDO extension then proceed
Do the same, more or less for PDO_MYSQL
tar zxvf PDO_MYSQL-1.0.2.tgz
Now carefully look for line 4163 which should read something like this
if test "x$is_it_shared" = "x" && test "x" != "xtrue"; then start commenting that line out until you see
fi which is at line 4173. Check line number by doing ^C and go to the line you want by ^_[line number]
After that proceed
Finally add below lines
to the bottom of files
/etc/php5/cli/php.ini. Don't forget to start apache again by
Watch careful for errors when it's complied (
make) and installed (
make install) or else you'll be like me doing this more than once.
Checking it again by
phpinfo() to see your great achievement
I have done this couple of times already so just followed the standard drill in my earlier post here. The only new finding is that I got
couldn't find package php5-xcache. The could be due to LTS 6.06 Dapper Drake perhaps not critical so I'll deal with that later. (PS: by a package search found that xcache is only available by default from Feisty onwards)
So I got LAMP and
free -m gives me
used = 237
free = 18
buffers = 3
cached = 178
swap not used
It appears Xen consumed a lot comparing to OpenVZ.
I have LAMP running so I did a quick
phpinfo() to see if everything I want is available, e.g. mod_rewrite and PHP PDO driver for mysql.
Oops! PDO isn't by default available to 6.06 so few more steps are required to get there.
First of all some depended modules
apt-get install php5-dev
apt-get install libmysqlclient15-dev
apt-get install php-pear
pecl install pdo
pecl install pdo_mysql
OK it wasn't that easy on the outdated 6.06, I got
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 92160 bytes) in /usr/share/php/PEAR/PackageFile/v2/Validator.php in line 1825
Tuesday, November 13, 2007
Now I'm back to 6.06 LTS, naturally followed this article to secure my slice. I didn't do all of them, just these steps
passwd root to change root password then
adduser newusername and used
visudo to edit
/etc/sudoers file adding
newusername ALL=(ALL) ALL to the end of the file. I then used a new terminal window to make sure I could login using
newusername before exiting as root.
free -m output was
total = 256
used = 42
free = 213
free swap = 511
I then did
sudo apt-get update and <sudo apt-get install localeconf language-pack-en which turned out to be not necessary. The
sudo apt-get upgrade was also not necessary may be the image is already the latest one.
Last step was a reboot by
sudo shutdown -r now
After that I need to get some essential packages by
sudo apt-get install build-essential. Let's look at memory again when that was done.
used = 159
free = 96
buffers = 4
cached = 120
swap used = 0
LAMP was installed and ran
free -m I got
total = 256
used = 239
free = 16
buffers = 5
cached = 177
total swap = 511
free swap = 511
I'm looking for a good howto in order to use nginx as frontend and Apache2 as backend.
I picked Gutsy Gibbon 7.10 and after reading this article I might just rebuild it to 6.06. I won't be doing anything fancy so may be security and stability are my best friends.
I had a little trouble yesterday when transferring my new domain name to Slicehost. I followed the good article here of course but I wrongly read the part about creating records for all 3 nameservers for NS entry. I created 3 A records for 3 nameservers. My shout for help didn't get heard in the forum so I emailed support who showed me the right way.
To check the domain name is pointing to the right DNS do this
dig @ns1.slicehost.net mydomain.name
Monday, November 12, 2007
Below is output of 'top' with only Gutsy 7.10 installed
I can see that 36.4% of memory available has been used by the OS running idle.
I also did a
tracert to my slice, average time was 272ms. It traveled through these places
Hong Kong ISPs
Most of the nodes are Level3's.
I have their email on 10 November, that was 39 days of waiting in the queue. The link/offer given was good for 4 days so I paid up the same evening.
I built my OS ubuntu 7.10, that took around 2 minutes and I have my IP and root pass. I was too busy over the weekend so I didn't do anything with it. May be I was lucky, got below from support yesterday.
The server your slice was one became unresponsive to our monitoring at 0448 GMT and an emergency reboot was required. It appears that the network interface card stopped responding, we're investigating this issue. Slices were restarted and are running fine. We'll notify you should further action be required. Please contact us with any questions, we apologize for this downtime.
Saturday, November 10, 2007
Now I have a reply from support which is that
I apologize for any delay. Unfortunately you cannot simply change or migrate to a XEN system or other system of different package types, you merely need to order a new package, then cancel the original. For detailed information you can review our thread on this topic here:
Friday, November 9, 2007
Reading this article I want to switch to Xen. I emailed support 3 days ago, since then an email a day, so far I hear nothing.
Tuesday, November 6, 2007
There is a good article in VPSLink's Wiki to follow in order to optimize Apache and MySQL to fit small VPS plans.
In particular there is an article referenced which tells me more about how Apache works.
I followed recommendations in this article because I'm having a Link-2 plan. Below is output of 'top' after my first optimization.
To compare RAM used by Apache:
- before = 41%
- after = 8.4%
RAM used by MySQL:
- before = 8.5%
- after = 5.8%
Total RAM used:
- before = 85.7Mb
- after = 38.9Mb
Of course as recorded above was only memory used right after a Apache restart. During actual running there'll be 5 instances (PS: nearly 59% of memory used) of Apache instead of initially 2.
Monday, November 5, 2007
No troubles no learning. I started to have a few with VPSLink now.
Yesterday I imported database of size about 2 Mb into my Habari install and used WXR to import content of this site into my trial WP install in my Link-2 plan. This plan has 5G storage and 128Mb RAM running under OpenVZ.
During import I have to increase the upload file size to 10M in
I started to have problem of logging in via SSH and got below error when clicking around in my WP site.
Fatal error: Out of memory (allocated 786432) (tried to allocate 77824 bytes) in /var/www/blog/wp-includes/classes.php on line 477. Very soon after that I have been refused login by
ssh_exchange_identification: connection closed by remote host and can't even do a
ls because of
fork: cannot allocate memory even if I have logged in.
Technical support said I better upgrade to Link-3 plan with 256Mb RAM because Link-2 is not meant for dynamic site with database backend. I said my sites aren't even public and I was the only visitor clicking? If I could do this at a 64Mb RAM plan with Budget Dedicated why can't I do this with VPSLink?
Support said they have turned off MySQL server in order to let me do SSH login. I don't think they should be messing around that way because I have rebooted my OS last night and have no trouble since then. Anyway I'll see if I could slim down Apache and MySQL a bit tonight.
For record below is output of 'top' after my first reboot.
Saturday, November 3, 2007
I started over again by rebuilding OS. The web interface is quite nice so it was easy selecting ubuntu 7.10 to start over. Now I'm back to LAMP instead of LEMP.
After rebuilding the OS logging in was a problem, something new learnt. The RS key fingerprint of the server wasn't retained hence I couldn't login. More reading from here which tells me how SSH host key protection works. I have to clear fingerprint left over at
/.ssh/known_hosts in order to get in.
After that installing LAMP wasn't difficult as I have successful steps written down in this entry.
Not really I found. Installation of
mysql-server wasn't OK and I got
failed on starting. The error was
E: Sub-process /usr/bin/dpkg returned an error code (1). From the VPSLink forum I found the solution, i.e. it is a InnoDb memory related issue which requires more memory of server to run. Workaround is to disable InnoDb by uncommenting
/etc/mysql/my.cnf. Reading what Innodb is from here I don't think it's needed at my sites.
Now I have
phpmyadmin working and a test WP site running latest svn revision at blog.example.com.
- install Habari at another subdomain
- Install firewall
- import database WP & Habari to see if they run OK
- optimize LAMP for this small VPS Plan
I firstly tried nginx as I have played with XAMPP and Apache2 before so something new to learn would be nice. Below was what I did
dpkg -i nginx_0.5.32~grrr-1_i386.deb
It wasn't OK during the
dpkg -i apparently there is a dependency on
libpcre3. Following the advice given I did
apt-get -f install
The second attempt was OK and I saw
Next I installed php5 and nano by
apt-get install php5-cli php5-cgi php5-xcache build-essential
apt-get install nano
There is a nice tutorial for installing LEMP in howtoforge here.
Conclusion I'm not ready for nginx, that's for geeks not me. By the way nginx isn't listed under servers in Fastcgi's official website.
Thursday, November 1, 2007
Decided to give VPS a try, I picked VPSLink.
I asked their support about differences between Xen and OpenVS they pointed me to this. Decided to give OpenVS a try.
Brought a new domain name at GoDaddy at 10:16pm, paid up VPSLink-2 (5G storage and 128M RAM) for 1 month at $14.95 at 10.24pm, changed DNS information and created 'A' record of my domain name following instruction in Wiki here. I logged into my server using the new domain name at 10:29pm.
That was all very quick and I don't have to remember IP address now.