Blog Navigation
Partners
Latest Activity
Phil gives the source code for implementing a MySQL singleton class in both PHP and Python.
Posted on: June 11th, 2011 by Famous Phil
Here is a relatively short blog for a change! A client came to me today to have PDFLib installed onto the Matthouse CPanel server. PDFLib allows you to create PDF files programatically (in this case, PHP), so I can see a lot of uses for this extension. As expected, CPanel wasn’t able to install this extension through PECL without a little help, so below is the procedure that I used.
#get latest pdflib lite 7 from http://www.pdflib.com/download/ #http://www.pdflib.com/download/pdflib-family/pdflib-lite-7/ cd ~ wget http://www.pdflib.com/binaries/PDFlib/705/PDFlib-Lite-7.0.5.tar.gz tar xzf PDFlib-Lite-7.0.5.tar.gz cd PDFlib-Lite-7.0.5 #java isn't installed on the server, compile without java ./configure --prefix=/usr/local/pdflib --without-java make make install pecl install pdflib #when asked for a path, enter "/usr/local/pdflib" then hit <enter>
I opted to install the lite version of PDFLib since its free and my client didn’t need all of the features that the program includes. I installed pdflib to its own directory that isn’t included in path since I don’t anticipate anyone actually using this via other languages on the server (besides PHP). Once PDFLib is installed, we will need to use the command line (as root) to install the pecl extension and tell it where to find the compiled version of pdflib. Note that CPanel’s PECL installer will not be able to install this extension since there is no way to enter the path (and I’d prefer to not add this to the global PATH variable on my server). The extension is now installed, in order to test the extension, make a PHP file for the below code and execute it in a web browser, you should see “Hello World” as a PDF document.
<?php
try {
$p = new PDFlib();
/* open new PDF file; insert a file name to create the PDF on disk */
if ($p->begin_document("", "") == 0) {
die("Error: " . $p->get_errmsg());
}
$p->set_info("Creator", "hello.php");
$p->set_info("Author", "AUTHOR");
$p->set_info("Title", "Hello world (PHP)!");
$p->begin_page_ext(595, 842, "");
$font = $p->load_font("Helvetica-Bold", "winansi", "");
$p->setfont($font, 24.0);
$p->set_text_pos(50, 700);
$p->show("Hello world!");
//$p->continue_text("continue text");
$p->end_page_ext("");
$p->end_document("");
$buf = $p->get_buffer();
$len = strlen($buf);
header("Content-type: application/pdf");
header("Content-Length: $len");
header("Content-Disposition: inline; filename=hello.pdf");
print $buf;
}
catch (PDFlibException $e) {
die("PDFlib exception occurred in hello sample:n". $e->get_errnum() ." " . $e->get_apiname() . " : " .$e->get_errmsg() . "nn");
}
catch (Exception $e) {
die($e);
}
$p = 0;
?>
Source: I used the guide at http://www.supportfacility.com/blog/cpanel/install-pdflib-php-on-cpanel-dedicated-server/ to write an updated version for my blog. I’d like to thank them for blogging about this topic!
Tags: CPanel, install, pdflib, php, server
Posted in Hosting / Server Administration, Programming
|| 2 Comments »
Posted on: January 5th, 2011 by Famous Phil
For any CPanel administrator, migrating accounts between servers is an issue that comes up now and again and I have not found any really great sources online on how to do this properly and minimize downtime so I thought I’d write my own guide. As always, the information provided is on an as-is basis with no warranty that this will work for your situation.
Background:
Since November, the Matthouse CPanel server (int) was sick. It started in early November by going offline with no response (my nagios monitor caught it). I thought nothing of it and hard-rebooted the machine. I read the error logs and found nothing out of place.
Aside: The kernel is the lowest level of an operating system, it is what makes disk access and other critical functions available to an operating system, BIOS typically calls a bootloader that then runs the kernel. Kernel panics are basically a condition when the kernel doesn’t know how to handle an error, and since the kernel holds the operating system up, the computer crashes and a BSOD (or equivalent) is displayed on the screen.
The next night, int crashed again, but because of the non-existent error logs, I decided to wait for a KVM device to be connected so that I could read the console screen. Thankfully when a system crashes, it leaves information up on the screen that is helpful to the administrator. In my case, the quota service was causing the panic. I disabled the quota service after rebooting the system and this helped for about a week. Then it happened again with a similar error on the console. After a lot of digging, I ran out of ideas and finally had the server checked for hardware problems. All the tests passed successfully so I let it be. Strange enough it made it for another week then the same problem occurred.
At this point, I thought it would be in the best interest of my clients to get them off the existing server and onto some new hardware in hopes of finding a long term solution to this problem. This is where the title of this blog comes into play. How do I implement a new CPanel server and move all the customers to it with almost no downtime? If you wish to know the solution, please open up the full version of this blog and read on.
Tags: BSOD, CPanel, crash, DNS, Kernel, Kernel panic, migration, Transfer, TTL, WHM
Posted in Hosting / Server Administration
|| 3 Comments »
Posted on: June 11th, 2009 by Famous Phil
First, I would like to offer my condolences to the family of K T Ligesh, the owner of HyperVM and LxLabs. It is a tragedy to see such a brilliant coder take his own life. You may read the entire story here
LxLabs develops the best control panel for OpenVZ/Xen which is a virtualization platform for hosting many servers on one physical server. HyperVM allows clients to control their server by enabling power control, operating system reinstallations, and charts for server status.
A major users of HyperVM is cheapvps.co.uk (a2b2, vaserv, fsckvps) which I would estimate hosts at least 5000 vps clients at the very least and I’m underestimating. They provide very cheap hosting and I did host with them for quite some time as a backup solution. I then found space on a friends server and didn’t need them any longer (I’d say about 2 months ago). To get back to vaserv, Their company took a big hit when a vulnerability was released (and as I understand it) was not fixed until 2 weeks after LxLabs was notified. Anyways, their entire service was hacked and most of their data was lost. I feel sorry for those who didn’t backup their vps regularly.
Back in the day when I was using LxLabs software: hypervm and lxadmin (which is like cpanel), the owner was very nice to help me with every problem I had. Eventually I made the move to cpanel because there was always some kind of problem popping up and I needed something much more stable and proven at the time. Cpanel did fix all of my woes.
Anyways, I bet there was a lot of pressure on the owner from everyone. VAserv still isn’t back up fully and it has been 4 days now. I really feel sorry for their staff. They must be losing a lot of money because of this 1 tiny hack. I can sort of see why the owner would kill himself over this, but because of his death, the programming community has lost a brilliant programmer. In addition, the VPS industry has lost a source of cheap, powerful software, so vps prices will likely rise in the near future if the legacy of hypervm isn’t carried on.
One final note on this, as a result of this, I hope the programming community realizes that updates are extremely important both for the developer and the client. I also cannot stress enough that proper backups should be made often and verified for redundancy! I will be verifying my backups later today
So you may be wondering, how did I find out? I have been looking at a vps server to host exchange 2003 or a similar email solution for mobile sync (to get away from the heavy ajax interface of mailxchange at 1and1 plus have control over my backups). I went to cheapvps and they were down, then I checked vaserv and found out that way. Because they have been down and I needed a server yesterday, I went with another provider who I might be reviewing in a couple of weeks or months
Tags: a2b2, cheapvps, CPanel, exchange 2003, fsckvps, hypervm, Ligesh, lxadmin, lxlabs, mailxchange, openvz, owner, suicide, vaserv, vps, Xen
Posted in Hosting / Server Administration, Programming
|| 2 Comments »
Posted on: April 16th, 2009 by Famous Phil
Today I discovered this blog on Matt Heaton’s blog (http://www.mattheaton.com/?p=179) about CPanel Backup.
Bluehost experiences the same difficulties that I experience when performing backups (likely much worse), and they are working on a patch using the linux kernel to determine the list of changed files instead of performing a hard disk scan for changed files. I recommend reading his blog for more details!
I look forward to seeing this addon released because it can help all system admins perform quicker backups on linux!
Tags: backups, bluehost, CPanel, hosting
Posted in Hosting / Server Administration, Programming, Technology
|| 3 Comments »
Posted on: February 18th, 2009 by Famous Phil
As the owner of a hosting company, I have made several decisions regarding which server to use, what kind of control panel should I provide, should I add features to my hosting, how many resources should I include, etc. In my opinion, one of the most important decisions in hosting is choosing how your users will use the service, meaning what control panel should I use? There are many options for Linux including, Plesk, LXAdmin, and the most popular: CPanel.
CPanel is the control panel that I choose to use for Matthouse hosting accounts, but why did I choose CPanel, what are its advantages and disadvantages?
I suppose I should first begin with a small description of what CPanel is. CPanel allows the hosting client to modify all aspects of their site from an easy to use web-based interface such as FTP accounts, Email accounts, statistics, subdomains, additional domains to host, etc. CPanel makes it very easy for the hosting company to give the client total control of their website without the requirement of providing full server access.
Here are the advantages of using CPanel:
So, what are the disadvantages of hosting with CPanel?
So when would I recommend a CPanel installation? Thats simple, I’d recommend it for hosting companies that host many sites on a single server. It reduces stress on the hosting company, and generally these servers have plentiful resources to handle CPanel in its entirety. Also sites that are generally on shared CPanel hosting are not big enough to have a good probability of being hacked.
When would I not recommend installing CPanel. I would personally say never install CPanel on a large site that gets over 5000 unique hits a day or more. CPanel may make administering the site easier, however most sites that are this big bring in a lot of revenue and paying for CPanel could be just slightly cheaper than hiring an experienced server administrator or a friend to run the server without CPanel. Installing the core components and configuring them manually will also ensure that you have minimal code that can be hacked (Yes, web servers are software). I’ve always been taught that the less code you use, the less likely there will be problems with it.
Thats all the time I have. I might follow up on this depending on how many comments I receive.
Tags: CPanel, Host, hosting, Linux, Manager, Web, WHM
Posted in Hosting / Server Administration
|| 24 Comments »