Cpnginx have user friendly server administration interface and a command line utility called nginxctl . You can install any version of nginx with any third-party nginx modules . The virtual host configurations are template based configuration. So you can edit and make any custom vhost templates. Cpnginx is using a modular architecture for creating vhost entries in nginx. That means each vhost configuration file is customizable. You can entirely build a new custom template for a domain or subdomain.

Cpnginx is a fully automated software. It will auto manage the nginx web server during the account creations or domain creation / deletion time .

You can build any custom version of nginx using the command line tool nginxctl. An example is given below :-

    
        # nginxctl  build nginx --version 1.11.3
    
  

This will build nginx version 1.11.3 in your server

By default the cpnginx install version is 1.10.1 . Cpnginx installer download the nginx source files from the nginx.org website .

The nginxctl use the configuration options from the file /etc/cpnginx/build/configure.sh

If you need to add an additional module to nginx, copy this file to /etc/cpnginx/build/custom/ and make changes . After that run the above command

    
        # cp /etc/cpnginx/build/configure.sh /etc/cpnginx/build/custom/configure.sh
    
  

To build the default version of nginx you can simply run the following command

    
        # nginxctl build nginx
    
  

Default nginx version is mentioned on the file /usr/local/cpanel/scripts/cpnginx/conf.py

The cpnginx auto installer will automatically install cpanel provided multiple php-fpm rpms and configure it properly. Cpnginx itself use the cpanel provided rpms for php-fpm services . Currently cpanel support php 5.4 , 5.5, 5.6 and 7.0 versions of php. You can see all supported cpnginx php versions from the file /usr/local/cpanel/scripts/cpnginx/conf.py

If you like to rebuild the php-fpm services , simply run the following command

    
        # nginxctl  setupphpfpm
    
  

Cpnginx will install nginx in the folder /usr/local/nginx/ . All nginx configuration files are located on /usr/local/nginx/conf/ directory . Please see the files and directory informations below

/usr/local/nginx/conf/ Contains the configuration files
/usr/local/nginx/conf/nginx.conf Nginx global configuration file
/usr/local/nginx/conf/conf.d/ Configuration files included on nginx global scope
/usr/local/nginx/conf/vhost.d/ Virtual host configurations of domains and sub-domains
/usr/local/nginx/conf/vhost.ssl.d/ SSL virtual host configurations of domain and sub-domains
/usr/local/nginx/conf/ssl.cert.d/ SSL certificates location of your domain and sub-domains
/usr/local/nginx/conf/ssl.key.d/ SSL key files links to your domains and sub-domains
/usr/local/nginx/conf/ssl.ca.d/ CA-Bundle files of your domain and sub-domains .
/usr/local/nginx/logs/ Contains the nginx server logs.

Cpnginx contains some files in /etc/cpnginx and /usr/local/cpanel/scripts folder. All these files are located under respective theme folders. Please see a detailed file informations below,

/etc/cpnginx/ The cpnginx configuration location directory
/etc/cpnginx/version Shows the version of cpnginx in your server
/etc/cpnginx/data/ Contains all json data files that required for cpnginx whm and cpanel
/etc/cpnginx/build/ Contains the nginx auto configure scripts provided by cpnginx
/etc/cpnginx/build/custom/ Contains your custom nginx auto configure scripts for building nginx
/etc/cpnginx/build/templates/ Contains nginx server configuration global templates , startup scripts etc,.
/etc/cpnginx/domains/ This is were whm save each domains custom vhost settings as json files
/etc/cpnginx/templates/ The virtual host and app templates folder
/etc/cpnginx/templates/vhost/ Contains the cpnginx provided vhost templates hybrid, proxy and nginx
/etc/cpnginx/templates/apps/ Contains the Apps Vhost templates like wordpress ,joomla ,etc,.
/etc/cpnginx/templates/fpm/ Contatins the use php-fpm template
/etc/cpnginx/templates/mods/ Contains nginx modules template files
/etc/cpnginx/templates/custom/ This is were your create and place your custom vhost or app template files.
/usr/local/cpanel/scripts/cpnginx/ Contains all python modules for the nginxctl command utility
/usr/local/cpanel/scripts/cpnginx/hooks/ All hooks files required for your cpanel server

Cpnginx provide three modes of nginx service. This comes with the default nginx installation. You can choose the default nginx mode of operation from Preferences → Settings tab. See below the meaning of these modes

Hybrid = Static files will work from nginx and dynamic files works from apache. Some .htacces rules don’t work
Proxy = Nginx works as a proxy server in front of apache. .htaccess rules works
Nginx = Nginx works as stand alone. All files will serve from nginx. Multi php fpm only works with this nginx mode unless you need to build a custom nginx template . .htaccess rules don’t work

Cpnginx have option to add nginx custom rewrite rules . You may read below to know how to add custom nginx rewrite rules

It is better not to use apache .htaccess rules. You can include custom rewrite rules as follows

If your domain name is foo.com , see below to add a rewrite rule

for HTTP domain : Create a file /usr/local/nginx/conf/vhost.d/foo.com.rewrite
For SSL domains : create a file /usr/local/nginx/conf/vhost.ssl.d/foo.com.rewrite

After that rebuild the vhost configuration using nginxctl as follows

    
        # nginxctl rebuildvhost  foo.com
    
  

