Automatically install configure Nginx with php-fpm and one from MySQL, PostgreSQL database

This article will help all of us to automatically install, configure Nginx with PHP-FPM, configure virtual host and will rpovide us choose one of MySQL or PostgreSQL databases.
We have two server. CentOS7 and FreeBSD10.

GIT repository for codes. To download codes from GIT repository you must be install GIT and use the following command:
# git clone https://github.com/jamalshahverdiev/nginx-phphpm-mysql-postgresql.git

To install and configure Python2.7 or Python3.4 in laptop or in server we can use this script.

./ngphfpmypg.py script require input from console for IP, login, pass, virtual host name, db name, db user and for db pass.
If entered Virtual Host is exists on server script will provide new script with name ./add-vhost-ngphfpmypg.py for add virtual host.
Scripts working on CentOS7 and FreeBSD10 servers. I am doing tests for each of servers.

Lets start install and configure Nginx with MySQL and PHP-FPM for each of servers:
fpyvenv ngmysqlphpng # ./ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.20
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: linux.com
This is CentOS server...
Please be patient, installing nginx server...
Nginx server installed and configured...
1. If you want install and configure MySQL with PHP-FPM write 1 and press "Enter"!!!
2. If you want install and configure PostgreSQL with PHP-FPM write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select: 1
You have selected "Enter" button!!!
Please be patient, it will take some time...
SQL service already running...
Enter name for new database: linuxdb
Enter user name for database: linuxuser
Enter pass for linuxuser:
Repeat pass for linuxuser:
Entered passwords must be the same. Please enter passwords again.
Please enter password:
Please repeat password:
The password set successfully!
MySQL, Nginx and PHP-FPM installed and configured...

fpyvenv ngmysqlphpng # ./ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.40
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: linux.com
This is FreeBSD server...
Please be patient, installing nginx server...
Nginx server installed and configured...
1. If you want install and configure MySQL with PHP-FPM write 1 and press "Enter"!!!
2. If you want install and configure PostgreSQL with PHP-FPM write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select: 1
You have chose MySQL with PHP-FPM!
Please be patient, it will take some time...
SQL service already running...
Enter name for new database: linuxdb
Enter user name for database: linuxuser
Enter pass for linuxuser:
Repeat pass for linuxuser:
MySQL, Nginx and PHP-FPM installed and configured...

Now I will install and configure Nginx with php-fpm and PostgreSQL for each of sevrers:
fpyvenv ngmysqlphpng # ./ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.20
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: linux.com
This is CentOS server...
Please be patient, installing nginx server...
Nginx server installed and configured...
1. If you want install and configure MySQL with PHP-FPM write 1 and press "Enter"!!!
2. If you want install and configure PostgreSQL with PHP-FPM write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select: 2
You have chose PostgreSQL with PHP-FPM!
Please be patient, it will take some time...
SQL service already running...
Enter name for new database: linuxdb
Enter user name for database: linuxuser
Enter pass for linuxuser:
Repeat pass for linuxuser:
Entered passwords must be the same. Please enter passwords again.
Please enter password:
Please repeat password:
Entered passwords must be the same. Please enter passwords again.
Please enter password:
Please repeat password:
The password set successfully!
PostgreSQL, Nginx and PHP-FPM installed and configured...

fpyvenv ngmysqlphpng # ./ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.40
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: linux.com
This is FreeBSD server...
Please be patient, installing nginx server...
Nginx server installed and configured...
1. If you want install and configure MySQL with PHP-FPM write 1 and press "Enter"!!!
2. If you want install and configure PostgreSQL with PHP-FPM write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select: 2
You have chose PostgreSQL with PHP-FPM!
Please be patient, it will take some time...
SQL service already running...
Enter name for new database: linuxdb
Enter user name for database: linuxuser
Enter pass for linuxuser:
Repeat pass for linuxuser:
Entered passwords must be the same. Please enter passwords again.
Please enter password:
Please repeat password:
The password set successfully!
PostgreSQL, Nginx and PHP-FPM installed and configured...

Try to add existing virtual host for each of servers:
fpyvenv ngmysqlphpng # ./ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.20
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: linux.com
This is CentOS server...
You have already installed and running Nginx web server...
If you want add new VirtualHost, please use ./add-vhost-ngphfpmypg.py script.

fpyvenv ngmysqlphpng # ./ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.40
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: linux.com
This is FreeBSD server...
You have already installed and running Nginx web server...
If you want add new VirtualHost, please use ./add-vhost-ngphfpmypg.py script.

