Archive for category Web Development

Increasing the size of tmpDSK and /tmp in a CPanel Environment

I recently ran into an issue in cPanel after recompiling Apache with some new settings. I enabled the eAccelerator extension in my EasyApache configuration for PHP. Now cPanel uses a default size for its /tmp mount of 512mb. I found out rather quickly that this isn’t enough for eAccelerator. I actually ended up resetting this value to 4096mb (4GB). As a reminder to myself and so anyone else looking for the solution to this problem, I will outline what needs to be done below.

First, ssh into your server and login as root or su – root after logging in as a regular user. Now use the power of the command line. Don’t panic!

Stop Apache, MySQL, and cPanel

1
2
3
service httpd stop
service mysql stop
service cpanel stop

Next unmount the existing /tmp

1
umount -l /tmp

Remove /usr/tmpDSK

1
rm -rf /usr/tmpDSK

Next, use your favorite editor (Vim in this example) to change the config file for the tmpDSK

1
vim /scripts/securetmp

Search the file for “tmpdsksize” (in Vim type /tmpdsksize and hit enter). The line should look like this by default:

1
my $tmpdsksize     = 512000;    # Must be larger than 250000

Change the 512000 to a higher number in Kilobytes. For my 4GB, I changed it to 4096000.
Save the file (vim :wq enter).
Run the script…

1
/scripts/securetmp

Answer y to the two questions it asks.
Finally start your services back up.

1
2
3
service httpd start
service mysql start
service cpanel start

That should have you set with more /tmp space.

, , , ,

No Comments

Best Godaddy Alternative Registrar

Many of you may be die-hard GoDaddy users. GoDaddy’s support of the SOPA has led many people to start looking for a new registrar, including myself. After a boycott, GoDaddy broke away from its support of SOPA. However, their initial support for the legislation was enough to turn me away, find the right payroll software for your startup. I do not plan to do any further business with them and will be slowly migrating my existing sites over to another registrar as time goes by. If you have a company be sure to be on time payment.

In my search for a GoDaddy alternative, I found that I really like NameCheap.com. They offer good rates on domain transfers and registration. I also like their control panel much better than GoDaddy. They don’t have as much up-selling going on when you register a domain. I always found that annoying about GoDaddy. I also didn’t care for GoDaddy’s domain manager implementing proper payroll processes. Once, I tried out GoDaddy’s Windows hosting as well. It was terrible. So if you are looking for a viable alternative to GoDaddy, you should definitely give NameCheap.com a try.

, ,

No Comments

Reset a WordPress password

I’ll make this post short and sweet. Let’s say you’ve forgotten your login for a WordPress site. To reset the password to something new, you can simply use a SQL query. If you have access to PHPMyadmin or the MySQL command line, this is really straight forward.

From PHPMyAdmin, open the database for the WordPress installation. If you don’t know which database to use, check out your wp-config.php file inside your main WordPress installation folder. You’ll find constants defined in that file for your database name and database user. Once you’ve found the database, you can execute a SQL statement by clicking the SQL button. In there, type:

 
UPDATE wp_user SET user_pass = MD5("yourpassword") WHERE user_login = "admin";

That’s assuming that your username is “admin”. Change it to whatever username you are using. Once you run that SQL statement, your password will be set to whatever you put in “yourpassword”. Both the username and password need to be quoted in the SQL statement.

To do the same thing in the MySQL command line, connect to the database with:

mysql -u<username> -p

Substitute <username> with your actual username from the wp-config.php file.
You will be prompted for a password. Use the password from the wp-config.php file.
Once you are logged into the mysql command problem type:

USE <databaseName>

Substitute the actual database name from the wp-config.php file.
Finally, type the update statement above and hit enter.

After you’ve updated the table via SQL, you should be able to login to your WordPress installation.

, ,

No Comments

My Search for the Best Deal on a Dedicated Server

Searching for a dedicated server can be stressful, especially when you have a lot of sites that are running slow as a result of their current host. Recently, I switched about 600 sites over to a dedicated server I borrowed from my friend Lynn. It is a pretty decent server, with two dual core Xeons running at 3 GHz. It also has 8 GB of RAM. However, it’s just not enough. After switching DNS over to this new server, its load went to 20 very quickly. For those who don’t know, a load of 20 means that there are 20 processes waiting in line to be processed. I don’t like my loads to go above 2 or 3. I can deal with them spiking to as high as 4, but with a multicore/multiprocessor I don’t want it to get above the number of cores/processors you have available.

Suffice to say that the web sites were loading very slowly. So, I switched the NS back to the VPS server I’ve been running them on. I’ve seen its load spike to 10 quite often but it normally stays well below 4. So the VPS is holding up pretty well considering. This VPS has 4 cores assigned to it, each at 1.6 GHz. It also only has 3GB of RAM. So, my question is, “Is a dedicated server really the best option?”.

There’s more factors in this as well. For instance, my sites are all on a WHM/cPanel install, which means I have to pay a monthly license fee for that as well. On a VPS this license is about half the cost as it is on a dedicated server. I like saving money.

