Artikel ini akan membantu kita semua untuk menginstal secara otomatis, mengkonfigurasi Nginx dengan PHP-FPM, mengkonfigurasi virtual host dan akan membuat kita memilih salah satu database MySQL atau PostgreSQL.
Kami memiliki dua server. CentOS7 dan FreeBSD10.
Kami memiliki dua server. CentOS7 dan FreeBSD10.
GIT repository untuk kode . Untuk mendownload kode dari gudang GIT Anda harus menginstal GIT dan menggunakan perintah berikut:
# git clone https://github.com/jamalshahverdiev/nginx-phphpm-mysql-postgresql.git
# git clone https://github.com/jamalshahverdiev/nginx-phphpm-mysql-postgresql.git
Untuk menginstal dan mengkonfigurasi Python2.7 atau Python3.4 di laptop atau di server kita bisa menggunakan script ini .
./ngphfpmypg.py script memerlukan masukan dari konsol untuk IP, login, pass, nama host virtual, nama db, pengguna db dan untuk db pass.
Jika masuk Virtual Host ada pada script server akan memberikan script baru dengan nama ./add-vhost-ngphfpmypg.py untuk menambahkan virtual host.
Script bekerja pada server CentOS7 dan FreeBSD10. Saya melakukan tes untuk masing-masing server.
Jika masuk Virtual Host ada pada script server akan memberikan script baru dengan nama ./add-vhost-ngphfpmypg.py untuk menambahkan virtual host.
Script bekerja pada server CentOS7 dan FreeBSD10. Saya melakukan tes untuk masing-masing server.
Mari kita mulai menginstal dan mengkonfigurasi Nginx dengan MySQL dan PHP-FPM untuk setiap server:
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...
Sekarang saya akan menginstal dan mengkonfigurasi Nginx dengan php-fpm dan PostgreSQL untuk masing-masing 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...
Cobalah menambahkan virtual host yang ada untuk masing-masing server:
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.
Cobalah untuk menambahkan virtual host baru dan tidak menginstal database apapun:
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!!!
Sekarang saya akan menggunakan script ./add-vhost-ngphfpmypg.py untuk setiap server untuk menambahkan virtual host baru.
Cobalah menambahkan virtual host yang ada untuk masing-masing server:
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.
Cobalah untuk menambahkan virtual host baru dan tidak menginstal database apapun:
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!!!
Sekarang saya akan menggunakan script ./add-vhost-ngphfpmypg.py untuk setiap server untuk menambahkan virtual host baru.
Coba tambahkan nama host virtual yang ada:
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" !!!
Coba tambahkan virtual host baru dengan database MySQL yang tidak terkonfigurasi:
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!!!
Coba tambahkan virtual host baru dengan database PostgreSQL yang sudah terkonfigurasi:
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
Cobalah menambahkan virtual host baru dengan database PostgreSQL yang tidak terkonfigurasi:
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!!!
Pada akhirnya, cobalah menambahkan virtual host baru dengan database MySQL yang sudah dikonfigurasi:
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
EmoticonEmoticon