This option is only available for server administrations. Cpnginx will add a whm interface to add or edit custom nginx rewrite rules.

You can add custom includes for per domain or sub-domain base. See an example for the domain foo.com as follows,

For HTTP domains : create a file /usr/local/nginx/conf/vhost.d/foo.com.include
For SSL domain : create a file /usr/local/nginx/conf/vhost.ssl.d/foo.com.include

After that rebuild the vhost configuration using nginxctl as follows

    
        # nginxctl rebuildvhost  foo.com
    
  

This option is only available for server administrations. Cpnginx will add a whm interface to add or edit custom nginx rewrite rules.

Cpnginx provide a user friendly vhost template management system which will allow you to create and maintain any type of virtualhost templates or app templates for your domains.

Cpnginx use the template language python mako . So it is easy to understand the template language.

Hybrid = The default template file of hybrid mode is located on /etc/cpnginx/templates/vhost/hybrid.conf
To create a custom hybrid template simply copy the file to custom directory as follows

    
        # cp /etc/cpnginx/templates/vhost/hybrid.conf /etc/cpnginx/templates/vhost/custom/hybrid.conf
    
  

Now you can edit this custom file and add your template options. This will automatically used at the time of vhost configuration build.

Proxy = The default template file of proxy mode is located on /etc/cpnginx/templates/vhost/proxy.conf
To create a custom proxy template copy this file to the custom directory as follows

    
        # cp /etc/cpnginx/templates/vhost/proxy.conf /etc/cpnginx/templates/vhost/custom/proxy.conf
    
  

Now you can edit this custom file and add your template options. This will automatically used at the time of vhost configuration build.

Nginx = The default template file of nginx mode is located on /etc/cpnginx/templates/vhost/nginx.conf

To create a custom proxy template copy this file to the custom directory as follows

    
        # cp /etc/cpnginx/templates/vhost/nginx.conf /etc/cpnginx/templates/vhost/custom/nginx.conf
    
  

Now you can edit this custom file and add your template options. This will automatically used at the time of vhost configuration build.

You can also build a template with different name . Suppose if you are going to make a template called mytemplate based on the nginx template file, then do it as follows:-

    
        # cp /etc/cpnginx/templates/vhost/nginx.conf /etc/cpnginx/templates/vhost/custom/mytemplate.conf
    
  

After that edit the file mytemplate.conf and customize it as you wish. You can set this template as the default template for a domain.

After creating a custom template or app template you need to rebuild the vhost template database. So that you and your cpanel users can chose this template from the user interface. To rebuild the template database, run the following command or use the rebuild options from whm interface.

    
        # nginxctl templaterebuild
    
  

You may refer the template documentation to know about the template language and syntax.

This is a new command line tool for managing your cpnginx server. It is a unique tool developed by cpnginx developers. You can do almost all operations of your nginx server from command line.

To see the available options , please run the following command

    
        # nginxctl  help
    
  

1) build : This option will help you to build some of the nginx tools. To build the nginx server run the following command

    
        # nginxctl  build nginx
    
  

To build your custom version of nginx run the following command

    
        # nginxctl build nginx --version 1.11.1
    
  

To build all nginx vhosts run the following command

    
        # nginxctl build vhosts
    
  

To build all ssl certificates run the following command

    
        # nginxctl build sslcerts
    
  

2) setupphpfpm : This option will automatically setup all multi-php fpm servers. It will use the cpanel provided multiple php binaries itself. This tool also set the default phpfpm as your servers default php version. Everything is automated . To update the phpfpm binaries please run the following commands

    
        # nginxctl setupphpfpm
    
  

3) rebuildvhost : This option will help you to rebuild the vhost settings of a domain or subdomain. Use the following syntax to run the commmand

    
        # nginxctl rebuildvhost  < domain name >
    
  

eg : nginxctl rebuildvhost fun.com

4) rmvhost : This option will help you to remove a vhost entry of domain or subdomain from the server. It will automatically remove ssl and non-ssl vhosts from the nginx pool.

    
        # nginxctl rmvhost < domain name >
    
  

eg: nginxctl rmvhost fun.com

5) rebuilduservhost : This option will help you to rebuill all domains vhost files of a cpanel user. This will build that users ssl or non-ssl domains and setup the php-fpm pools of the domains automatically

    
        # nginxctl rebuilduservhost  < cpanel user name >
    
  

eg : nginxctl rebuilduservhost cpuser

6) rmuservhost : This option will remove a all nginx vhost files of a cpanel user. This will automatically remove the users php-fpm pool configurations, ssl domains and non-ssl domains. It only remove the nginx related files.

    
        # nginxctl rmuservhost  < cpanel user name >
    
  

eg : nginxctl rmuservhost cpuser

7) templaterebuild : This option will rebuild all your nginx templates and apps templates pools. It will be automatically added to the cpnginx interface. You should run this command after making your own nginx vhost template files or app templates

    
        # nginxctl templaterebuild
    
  

8) restart :This options will restart your nginx server. To restart the nginx server run the following command

    
        # nginxctl restart
    
  

9) help : This option will show the nginxctl help menu

10) enable : This option is for enabling cpnginx in your server, if it is disabled by administrator.

11) disable : This will disable the cpnginx from your server, if it is enabled.

12) status : This will show the nginx service status

13) version : This will show the cpnginx version, nginx version and apache version