I currently have my hosting through a small hosting provided in Knoxville, TN called Knoxcolo/Smith & Hammaker. I have a colo server (not the one I used for my 600 sites, it’s a single site), and I have the VPS. For the colo they charge $35 for the 1U of rack space, and it’s an unmetered drop. The VPS is $40 per 1GB of RAM. That’s their rate, they don’t charge for extra HDD space or even CPU cores. They are also a good bunch of people to work with. I have full access to the colo facility through a high security system. I rarely use it since my colo has an iLo connection for remote console even when the servers main drop is offline. The security for operational technologies is really necessary to protect the data.

I thought that a dedicated server would be a better choice for my 600 sites, but I’ve found that the VPS is really the better choice in the long run. The only thing I don’t like about the VPS is that I don’t have the ability to remotely reboot the virtual machine. I’d really like this ability.

So I’ve found that perhaps a dedicated server isn’t what I really want. Some VPS providers give you a lot more bang for your buck. You can spend hundreds of dollars per month on a very powerful dedicated server, but you have two problems. You don’t want to spend a lot of money for hardware that you may not use fully. Of course, secondly, you don’t want to spend a lot of money on a server that can’t fully handle the load if you have a lot of sites. With a VPS, you have more power to change the hardware specs to meet the demand of your site load. You pay for whatever you need. This is really the best option for anyone who wants to host any number of sites. If you don’t need much power, because you only have a few sites, you can save money.

However, you should look for the best deal on a VPS. Smaller companies actually have the better deal when it comes to a VPS, because they typically don’t have as much total load on their rack of CPUs. If you get a VPS from a larger provider, they may be pushing their rack to its limits already, and you’ll get terrible physical processor speeds, even if you are paying for four cores.

Shop around and look into VPS servers. They are great alternatives to dedicated or colo servers if you look in the right place.

, , , ,

No Comments

To Comment or Not to Comment

Anyone who has had programming classes knows that one of the primary things they push on you is that all good programmers comment their code. They don’t always tell you how much commenting you should do, although some do give good advice. How does one decide how much is enough.

Comments are great because they are basically communications between programmers to help with the logic that is going on in the code. Sometimes the two programmers are the same person. I think a good rule of thumb is to comment just below your own skill level. This means to comment just enough to help someone of almost the same skill as yourself along. You don’t want to comment your code to the point that it clutters up the rest of the source, but you want to be able to read through your own code and quickly find the cause of any potential bugs. You never know when you’ll have to go back through your own code. Chances are you won’t remember what exactly is going on at any particular point, especially if you work on a lot of projects.

Of course, there are always conventions that are mapped out beforehand for most developing teams, but if you are working solo, you should comment as if you are in a team environment.

I personally find comments distracting and ugly when viewing code. I don’t particularly care for method and class header comments. They rarely give any useful information. Inline comments are very valuable, however. So if if the coding standards of your team require class and method headers, put them in, but if you are solo or there’s no coding standards in place that require these types of comments, don’t use them. You should be able to look at any method and tell what kind of parameters it takes, and you should be able to quickly find the return type. These aren’t necessary and break down code readability in the end.

Comment changes. If you have to remove some code, comment it out instead of deleting it. This will help you revert changes or come up with better solutions if it is later found that the new code is buggy itself. If you have some bit of logic that is complicated even to your own eyes, comment it and explain how it works. Other than that, keep comments to a minimum.

, , ,

No Comments

Codeigniter Controllers Give Server 404

I often take shortcuts when setting up my development servers. I recently installed Linux Mint 12 x64 on my main box and wanted to setup a web developing environment on it. To cut corners during package installation, I’ll typically install phpmyadmin which grabs most of the dependencies I need to have a full LAMP dev stack, such as Apache2 and Mysql-server.

That’s how I initially set up my stack in Linux Mint. I also enabled user directories in Apache so I could develop within the public_html directory inside my home directory. All was working well until I copied a CodeIgniter project over and tried it out. I couldn’t access my controller functions from index.php. It worked well for the default controller because it was accessing it from index.php, but when I changed the URL to point to a controller like index.php/admin, it didn’t know what to do with it and I would receiver a server 404 error.

After digging around for a solution, I realized that when I installed my LAMP stack, apt had installed libapache2-mod-php5filter instead of libapache2-mod-php5. I’m not very familiar with this module or what benefits come from using it, but the quick fix was to:

sudo apt-get install libapache2-mod-php5

This removed the php5filter module and installed the plain php5 module. After that, I no longer have an issue with the controllers giving 404 errors.

, , , , ,

1 Comment

GoDaddy Alternatives | Boycott GoDaddy

Due to its support of SOPA, many people are calling for a boycott on GoDaddy. At first GoDaddy was laughing because of the planned boycott. After about 24 hours, their tone changed and they proclaimed that they were no longer supporting the legislation. Many people are looking for alternatives to Godaddy.

I searched for a bit and found that about the best deal in town is namecheap.com. There is a transfer fee for moving domains over to them, but you get a free year of registration with the transfer. So for around $7 bucks you can transfer and renew a .com. If you have a few months left before it’s time to renew your .com, you can still transfer the domain and get a free year along with the remaining time of your current registration.