Try to add new virtual host and not install any of database:
fpyvenv ngmysqlphpng # ./ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.20
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: linux.com
This is CentOS server...
Please be patient, installing nginx server...
Nginx server installed and configured...
1. If you want install and configure MySQL with PHP-FPM write 1 and press "Enter"!!!
2. If you want install and configure PostgreSQL with PHP-FPM write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select:
You pressed "Enter" button, exiting!!!

fpyvenv ngmysqlphpng # ./ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.40
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: linux.com
This is FreeBSD server...
Please be patient, installing nginx server...
Nginx server installed and configured...
1. If you want install and configure MySQL with PHP-FPM write 1 and press "Enter"!!!
2. If you want install and configure PostgreSQL with PHP-FPM write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select:
You pressed "Enter" button, exiting!!!

Now I will use ./add-vhost-ngphfpmypg.py script for each of server to add new virtual host.

Try to add existing virtual host name:
fpyvenv ngmysqlphpng # ./add-vhost-ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.20
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: linux.com
This is CentOS server...
Entered domain name linux.com is already exists on the 172.16.100.20 server!!!
Please enter different name than "linux.com" !!!

fpyvenv ngmysqlphpng # ./add-vhost-ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.40
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: linux.com
This is FreeBSD server...
Entered domain name linux.com is already exists on the 172.16.100.40 server!!!
Please enter different name than "linux.com" !!!

Try to add new virtual host with not configured MySQL database:
fpyvenv ngmysqlphpng # ./add-vhost-ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.20
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: unixmen.com
This is CentOS server...
You have already running Nginx web server...
Virtual host unixmen.com already configured...
1. To add MySQL database for this virtual host write 1 and press "Enter"!!!
2. To add PostgreSQL database for this virtual host write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select: 1
You have chose MySQL with PHP-FPM!
Please check SQL service!!!

fpyvenv ngmysqlphpng # ./add-vhost-ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.40
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: unixmen.com
This is FreeBSD server...
You have already running Nginx web server...
Virtual host unixmen.com already configured...
1. To add MySQL database for this virtual host write 1 and press "Enter"!!!
2. To add PostgreSQL database for this virtual host write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select: 1
You have chose MySQL with PHP-FPM!
Please check SQL service!!!

Try to add new virtual host with already configured PostgreSQL database:
fpyvenv ngmysqlphpng # ./add-vhost-ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.20
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: linuxmen.com
This is CentOS server...
You have already running Nginx web server...
Virtual host linuxmen.com already configured...
1. To add MySQL database for this virtual host write 1 and press "Enter"!!!
2. To add PostgreSQL database for this virtual host write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select: 2
You have chose PostgreSQL with PHP-FPM!
You have already running PostgreSQL database server...
Enter name for new database: linuxmendb
Enter user name for database: linuxmenuser
Enter pass for linuxmenuser:
Repeat pass for linuxmenuser:
Entered passwords must be the same. Please enter passwords again.
Please enter password:
Please repeat password:
The password set successfully!
PostgreSQL database and Nginx configured for your site: linuxmen.com

fpyvenv ngmysqlphpng # ./add-vhost-ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.40
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: linuxmen.com
This is FreeBSD server...
You have already running Nginx web server...
Virtual host linuxmen.com already configured...
1. To add MySQL database for this virtual host write 1 and press "Enter"!!!
2. To add PostgreSQL database for this virtual host write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select: 2
You have chose PostgreSQL with PHP-FPM!
You have already running PostgreSQL database server...
Enter name for new database: linuxmendb
Enter user name for database: linuxmenuser
Enter pass for linuxmenuser:
Repeat pass for linuxmenuser:
Entered passwords must be the same. Please enter passwords again.
Please enter password:
Please repeat password:
The password set successfully!
PostgreSQL database and Nginx configured for your site: linuxmen.com

Try to add new virtual host with not configured PostgreSQL database:
fpyvenv ngmysqlphpng # ./add-vhost-ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.20
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: freebsd.com
This is CentOS server...
You have already running Nginx web server...
Virtual host freebsd.com already configured...
1. To add MySQL database for this virtual host write 1 and press "Enter"!!!
2. To add PostgreSQL database for this virtual host write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select: 2
You have chose PostgreSQL with PHP-FPM!
Please check SQL service!!!

fpyvenv ngmysqlphpng # ./add-vhost-ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.20
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: freebsd.com
This is CentOS server...
You have already running Nginx web server...
Virtual host freebsd.com already configured...
1. To add MySQL database for this virtual host write 1 and press "Enter"!!!
2. To add PostgreSQL database for this virtual host write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select: 2
You have chose PostgreSQL with PHP-FPM!
Please check SQL service!!!

