How to set a web server (Nginx or Apache HTTPD) to run your app

NodeChef PHP hosting allows you to run your application the nginx web server or the Apache httpd web server. This document describes how to specify the server used to start the application.

Nginx vs Apache

One of the questions mostly asked by customers running applications here at NodeChef is to recommend a server for the best performance and we always respond with nginx.

Nginx was created around 2002 to solve what is described as the C10K problem. The C10k problem essentially involves the inability of then web servers to handle 10,000 concurrent connections. Nginx was designed to solve this problem using an Event IO model where your web server does not fork a new process to handle each client that connects to your app as compared to Httpd. This results in better cpu utlization with fewer processes as forking a new process does not come cheap. This inefficiency could be at least ameriolated with a process pool mechanism instead of creating and destroying processes but as of this writing, this is not the case with the httpd server.

Apache has its roots in 1995 and still remains the most popular web server used on the internet mostly due to its flexibility and widespread support. Overall performant in the general use case but lags far behind in regards to efficient CPU utilization as explained above.

Again the choice is up to you, at the end of the day you need to ship and if nginx is unfavorable to the current implementation of your app, you generally should be fine with httpd.

Step 1. Create the .bp-config/options.json file

In the root folder of your application create a folder with name .bp-config. Under this folder create a file with name options.json

The below example shows an example PHP app directory after you create the .bp-config/options.json file.

index.php composer.json .bp-config/ options.json

Step 2. Specify the Web server to be used

Use the example JSON format below to specify the web server to use to run your application.

{ "WEB_SERVER" : "nginx" }

The supported values for the WEB_SERVER option includes:

Step 3. Deploy your applicaiton

Zip your PHP project folder and upload it from the dashboard and your PHP app should run with the version you specified. You can also use the CLI to deploy your PHP app.