A Look at Our PHP Setup

In the tradition of A look at our Python setup, today’s post is all about WebFaction’s PHP setup. While some of our specialized installers get a lot of attention, we know that PHP is an important, if not glamorous, part of many web developers’ toolbox. So let’s take a closer look.

On our servers, PHP 5.2 is the default version. It’s not the newest and shiniest, but it’s hugely popular. For example, on Web310:

$ php --version
PHP 5.2.17 (cli) (built: Jan 17 2012 13:19:44) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
    with the ionCube PHP Loader v4.0.10, Copyright (c) 2002-2011, by ionCube
        Ltd., and
    with Zend Optimizer v3.3.9, Copyright (c) 1998-2009, by Zend Technologies

But we’re not ignoring PHP’s development. PHP 5.3 is also available:

$ php53 --version
PHP 5.3.9 (cli) (built: Jan 16 2012 15:27:59) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with the ionCube PHP Loader v4.0.10, Copyright (c) 2002-2011, by ionCube
        Ltd.

We’ve tried to provide a lot of the more popular and useful compilation options. For example, we’ve enabled libcurl support so you can start making HTTP requests, right out of the box:

<?php
    $c = curl_init();
    curl_setopt($c, CURLOPT_URL, "http://www.webfaction.com");
    curl_exec($c);
    curl_close($c);
?>

Here’s a complete list of the our compilation flags on a CentOS 6 (64-bit) server:

--with-libdir=lib64
--with-pdo-mysql
--with-pdo-pgsql=/usr/pgsql-9.1
--enable-bcmath
--enable-calendar
--enable-exif
--enable-ftp
--enable-mbstring
--enable-soap
--enable-zip
--with-curl
--with-kerberos
--with-freetype-dir
--with-gd
--with-gettext
--with-gmp
--with-iconv
--with-imap
--with-imap-ssl
--with-jpeg-dir
--with-ldap
--with-mcrypt
--with-mhash
--with-mysql
--with-mysqli
--with-openssl
--with-pgsql=/usr/pgsql-9.1
--with-png-dir
--with-pspell
--with-regex
--with-tidy
--with-xmlrpc
--with-xsl
--with-zlib
--enable-fastcgi
--enable-sockets
--with-libxml-dir

You can see all the details on your specific machine’s PHP setup by running php-config.

In case you missed it previously, you should also know that our PHP setup allows you to send email with PHP’s built-in mail() function. There’s no requirement to use an SMTP library to send mail (though you’re welcome to do so, if you prefer). You can send email simply, like so:

<?php
    $message = "Just testing sendmail\n";
    mail('support@webfaction.com', 'Help me', $message);
?>

Of course, PHP in isolation isn’t so useful; we can plug it into the web with our corresponding Static/CGI/PHP applications. They’re more flexible than meets the eye. By default, a Static/CGI/PHP application uses a traditional php-cgi deployment method, where each PHP script is loaded and run with each request. It’s simple, effective, and perhaps best of all, doesn’t count toward your account’s memory usage.

But if you’d like to tweak your PHP deployment method, you can choose FastCGI as an alternative. Although it consumes your account’s memory, it has better performance for some applications. To use FastCGI, create a .htaccess file in your Static/PHP/CGI application directory containing this line:

<FilesMatch \.php$>
    SetHandler php52-fcgi
</FilesMatch>

You can also replace php52-fcgi with php52-fcgi2, php52-fcgi3, through php52-fcgi6 to control the number of processes FastCGI will use to serve the site.

In addition to .htaccess, you’re free to use your own php.ini file to configure your PHP application. For example, you can use php.ini to set the maximum size of file uploads. See our existing Configuring PHP docs for all the details.

Finally, we have some Static/CGI/PHP-derived installers for popular tools, like WordPress and Drupal. Under the hood, they’re PHP applications through and through, so you can use what you’ve learned here to extend or customize those applications too.

We hope this gives you a better picture of what our PHP setup is capable of and what you can do with your account. If you have any questions, let us know in the comments or join us on the Q&A Community.

This entry was posted in Server setup. Bookmark the permalink.

13 Responses to A Look at Our PHP Setup

  1. You guys are way too cool! I’m a happy customer.

  2. Anand Babu says:

    I have been using Webfaction PHP stack for couple of years now, and i am so satisfied that i have moved all my web development client’s accounts to webfaction. THEY ARE THE BEST !!

  3. Sofia Cardita says:

    Hi,

    Thanks for all your great work :) Php 5.4 has just come out and fixes some really important security holes in php5.3 as well as having better performance (at least according to the benchmarks). When do you think you’ll have it available?

    Sofia

  4. Nick Watts says:

    I have never used, or even heard of a web hosting provider as good as webfaction. I used to be a sysadmin, and I can tell you that articles like this just go to show what pride the webfaction team takes in delivering outstanding service. I run custom bible-study software written in PHP on my account. Fast, flawless, and great documentation for deployment. I made a mistake in configuring .htaccess for my MVC framework. 10 minutes of searching the docs and I had it fixed.

    People ask me for recommendations for hosting all the time. I tell them they’re doing themselves a giant favour by going with webfaction.

    Keep it up guys :)

  5. Tim says:

    Can you give an example of setting up a site to use php 5.3 instead of 5.2?

  6. Jamie Robe says:

    Have been a loyal customer of Webfaction since the Pyhton-Hosting days. You guys are fantastic. I really liked reading this blog post too. I highly recommend you to clients.

  7. Yoav Aner says:

    we have some Static/CGI/PHP-derived installers for popular tools, like WordPress and Drupal. Under the hood, they’re PHP applications through and through, so you can use what you’ve learned here to extend or customize those applications too.

    Is this available via the control panel? I couldn’t find a way to change WordPress from 5.2 to 5.3. Also, do you have any specific recommendations for getting the best performance using WordPress? (Is fastcgi better?)

    • remi says:

      WordPress upgrades are available via the WordPress admin panel. Getting the best performance out of WordPress (or any app) is a vast subject and really depends on your needs and your budget. Feel free to email support@webfaction.com and we’ll do our best to advise you.

  8. Pingback: PHP-5.4 is here | WebFaction Blog

  9. Dave says:

    Any reason you don’t configure with mysqlnd?

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>