At the end, try to add new virtual host with already configured MySQL database:
fpyvenv ngmysqlphpng # ./add-vhost-ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.20
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: unixmen.com
This is CentOS server...
You have already running Nginx web server...
Virtual host unixmen.com already configured...
1. To add MySQL database for this virtual host write 1 and press "Enter"!!!
2. To add PostgreSQL database for this virtual host write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select: 1
You have chose MySQL with PHP-FPM!
You have already running MySQL database server...
Enter name for new database: unixmendb
Enter user name for database: unixmenuser
Enter pass for unixmenuser:
Repeat pass for unixmenuser:
Entered passwords must be the same. Please enter passwords again.
Please enter password:
Please repeat password:
The password set successfully!
MySQL database and Nginx configured for your site: unixmen.com

fpyvenv ngmysqlphpng # ./add-vhost-ngphfpmypg.py
Please enter WEB server IP address: 172.16.100.40
Please enter username for UNIX/Linux server: root
Password:
Please enter site name: unixmen.com
This is FreeBSD server...
You have already running Nginx web server...
Virtual host unixmen.com already configured...
1. To add MySQL database for this virtual host write 1 and press "Enter"!!!
2. To add PostgreSQL database for this virtual host write 2 and press "Enter"!!!
3. If you want to exit from script just press "Enter" button.
Please select: 1
You have chose MySQL with PHP-FPM!
You have already running MySQL database server...
Enter name for new database: unixmendb
Enter user name for database: unixmenuser
Enter pass for unixmenuser:
Repeat pass for unixmenuser:
Entered passwords must be the same. Please enter passwords again.
Please enter password:
Please repeat password:
The password set successfully!
MySQL database and Nginx configured for your site: unixmen.com

  • Pingback: Automatically install configure Nginx with php-fpm and one from MySQL, PostgreSQL database | Tech News()

  • I got paid 104 thousand dollars last year by freelancing from my house and I did that by w­orking part-time f­o­r few h daily. I followed work model I came across online and I am excited that I was able to earn so much extra income. It’s very user friendly a­n­d I’m so happy that i discovered it. This is what i do… http://www.wzurl­.­me/8bX__A

  • jacqueline.burton

    I was paid 104000 dollars previous year by doing an on-line task and consequently I was able to do it by w­orking in my own time f­o­r quite a few hours on a regular basis. I used job opportunity I found on-line and so I am thrilled that I was able to make such good money. It’s seriously newbie-friendly and I am so blessed that I found out about it. Read through exactly what I do… http://secure10­.­weebly­.­com

  • M­a­n­y p­e­o­ple w­a­nt t­o ha­v­e a awesome in­com­e at h­o­me, bu­t t­he­y don’t have much idea ho­w t­o exactly d­o th­at o­n th­e Int­ernet. Th­ere ar­e a l­ot of w­ays t­o ea­rn significant am­ount of mo­ney, b­ut wh­enev­er p­eopl­e t­ry th­at the­y g­et tr­app­ed in a fraud, And so I am sh­aring wi­th yo­u a g­enuine an­d gu­arante­ed w­ay f­or fre­e to ea­rn hug­e am­ount of mon­ey a­t ho­me.I am making atleast $10000 monthly since 1 year.Its on-line job and really easy to do, Even a little child can do this job and make online money. If you want a happy and rich life then you should copy and paste this online site in web browser and then follow instructions to get started right now and earn Thousands Over the internet……….. http://s­.­id/1cn

  • M­a­n­y p­e­o­ple wish t­o ha­v­e a high earnings at h­o­me, bu­t t­he­y don’t have much idea ho­w t­o exactly d­o th­at o­n th­e Int­ernet. Th­ere ar­e a l­ot of w­ays t­o ea­rn am­ount of mo­ney, b­ut wh­enev­er p­eopl­e t­ry th­at the­y g­et tr­app­ed in a s­cam, Thus I am sh­aring wi­th yo­u a g­enuine an­d gu­arante­ed w­ay f­or fre­e to ea­rn hug­e am­ount of mon­ey a­t ho­me.I am making atleast $10000 monthly since a year.Its on-line job and also really easy to do, Even a little boy or girl can do this job and make money online. If you want a happy and wealthy life then you need to copy and paste this site in web browser and then follow instructions to get started right now and earn Thousands On the internet……….. http://shrty­.­link/SmWHqQ