x

Active Group: Uniquez TalkBox

  • General
  • Whispers
  • Groups

Please log-in OR Register to view the Talkbox
Everyone must make a new account!


Webmin, Virtualmin, PHP-FPM, NGINX setup module.

  • 2 Replies
  • 1000 Views

0 Members and 1 Guest are viewing this topic.

*

oOo--STAR--oOo

  • *
  • Full Member
  • Founder
  • 140 40
  • Nostradamus feeling super marvellous.
Webmin, Virtualmin, PHP-FPM, NGINX setup module.
« : January 30, 17, 02:33 AM »
Download Modules

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
Code: [Select]
yum update
yum upgrade
yum autoremove
yum clean all
3) Install nano and wget
Code: [Select]
yum Install nano and wget
4) Install the Epel repository.
Code: [Select]
yum install epel-release
5) Install the Remi repository.
Code: [Select]
wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
sudo rpm -Uvh remi-release-7*.rpm
6) Enable Remi and PHP56
Code: [Select]
nano /etc/yum.repos.d/remi.repo set enabled=1 under [remi] and [remi-php56]

7) Create an Nginx Repository.
Code: [Select]
nano /etc/yum.repos.d/nginx.repo Paste these lines with right click if using putty.
Code: [Select]
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
Ctrl + x and type y to save.

Create a Virtual Repository.
Code: [Select]
nano /etc/yum.repos.d/virtualmin.repo Paste these lines with right click if using putty.
Code: [Select]
[virtualmin]
name=RHEL/CentOS/Scientific $releasever - $basearch - Virtualmin
baseurl=http://GPL:[email protected]/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:[email protected]/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
Code: [Select]
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.
Code: [Select]
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
Code: [Select]
yum install wbm-virtual-server
12) Install MariaDB
Code: [Select]
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
Code: [Select]
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
https://github.com/TwinFuture/virtualmin-nginx-ssl/releases

16) Install php56
Code: [Select]
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.



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!

« Last Edit: February 16, 17, 11:32 PM by oOo--STAR--oOo »
You can't fool a sufficiently talented fool!

*

Alcaline

  • *
  • Newbie
  • 20 7
  • Oo Laaa Laaa
Re: Webmin, Virtualmin, PHP-FPM, NGINX setup module.
« Reply #1: February 16, 17, 06:15 PM »

I tried your tutorial.
It s great. I still need to make a couple tests.

I've an issue with fail2ban (with shorewall). Daemon not start. I hope it will soon resolve.

*

oOo--STAR--oOo

  • *
  • Full Member
  • Founder
  • 140 40
  • Nostradamus feeling super marvellous.
Re: Webmin, Virtualmin, PHP-FPM, NGINX setup module.
« Reply #2: February 16, 17, 11:25 PM »
Module has been updated with some small fixes and tweaks.
« Last Edit: February 16, 17, 11:32 PM by oOo--STAR--oOo »
You can't fool a sufficiently talented fool!