Check out their deals. Let’s show GoDaddy that we do not like their support of this unconstitutional legislation.

NameCheap.com

,

No Comments

PHP Video Tutorials

I just started a new website devoted to teaching people how to develop websites. The site is PHP Video Tutorials. So far I have about 20 videos uploaded. There are nine in the first series which teaches basic HTML and CSS. The second video series goes into PHP and MySQL. I think these videos will be very helpful to anyone who wants to get into web development.

, , , , , ,

No Comments

The Best PHP Framework

I searched for the best PHP framework for a while. I tried CakePHP, Zend, Yii, Symfony, and Codeigniter. Some of them frustrated me to the point that I was ready to write my own mini-framework. I think the problem with some of them, at least from my perspective, is that they try to do too much. Some were just poorly documented. Sure, you can find all the information you need to find about all the features, but they don’t make it very easy. For this post, I want to compare two of the most recent frameworks I’ve worked with, Codeigniter and Symfony.

I use Codeigniter for all of my personal projects these days. Recently, I had to use Symfony for some other work I was doing. I can see positive and negative aspects of each system at this point, and this is an overview of their main differences.

First, I’ll talk about Symfony. It includes two ORMs, Doctrine and Propel. I was using Doctrine. It relies heavily on the ORM as it should, but I found utilizing an ORM to be overly complex. This may be due to my own ignorance, but when using an ORM, you have to get into a different mindset. Most people would view the ORM as a feature. For me, it was unwanted. Symfony is a great framework and is used by many people. My distaste for it should not be a deciding factor in choosing your own framework.

However, I would like to point out other things about Symfony that I didn’t like. First of all, the directory structure is overly complex, especially when your job is to maintain code that is already in place. You may find yourself looking at a page and going through 10 different files trying to find where the code is located. Symfony has a ton of plugins, many of which have auto-generated forms and templates. There are times that you won’t find the code that generates the form and from what I saw, your only option is to override the plugin’s actions and templates. If the code you’re maintaining doesn’t override the plugin, you will have to check cache files for the auto-generated PHP and then implement this in the override.

While we are talking about caching, I’ll point out that this is a good feature and it’s implemented by default in Symfony. During the development maintenance of a site, however, it gets on my nerves. So, you’ll spend a lot of time clearing your cache from the command line. Symfony depends on command line usage. While I like using a command line in most cases, I don’t want to be jumping back and forth between my IDE, command line, and web browser so much. Since Symfony auto-generates a ton of code for you through the use of the command line, I can see the advantage, but I prefer the Codeigniter way.

So, let me talk about Codeigniter and why I prefer it to all other frameworks I’ve tried.

First of all, it stays out of your way. It arranges your site into three folders, as I think it should, models, views, and controllers. You can then arrange your files in sub-directories under these main folders as you wish. So if you have a user system on your site, you can put all your views for that section under views/user.

While I’m on the subject of views, let me touch on Symfony’s templates and layouts. It’s actually a good system and cuts back on the amount of code one has to write, but it depends on yaml config files in various locations. I liked the idea, but hated the implementation. I much prefer having the view source where I can easily find it. In Codeigniter, I get all my data ready to send to a view, then load that view. In this view, I can load other views as needed. So if my page has a top navigation menu, I can just load that menu from within my view. This templating system works best for me, and I don’t have to search through config files at various locations to find out where the HTML is located.

Finally, documentation is much better in Codeigniter. If you want to know how a library or helper works, their documentation makes it simple to understand. Symfony’s documentation is terrible in comparison. There’s a reference but it’s just not that good. Plus much of the documentation you’ll need is actually on the Doctrine site.

Symfony has many features that Codeigniter doesn’t. Codeigniter is much easier to use, has the best documentation, and is much easier to maintain. These three things are why I prefer Codeigniter. Maintainability and ease of use are the two main reasons to implement a Framework anyway. Without these two things, one would be much better off using straight OOP PHP.

 

 

, ,

No Comments

The Best PHP Framework?

I’ve been really interested in using a PHP framework. One thing holding me back is deciding which one to work with. It seems that every time I start looking at frameworks, I end up deciding to just code everything manually. The major contenders seem to be Yii, Zend, Symfony, CakePHP, and CodeIgnitor. However, I have no idea which one I’m going to use. It’s hard to decide without learning the ins and outs of each one and making a good decision based on that knowledge.

My latest attempt was with the Zend framework. I was getting into it and realized that most of the documentation for setting it up bases the setup from a virtual host in Apache. This would be fine, but it actually makes development and deployment overly complicated for me. My development environment is a Linux machine that is my main desktop. My production server is my own dedicated server with CPanel. Zend doesn’t work very well with this setup from what I can tell.

I want my site to transfer easily between the two environments. I like them to be self-contained as well. I want to throw the framework into a lib folder or link to it in some way. I don’t like that the forward-facing web site is in the “public” folder. I want the root of the website to be the forward-facing public website.

I would really like to use Zend because it has a lot of good extensions for utilizing various web services.

I’d like to hear from others. Which framework would you recommend and why?

, , , , ,

No Comments