Cpanel / WHM Tutorials

Configuring Apache and PHP in EasyApache 4

Configuring Apache and PHP in EasyApache 4

Configuring Apache and PHP in EasyApache 4

EasyApache is a powerful script that allows you to upgrade and configure Apache web server. It also lets you enable/disable Apache or PHP modules using the EasyApache tool in WHM. During this process, cPanel rebuilds Apache and PHP with the options you select or deselect.

In this tutorial, we’ll show you, how to enable/disable Apache & PHP modules using the EasyApache4.

1. Login into your WHM panel via URL https://server-IP-Address:2087.

2. In the left-hand menu pane, type EasyApache and you will see EasyApache4 option appearing.

Configuring Apache and PHP in EasyApache 4

3. Click the Customize button in the Currently Installed Packages box near the top of the screen. This will adjust your current Apache and PHP installation.

 

Configuring Apache and PHP in EasyApache 4

 Apache MPM selection

4. First you will need to select Apache Multi-Processing Module (MPM) which determines how Apache binds to network ports, accepts HTTP requests, and dispatches children processes to handle the HTTP requests:

There are currently 4 different MPMs available for selection. Let’s discuss them briefly as their selection may significantly impact on your server speed and stability.

PREFORK

Default MPM suggested by cPanel uses multiple child processes with one thread each. Each process handles one connection at a time.

Pros:

  • Quick. The prefork MPM causes Apache to branch (fork) into additional processes before the system receives requests. When the server receives requests, it responds quickly to each request since an Apache process already exists to handle it.
  • Stable. If a problem occurs with an individual process, the system can kill the process with no effect on other Apache processes.
  • Compatibility. Threadless design is safe for non-thread-safe modules, like mod_php.

Cons:

  • Consumes more RAM than threaded MPMs like Worker or Event. Scaled child processes may result in the use of a large amount of system RAM.
  • Comparatively bad scalability. This worker may perform poorly on high-traffic servers with many concurrent requests, since requests have to wait until processes are free.

WORKER

The worker MPM uses multiple child processes with many threads each. Each thread handles one connection at a time.

Pros:

  • Scalability. Worker generally is a good choice for high-traffic servers since there are more threads than processes, this also means that new connections can immediately take a free thread instead of having to wait for a free process.
  • Less RAM-demanding than pre-fork. Worker MPM uses low memory in comparison to Prefork MPM which could help greatly on low tier VPS with lesser RAM available.

Cons:

  • Unsafe for use with non-thread-safe modules (mod_php will not be available).

EVENT

Similar to Worker MPM, but also allows more requests to be served simultaneously by passing off some processing work to supporting threads. Pros and cons are basically the same as Worker ones except for one major improvement. In Event MPM when a client completes the first request then the client can keep the connection open and send further requests using the same socket which reduces connection overload. Idle/kept-alive connections are not consuming many threads and their needed memory, which should reduce server overload with large number of requests.

On the other hand, SSL connections are treated identically to Worker MPM which make this improvement not totally applicable for all kind of websites.

ITK

cPanel recommends using it along with CloudLinux OS as MPM for servers which have shared hosting environment. ITK is based on Prefork MPM and allows you to configure individual Apache vhosts to run as specified users and groups. Thanks to this scripts and configuration files for one vhost no longer have to be readable for other vhosts.

Pros:

  • Security. This MPM allows each user to isolate their files from others with the standard file permission settings which creates an additional level of security.
  • Non-threaded MPM. Just like prefork MPM, ITK is not-threaded which means you can run non-thread-aware code without problems.

Cons:

  • Performance. It is a bit slower than the original Prefork, both MPMs are sharing the performance issues when dealing with big number of requests.
  • Code restrictions. As stated in cPanel documentation for this module: ‘Recent versions of the MPM ITK Apache module implemented restrictions on the use of the setuid() function and the setgid() function. As a result, scripts that depend on these functions may encounter problems. This includes scripts that use the mail() function, the shell_exec function, or the sudo command.’

So if some of your websites are dependable on using these functions you should consider using different MPM.

In general we would suggest choosing of MPM based on your own needs:

  • For best speed and compatibility with older applications use Prefork MPM.
  • For servers which are dealing with big amount of traffic use Worker or Event worker.

knowledgebase page

Once MPM is selected, click on Next to proceed to apache modules selection.

You can only have one MPM installed and active. Changing the MPM can drastically change how Apache behaves on your server, so only choose something different if you understand what that change will do.

NOTE:There is a set of links in the sidebar to the left. You can follow along with each of these steps or skip immediately to a specific area where you want to make changes. Clicking these quick links will not cause you to lose any changes you may have made on other Easy Apache 4 screens, so you can navigate back and forth quickly making changes as needed.

Apache Modules

5. The “Apache Modules” segment will enable you to choose and install the required Apache Modules. When the required modules are chosen, you need to click on Next. Apache Modules can add additional usefulness to Apache. For instance, you are able to choose mod_ssl module by using this interface. Apache Multi-Processing Modules

PHP Versions

6. If we talk about the PHP Versions option, so you are able to choose which PHP version you need to install. WHM will naturally check for augmentation as of now being utilized by different PHP version on your server. We prescribe choosing the PHP X.X and Extensions option when choosing the version. After you have chosen the version you need to install, click on Next.

PHP Extensions

7. As you are able to see the following menu, as the name is PHP Extensions, you are able to choose all PHP extensions as per your need. PHP extensions empower specific capacities utilized in your PHP code, in any case, if your PHP code deals with MySQL so you should use the extension as “mysqlnd“.

Ruby via Passenger

8. If you want to enable shared hosting support for Ruby on Rails, this screen is the one where you can control if it is offered and if so what gems or other functionality are included by default. Select what you want and then click Next to continue.

9. Easy Apache 4 also supports NodeJS and Tomcat if you decide you want to offer these things. Click the slider next to the options you want to offer and click Next.

10. On this final screen, you can review any changes you may have made and then click Provision if you want to apply the changes and have Easy Apache 4 add or remove items as needed. You can click Cancel to revert your changes to what you had configured originally. You can also save the settings for all of these modules as a profile. This would allow you to quickly reapply these settings in the future or export the profile to other cPanel servers and use them there.

Configuring Apache and PHP in EasyApache 4

Conclusion

This is all about Configuring Apache and PHP in EasyApache 4

If you know which ingredient is better than this, let us know in the comments section.

About the author

Avatar

jon snow

Jon is a Linux and F.O.S.S enthusiast, an upcoming Linux SysAdmin, and currently a content creator for ERRORHAT who loves working with computers and strongly believes in sharing knowledge.

Add Comment

Click here to post a comment