Nginx one of the popular web server used by high traffic web sites have come up with NGINX Unit, an application server that can serve PHP, Python And Go language web applications.
To Install Nginx Unit on Ubuntu 16.04, first add nginx key
wget http://nginx.org/keys/nginx_signing.key sudo apt-key add nginx_signing.key
Add Nginx Unit repository by editing
vi /etc/apt/sources.list
Add following 2 lines to end of the file
deb http://nginx.org/packages/mainline/ubuntu/ xenial nginx deb-src http://nginx.org/packages/mainline/ubuntu/ xenial nginx
Install Nginx Unit with command
apt-get update apt-get -y install unit
I was expecting it will install nginx, then this new “unit”, that replace php-fpm. But all it installed was the new unit package.
Starting Nginx Unit
To start Nginx Unit, run
service unitd start
This won’t start any web server, that is at this stage, if you check with netstat, you won’t see any new LISTENING ports.
Now, you need to restoreconfig file, this can be done with command
service unitd restoreconfig /usr/share/doc/unit/examples/example.config
You can see current config with command
root@hon:~# service unitd dumpconfig The following configuration has been saved to /etc/unit/config: { "applications": { "example_php": { "type": "php", "user": "nobody", "group": "nogroup", "workers": 2, "root": "/usr/share/doc/unit/examples/php-app", "index": "index.php" }, "example_python": { "type": "python", "user": "nobody", "group": "nogroup", "workers": 2, "path": "/usr/share/doc/unit/examples/python-app", "module": "wsgi" }, "example_go": { "type": "go", "user": "nobody", "group": "nogroup", "executable": "/tmp/go-app" } }, "listeners": { "*:8300": { "application": "example_php" }, "*:8400": { "application": "example_python" }, "*:8500": { "application": "example_go" } } } root@hon:~#
As you can see from the config, PHP application is running on port 8300, python on port 8400, golang app on port 8500. For some reason, go lang application did not work as binary is missing. Look like you need to compile golang application yourself.
Here is config if you want to run PHP application on port 80
{ "applications": { "my_php_app": { "type": "php", "user": "nobody", "group": "nogroup", "workers": 2, "root": "/var/www/html", "index": "index.php" } }, "listeners": { "*:80": { "application": "my_php_app" } } }
See Nginx