WHM 11 services series

7. How to rebuild Apache and PHP in WHM

At some point in time, you're probably going to have to recompile Apache and PHP. This is necessary any time you wish to upgrade to the latest version, enable or disable a module or feature, et cetera.

WHM provides you with a convenient tool called EasyApache. This tool gives you the freedom to customize every little detail, if you want, or to choose from an existing configuration profile.

1) Find the Software category of the menu.

2) Click the EasyApache link.

It will check for updates first, then should forward you to the user interface.

If you'd like more information before using EasyApache, you can always read over the documentation, found using the links above.

3) Select a profile from the list. Check out the More Info links if you'd like more details about each one.

4) Click Build Profile Now if you'd like to go ahead and rebuild Apache and PHP without making any changes to the profile first.

We're going to customize the Previously Saved Config.

You can keep track of your progress and return to previous pages up here.

5) Select the version of Apache you want to build.

6) Click Next Step to proceed.

7) Select the main versions of PHP you want to build; we'll be sticking with PHP 5. You can choose to install both -- or neither -- if you wish.

8) Next Step.

9) Now, select the minor version to build of each major PHP version.

Typically, the latest version is best.

10) Now, for the Short Options List. Work your way through the list, enabling or disabling whatever you want. Be sure to enable only what you need; installing too many modules can cause performance issues.

Assume that if an option on our screen is already enabled and we don't mention it, you should enable it on yours, if it isn't already.

You'll have to confirm most options, but we won't show that for every one.

The Frontpage Extensions for Apache have security issues and bugs. Frontpage itself has been discontinued since 2006.

11) So, we'll turn Frontpage off.

12) Mod SuPHP is a module for PHP similar to the suEXEC module for Apache. It helps decrease the security risks involved with running PHP scripts. This option requires that PHP runs in CGI mode; enabling it will make the necessary changes automatically.

13) The IonCube Loader for PHP is required to run some PHP programs having encrypted source code.

14) ModSecurity is a web application firewall for Apache; it increases security by detecting and preventing attacks before they reach web applications. You'll be able to configure this in WHM later, once enabled.

15) Suhosin is an advanced protection system for PHP, designed to protect servers and users from flaws in PHP itself.

16) SourceGuardian is similar to IonCube.

17) At the bottom of this page, you have the option to Save and Build your profile as it is now.

18) Or, go to the Exhaustive Options List for further configuration options.

19) First on this page is the list of Apache Built-in Modules. You shouldn't need to enable or disable these any further than we did on the previous page, unless you're certain you need to do so.

This is the only PHP-related module here; the core PHP modules can be enabled or disabled further down the page.

20) Next is the Other Modules section. All of these were on the previous page, so let's skip down to the PHP section.

Most of the changes you'll make on this page will probably be to the PHP options, shown here. You should see a section like this for each version of PHP you'll be installing.

21) cURL allows PHP scripts to connect to many different types of servers, such as web servers and FTP servers.

Let's enable cURL and its SSL support (for encrypted connections).

22) GD (or Graphics Draw) is a library of functions for PHP that allows programmers to create and manipulate images in a variety of different formats.

Many PHP programs use this, so you should turn it on.

23) The Zlib module for PHP is required to install GD.

24) Mbstring allows PHP to handle working with "multi-byte strings". This module is required in order to work with alphabets other than Latin.

25) Mcrypt enables a number of advanced encryption algorithms. A number of the algorithms are used by governments to protect Top Secret information.

26) Closely related to Mcrypt is Mhash. Hashing algorithms are similar to encryption algorithms, with the key difference being that hashing is irreversible.

27) Let's enable both of those.

28) The MySQL "Improved" extension provides programmers with more efficient access to a MySQL server and its databases. It should work with all recent versions of MySQL. Click here to enable it.

29) Enabling Safe PHP CGI prevents users from overriding your system PHP.ini settings when running PHP in CGI mode.

30) Ticking the checkbox next to TTF (FreeType) gives the GD extension better font support.

That's all of the options for PHP.

Here are some preferences that you should not need to change, but can if you wish.

31) If you want, you can use this form to save your settings as a custom profile that will be selectable with the rest of the profiles later on. If you don't fill out this form, your choices will still be saved as "Previously Saved Config".

32) Click here to Save your profile without building it...

33) ...or here to save and build your profile.

34) Confirm.

35) Acknowledge that you understand terminating the build process can cause data loss. Apache will be rendered unusable if this process is killed prematurely.

You will be notified of any necessary adjustments to your configuration, then forwarded automatically to the build page.

If anything goes wrong, the entire build log will be saved to the path shown above in bold for troubleshooting purposes.

If you receive "Out of memory" errors below, you will need to run the build manually by command line. That's beyond the scope of this tutorial. Most servers should run EasyApache in a browser just fine.

You might also find these profile-related links useful.

Barring any unexpected errors or a server crash, the build process will continue in the background until finished, even if the browser window is closed.

You'll see output from the process in this box, as the build goes on.

It could take an hour or two for the build to complete, depending on your settings.

When the build is complete, you should see this box pop up, telling you to configure suEXEC and PHP.

This page allows you to choose which of the PHP versions available on your system are active.

You can also enable suEXEC for Apache, which decreases the security risks when running CGI and SSI programs. Note that this has no effect on PHP scripts -- that's where suPHP comes in.

In order for suPHP to work, you must select it as the handler for each version of PHP you have installed.

If you have both versions of PHP on your system, you'll need to choose which is used by default to execute .php files.

36) When finished, click Save New Configuration.

You will be shown the settings you chose and the generated php.conf file.

That's it! Apache and PHP have been re-built. If all went well, all the websites on your system should function normally.

If you mis-configured anything, you can always come back here and re-build Apache and PHP.