Converting from mod_php to php-cgi : Steps to take for a seemless upgrade

Question:

I’d like to change from mod_php to php-cgi. What steps should I take to make sure the change is smooth?

Answer:

Most conversions are as simple as selecting the new version to use in the control panel. If a small amount of possible downtime on your site is acceptable you may want to just try the change and see. In the worst case, you’ll have to wait as long as 15 minutes to switch back to the old version.

The server looks for changes and reloads (if needed) your php configuration every 15 minutes. If you make the change and find you site has problems, you’ll need to “undo” the change by selecting the version you were running previously. You’ll then need to wait for the server to reload your config. Note: During this time your site still runs – there is no downtime – but it does not run the new php version.

If you want near-zero probability of problems (or if you tried the approach above and ran it problems), we recommend the following:

1. Make sure there are no files owned by the generic server user “nobody”. Do this:

find /home/your_user_name_here -user nobody -print

If it shows files owned by nobody, you’ll need to put in a support request for an admin to change the ownership back to your own username.

2. Use the php.ini file that your site was running under before :


mkdir /home/your_username_here/etc/
cp /usr/local/lib/php.ini /home/your_username_here/etc/

4. Make sure date.timezone is set in php.ini. A common problem ugprading to php5.3 is not having date.timezone set. It needs to be set either in your code or (easier) in php.ini

An example for EST timezone is :

date.timezone = 'America/New_York'

5. Check the php.net changelog documentation for any functions that have been removed or changed between the version you are currently running and the version you are upgrading to.

How does the switch over to a VPS from shared hosting take place?

Question:

I want to switch from my shared hosting to a VPS. How can this be done so that I have no downtime? What is the normal process?

Answer:

Normally we do this:

1. Set your DNS TTL to a short value. Normally 3 minutes.

2. Clone your site (files and databases) to the VPS.

3. Send you the raw IP of the VPS to check things out on. Depending on the way your site is coded this may not work perfect (ie. your code keeps trying to redirect you to the proper domain name).

4. If all is well, you contact us and tell us to switch it over

5. We do one final sync of your db and files (in case anything changed from the time we first cloned your site). This step is optional. Let us know if you want a final sync done. If you’ve made tweaks to the VPS copy of the site you will NOT want this done as it will overwrite your changes.

6. The site goes live. If anything is wrong, you let us know and we switch it back

We keep your DNS TTL to about 3 minutes so if something is wrong, your users will pretty quickly (in theory no longer than 3 minutes) start hitting the “old” server again.

Quick methods to move a website to a new host

Question:

How can I quickly clone my existing website to my new hosting account? I want to avoid copying all my files via ftp to my local computer and then re-uploading them – that would take a very long time on my slow internet connection.

Answer:

These command all require you to use the unix command shell but they are very fast ways to clone your website over. If you need help, send a message to support with the login information for your old host and we can do these commands for you.

To quickly pull your backup from your old host :

1. Make the backup on the old host

2. Move it somewhere in the public_html/www/”live” part of your site.

3. On your new server with us: wget http://server.oldhost.com/backup.tgz

4. remove the file from your old server. Don’t forget this step or you’ll have a copy of your site accessible to anyone who might happen to guess the name and location of it.

The second option is to use rsync to make a copy of your site and allow for updates without re-copying everything.

To clone with rsync, do the following: (again contact tech support if you need help!)

cd ~/
rsync -vaze ssh your_user@old_server.com:~/ .

this will copy all your files from the old host to your current directory.

The first run will copy everything over. When you run it over again, it will only copy over the changes. Useful if you want to move the site over, test it out and then do one final copy before going live (in case anything changed on the old server).

Shared hosting versus VPS downtimes

Question:

How often should I expect downtime on a shared account versus a VPS?

Answer:

If you picked a random shared server, you could expect about one five minute outage every 5 months due to kernel upgrades. This is an average because there is no way to tell for certain when new (required – security related) kernels will be released. Think of a kernel update as a required security upgrade that needs a reboot to be installed.

On a shared server other outages are totally dependent on the machine itself and the hard to foresee mix of user websites loaded onto it. On a shared machine it is very hard to 100% stop a user with problems from affecting everyone else.

On a VPS you are in a much better position. You still have occasional reboots for kernel upgrades (we handle these automatically for you). All other parts of your server are totally private so you do not need to worry about other users causing downtime. As long as your own scripts do not cause out of memory and and other problems your VPS should run without issue.

Linux Shell Host – What are my options?

phpwebhosting.com is a great choice for a Linux shell host. After you sign-up, put in a request for ssh and it will be enabled quickly (all new accounts need to be verified). All common unix shell tools are pre-installed and, best of all, the admins will install more for you on request. You also have compiler access so are free to do any custom installs into your account space.

Your account is a normal unix shell – no restricted shells here. subversion and git are both available for revision control. Background processes are allowed as long as they do not cause a problem for other users. Crontab is also available.

Ruby, capistrano and a VPS

Q: What are my options for Rails?

A: Rails is pre-installed on your server (a few legacy servers may be missing it – if so, contact support). You can create a new app by typing :

rails

at the command line.

An example is :

rails myapp
cd www
ln -s ../myapp/public/ myapp
cd ../myapp/
script/generate controller test
emacs app/controllers/test_controller.rb

add:

def hello
render_text “Hello World!”
end

next go to:

http://yoursite.com/myapp/test/hello

capistrano is also pre-installed.

However if you are doing a lot of rails development, you may want to consider upgrading to a Virtual Private Server (VPS). A VPS will give you full root access so you can install things like mongrel and other app servers. Enter a support request to have your account upgraded to a VPS. Note: a fee will be involved. Be sure to ask support if you are not aware of VPS pricing.