Ṣiṣeto Nginx pẹlu MariaDB ati PHP/PHP-FPM lori Fedora 24 Server ati Ibi iṣẹ


O gbọdọ ti fi sori ẹrọ ẹda olupin Fedora 24 sori ẹrọ rẹ ati pe o ni itara ati nireti lati ṣeto olupin ayelujara kan lati ṣiṣe awọn oju opo wẹẹbu ati awọn ohun elo wẹẹbu. Ma ṣe wa siwaju, nitori awa yoo ṣe gbogbo iyẹn nihin, pẹlu awọn igbesẹ ti o rọrun ati rọrun ti iwọ yoo ni riri ni ipari.

Ninu eyi bawo ni a ṣe le ṣe itọsọna, a yoo ṣiṣẹ nipasẹ awọn igbesẹ oriṣiriṣi ti bii o ṣe le fi akopọ LEMP sori olupin wẹẹbu Fedora 24 rẹ. Iru si atupa, ṣugbọn labẹ LEMP, a lo olupin ayelujara Nginx.

Igbesẹ 1: Nmu Awọn idii Eto ṣiṣẹ

O le bẹrẹ nipasẹ mimu awọn idii eto rẹ ṣe bi atẹle:

# dnf update

Nigbati o ba ti ṣe iyẹn, tẹsiwaju lati fi sori ẹrọ awọn idii LEMP apapo.

Igbesẹ 2: Fi Nginx Web Server sii

Nginx jẹ omiiran si olupin wẹẹbu Apache, o jẹ iwuwo ina ati jẹun eto eto ti o kere si nitorinaa iṣẹ giga rẹ, iduroṣinṣin ati irọrun ni awọn agbegbe iṣelọpọ iṣelọpọ.

Lati fi Nginx sori Fedora 24, gbekalẹ aṣẹ ni isalẹ:

# dnf install nginx  

Lọgan ti fifi sori ẹrọ ba pari, o nilo lati ṣakoso iṣẹ Nginx lori ẹrọ rẹ. Ni akọkọ o nilo lati ṣeto lati bẹrẹ laifọwọyi ni akoko bata nipasẹ ṣiṣe aṣẹ ni isalẹ:

# systemctl enable nginx.service

Lẹhinna bẹrẹ iṣẹ bi atẹle:
# systemctl bẹrẹ nginx.service

Nigbamii, ṣayẹwo lati rii pe olupin Nginx nṣiṣẹ, o le fun ni aṣẹ ni isalẹ lati ṣe eyi:

# systemctl status nginx.service

Lati le wo olupin ayelujara Nginx rẹ lori ilana HTTP/HTTPS, o nilo lati gba aaye laaye si ọdọ rẹ nipasẹ ogiriina eto. Lati ṣe bẹ, ṣiṣe awọn ofin wọnyi:

# firewall-cmd --permanent --add-service=http
# firewall-cmd --permanent --add-service=https

Lẹhinna tun gbe awọn atunto ogiriina eto lati ni ipa awọn ayipada loke bi atẹle:

# systemctl reload firewalld

Bayi tẹsiwaju lati ṣeto itọsọna Nginx olupin_name rẹ, ni lilo olootu ayanfẹ rẹ, ṣii faili /etc/nginx/nginx.conf ki o wa itọsọna iṣeto bi o ti han:

server_name server-ip-address;

Akiyesi: gbongbo ilana iwe Nginx jẹ /usr/share/nginx/html , ati pe eyi ni ibiti o le gbe gbogbo awọn faili wẹẹbu rẹ si.

Ohun pataki diẹ sii lati ṣe labẹ fifi sori Nginx ni lati ṣayẹwo boya oju-iwe atọka fifi sori ẹrọ Nginx le fifuye ninu aṣawakiri wẹẹbu rẹ, nitorinaa ṣii ẹrọ lilọ kiri lori ayelujara rẹ ki o tẹ URL sii:

http://server-ip-address

O yẹ ki o ni anfani lati wo oju-iwe yii ni isalẹ:

Igbesẹ 3: Fi sori ẹrọ olupin MariaDB

MariaDB jẹ orita ti olupin data ibatan ibatan MySQL olokiki julọ, lati fi MariaDB sori olupin Fedora 24, gbekalẹ aṣẹ ni isalẹ:

# dnf install mariadb-server

Lẹhin ipari fifi sori ẹrọ MariaDB, o nilo lati muu ṣiṣẹ, bẹrẹ ati ṣayẹwo iṣẹ naa nipasẹ ṣiṣe atẹle awọn ofin.

# systemctl enable mariadb-service  
# systemctl start mariadb-service 
# systemctl status mariadb-service  

Bayi o to akoko lati ni aabo fifi sori ẹrọ MariaDB rẹ nipa lilo pipaṣẹ atẹle:

# mysql_secure_installation

Lẹhin ṣiṣe pipaṣẹ loke, ao beere ibeere diẹ bi atẹle:

Enter current password for root(enter for none): Here, Simply press [Enter]
Next you will be asked to set a root user password for your MariaDB server.
Set root password? [Y/n]: y and hit [Enter]
New password: Enter a new password for root user
Re-enter new password: Re-enter the above password 
Remove anonymous users? [Y/n]: y to remove anonymous users
It is not always good to keep your system open to remote access by root user, in case an attacker lands on your root user password, he/she can cause damage to your system. 
Disallow root login remotely? [Y/n]: y to prevent remote access for root user. 
Remove test database and access to it? [Y/n]: y to remove the test database
Finally, you need to reload privileges tables on your database server for the above changes to take effect.
Reload privileges tables now? [Y/n]: y to reload privileges tables 

Igbesẹ 4: Fi PHP ati Awọn modulu sii

Lati fi PHP sori Fedora 24 pẹlu awọn modulu rẹ, lo aṣẹ ni isalẹ:

# dnf install php php-commom php-fpm php-mysql php-gd

Bayi pe PHP ati diẹ ninu awọn modulu PHP ti pari fifi sori ẹrọ, o nilo lati tunto PHP ki o le ṣiṣẹ awọn faili PHP.

Nipa aiyipada, a ṣe atunto PHP-FPM lati ṣee lo pẹlu olupin ayelujara Apache, ṣugbọn fun ọran wa nibi, a nlo olupin wẹẹbu Nginx. Nitorinaa a nilo lati yi eto yẹn pada ni awọn igbesẹ isalẹ:

Lilo olootu ayanfẹ rẹ, ṣii faili /etc/php-fpm.d/www.conf bi atẹle:

# vi /etc/php-fpm.d/www.conf

Lẹhinna yi awọn iye olumulo ati ẹgbẹ pada lati afun si nginx ni awọn ila wọnyi:

; RPM: apache Choosed to be able to access some dir as httpd 
user = nginx 
; RPM: Keep a group allowed to write in log dir. 
group = nginx

Lẹhinna tun bẹrẹ PHP-FPM ati olupin ayelujara Nginx lati ṣe awọn ayipada loke:

# systemctl restart php-fpm.services
# systemctl restart nginx.services

Lẹhin eyini, jẹrisi pe wọn nṣiṣẹ n ṣe awọn ofin ni isalẹ:

# systemctl status php-fpm.services
# systemctl status nginx.services

Bayi o le idanwo gbogbo rẹ, ni lilo olootu ayanfẹ rẹ, ṣẹda faili kan ti a pe ni info.php ninu itọsọna root root Nginx rẹ bi atẹle:

# vi /usr/share/nginx/html/info.php

Ṣafikun awọn ila wọnyi ninu faili naa, fipamọ ati jade.

<?php
phpinfo()
?>

Lẹhinna ṣii ẹrọ aṣawakiri wẹẹbu rẹ ki o tẹ URL atẹle si lati rii daju alaye PHP:

http://server-ip-address/info.php

Ni aaye yii, o gbọdọ ti fi sori ẹrọ daradara ati tunto akopọ LEMP lori olupin Fedora 24 rẹ. Ni awọn ọrọ diẹ, diẹ ninu rẹ gbọdọ ti ni awọn aṣiṣe aṣiṣe tabi fẹ alaye diẹ sii nipa ọrọ ti ibakcdun, o le fi asọye silẹ ni abala ọrọ asọye ni isalẹ ati pe a yoo wa awọn solusan papọ.