Hey I have been using Virtualmin for some time now and never really coded anything in Perl before. So I have been reading through the documentation and applying edits to the current module. I recently decided to install Virtualmin again within CentOS 7. After doing this I realised that I would have to configure files each time I created a server for PHP-FPM and Nginx to work together.. I kinda wanted to automate this process and make a few changes to the current Nginx Virtualmin mod as I realised it doesn't cater for a number of things.
With the updated plugin, for Nginx and Nginx SSL a few things that have been added and some fixes to the previous code are: Allows multiple server blocks instead of just 1. When backing up, if you have multiple server blocks for one domain it will backup both server blocks and restore them correctly. When renaming the domain or changing IP address it will do this in all server blocks related to the domain. I fixed some of the bugs when doing some renaming and editing of the Virtualhost. I did notice there were a few bugs.
This will automatically create a new php-fpm pool file for each virtual host created in php-fpm.d and configure the domains Nginx config file for PHP-FPM. You can choose between using the old previous php-fcgi mode or php-fpm with both of them supporting socks and TCP connection. You can choose which mode you wish to use and all configuration files will be setup accordingly. Supports full backup and restore ability.
This also fix's a lot of the Selinux permission issues automatically when creating a virtual host PHP-FPM and Nginx.
I have added a function to try and automatically detect which PHP-FPM version you are using and its location. If unable to detect you can got the module configration page and insert the location to your PHP-FPM directories manually.
This is the same for the start,stop and restart commands for PHP-FPM. A lot has been done to the code but the overall result is this.
You can now create virtual hosts for a domain name and this will setup an Nginx config and PHP-FPM config automatically and your domain will be instantly usable by PHP.
If anyone would like to contribute the code and make improvements please do post!
This mod has actually taken a very long time to get right. So I would appreciate some feedback and if it worked for you as I have not been able to test in multiple environments. So you know my exact setup from start to finish, here is how to setup CentOS 7 with Webmin, Virtualmin, Nginx, PHP-FPM and MariaDB. Without going into too much detail. Remember this is a basic setup and you must secure your server after doing this!
1) Install Centos 7 minimal or what ever you prefer. This should also work with CentOS 6.
2) Update,Upgrade,remove old packages and clean CentOS
yum update
yum upgrade
yum autoremove
yum clean all
3)
Install nano and wget
yum Install nano and wget
4)
Install the Epel repository.
yum install epel-release
5) Install the Remi repository.
wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
sudo rpm -Uvh remi-release-7*.rpm
6)
Enable Remi and PHP56
nano /etc/yum.repos.d/remi.repo
set enabled=1 under [remi] and [remi-php56]
7)
Create an Nginx Repository.
nano /etc/yum.repos.d/nginx.repo
Paste these lines with right click if using putty.
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
Ctrl + x and type y to save.
8)
Create a Virtual Repository.
nano /etc/yum.repos.d/virtualmin.repo
Paste these lines with right click if using putty.
[virtualmin]
name=RHEL/CentOS/Scientific $releasever - $basearch - Virtualmin
baseurl=http://GPL:GPL@software.virtualmin.com/gpl/rhel/$releasever/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-virtualmin
gpgcheck=1
[virtualmin-universal]
name=Virtualmin Distribution Neutral Packages
baseurl=http://GPL:GPL@software.virtualmin.com/gpl/universal/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-virtualmin
gpgcheck=1
Ctrl + x and type y to save.
9) Install Webmin and Virtualmin RPM keys
cd /etc/pki/rpm-gpg/
wget http://software.virtualmin.com/lib/RPM-GPG-KEY-virtualmin
cd ~
wget http://www.webmin.com/jcameron-key.asc && rpm --import jcameron-key.asc
10)
Install Webmin.
yum install webmin
You can then login to webmin using your IP addesss https://127.0.0.1:10000
Once here you can use this chance to change the default port of Webmin and SSH.
11)
Install Virtualmin
yum install wbm-virtual-server
12)
Install MariaDB
yum install mariadb mariadb-server
13) After install go to Webmin -> servers -> virtual servers GPL and go through the setup. Once finished go to features and plugins and disable; Apache website Bind DNS Mail for domain Webalizer reporting
14)
Install Nginx
yum install Nginx
15) Install the virtualmin nginx and virtualmin nginx ssl module that I have provided. Download the file, go to webmin -> webmin configuration -> webmin modules and install the module from the download you may want to click enable for all users also. https://github.com/TwinFuture/virtualmin-nginx/releases/tag/v1.0 https://github.com/TwinFuture/virtualmin-nginx-ssl/releases/tag/v1.0
16)
Install php56
yum install php56 php56-php-xml php56-php-gd php56-php-imap php56-php-mysql php56-php-odbc php56-php-pear php56-php-snmp php56-php-xmlrpc php56-php-mbstring php56-php-fpm php56-php-mcrypt
Once all this is installed don't forget to run mysql_secure_installation
So once we have finished installing and setting up everything we now need to make sure we have disabled the plugins and features listed above. You also need to check Virtualmin configuration and setup what Virtualmin will be used for.
Head over to Virtualmin -> System Settings -> Features and plugins and click on configure on Nginx website. Execute PHP scripts using PHP-FPM, check this radio box. You can setup the paths and commands to php-fpm if you know them but it will attempt to get them automatically on first creation of virtual server and save them for you.
Also is best to use a directory for new virtual hosts so check "File or directory for new virtual hosts" and insert a location such as /etc/nginx/conf.d Save and then create your first virtual host.
You should notice a new conf file inside your Nginx conf.d directory and your php-fpm.d directory and that's pretty much it for setting up nginx and php-fpm automatically.
Here is a screenshot of my setup configuration for Nginx. http://i.imgur.com/uDfK87v.png
I plan on adding a panel for php-fpm to edit zones and configuration panels easily with a gui. I already started to code a panel.
I may of missed some things out also all comments and replies are welcome!
More info or questions can be answered @ https://www.uniquez-home.com/index.php?topic=29
How to do NGINX, MariaDB on Ubuntu?
Use the automated standard Virtualmin install script, and then install and switch the web server and the database server to your preferences. Doing it manually would work, but is unnecessary complexity.
--
Check out the forum guidelines!
i'm interested to try this on centos 7.3, but i'm new to virtualmin. some questions:
also, what are your thoughts on roland's work on nginx as reverse proxy? https://www.webfoobar.com/node/35
under Configure Virtualmin, he's listed a script that will automate the creation of website virtual host Nginx configuration file each time Virtualmin created a new server.
he's setting things up for drupal in mind, but i guess i could replace drupal with wordpress and adjust accordingly
thank you!