Yadda ake Shigar Lighttpd tare da PHP da MariaDB akan CentOS/RHEL 8/7


Lighttpd shine tushen buɗewa, amintacce, mai sauri, mai sassauƙa, kuma mafi ingantaccen sabar gidan yanar gizo wanda aka tsara don yanayin mawuyacin hali tare da ƙarancin amfani da ƙwaƙwalwar ajiya idan aka kwatanta da sauran sabar yanar gizo.

Zai iya ɗaukar har zuwa haɗin 10,000 a layi ɗaya a cikin sabar ɗaya tare da ingantaccen sarrafawar CPU-load kuma ya zo tare da ingantaccen fasalin fasali kamar FastCGI, SCGI, Auth, Output-Compression, URL-Rewriting da ƙari mai yawa.

Lighttpd kyakkyawan bayani ne ga kowane sabar Linux, saboda saurin-io-kayan aikin da ke ba mu damar haɓaka sau da yawa mafi kyawun aiki tare da kayan aiki ɗaya fiye da sauran madadin sabar yanar gizo.

A cikin wannan darasin, zamuyi bayanin yadda ake girka Lighttpd tare da PHP, PHP-FPM, da MariaDB akan rarraba CentOS/RHEL 8/7 tare da sunan mai masauki linux-console.net da adireshin IP 192.168.0.103.

Mataki 1: Shigar da Gidan yanar gizo na Lighttpd

1. Don girka Lighttpd, da farko, kuna buƙatar sabunta kunshin software na tsarinku da wadatar wuraren ajiya ta amfani da umarnin yum mai zuwa.

# yum -y update

2. Na gaba, kuna buƙatar kunna wurin ajiyar EPEL akan tsarinku kuma sabunta kunshin software ta amfani da waɗannan umarnin.

# yum -y install epel-release
# yum -y update

3. Da zarar ka kunna wurin ajiyar EPEL, yanzu zaka iya shigar da Lighttpd ta hanyar bin umarnin nan.

# yum install lighttpd

4. Da zarar an shigar da fakitin Lighttpd, zaka iya farawa da kunna sabis ɗin don farawa ta atomatik a lokacin taya kuma tabbatar da tabbatar da halin ta amfani da waɗannan umarnin.

# systemctl start lighttpd
# systemctl enable lighttpd
# systemctl status lighttpd

5. Yanzu tabbatar da sigar Lighttpd da aka sanya a kan tsarin ku ta amfani da umarni mai zuwa.

# lighttpd -v

lighttpd/1.4.55 (ssl) - a light and fast webserver

6. Yanzu kuna buƙatar bada izinin zirga-zirgar HTTP da HTTPS akan bangonku.

# firewall-cmd --permanent --zone=public --add-service=http
# firewall-cmd --permanent --zone=public --add-service=https
# firewall-cmd --reload

7. Yanzu buɗe burauzarka ka nuna URL na gaba don ganin Lighttpd webserver ɗin yana aiki.

http://Your-Domain.com
OR
http://Your-IP-addr

Tsoffin kundin tushen daftarin aiki na Lighttpd shine/var/www/lighttpd/kuma babban fayil ɗin daidaitawa yana ƙarƙashin /etc/lighttpd/lighttpd.conf.

Mataki 2: Shigar da MariaDB azaman MySQL a cikin CentOS 7

8. Na gaba, girka goyon bayan MySQL na Lighttpd ta amfani da wadannan umarni.

# yum -y install mariadb mariadb-server

9. Da zarar an gama girkawa, fara, kunna, kuma tabbatar da matsayin MariaDB ta amfani da wadannan umarni.

# systemctl start mariadb.service
# systemctl enable mariadb.service
# systemctl status mariadb.service

10. A ƙarshe, kuna buƙatar tabbatar da shigarwar MariaDB ɗinku ta hanyar bayar da umarni mai zuwa.

# mysql_secure_installation

Za a sa ku wasu 'yan tambayoyi daban-daban game da shigarwar MariaDB da yadda kuke son tabbatar da shi. Kuna iya canza kalmar sirri ta mai amfani da tushen bayanai, musaki bayanan gwajin, musaki masu amfani da ba a sani ba, da kuma dakatar da shiga tushen nesa.

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): Enter OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorization. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!

11. Gwada haɗawa zuwa uwar garken MySQL kuma sake nazarin bayanan data kasance akan sabar uwar garkenku tare da bin umarni akan tashar.

# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.60-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]>

Mataki na 3: Shigar da PHP da PHP-FPM tare da FastCGI akan CentOS 7

12. Don kunna PHP-FPM tare da tallafi na FastCGI, da farko, kuna buƙatar shigar da PHP tare da ƙarin faɗaɗa masu amfani ta amfani da umarni mai zuwa.

# yum -y install php php-mysqlnd php-pdo php-gd php-mbstring

13. Da zarar an girka PHP, yanzu kunna PHP-FPM da FastCGI tallafi don Lighttpd, don yin wannan kuna buƙatar shigar da waɗannan fakitin suma.

# yum -y install php-fpm lighttpd-fastcgi

14. Yanzu buɗe fayil ɗin da ake kira /etc/php-fpm.d/www.conf.

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

Saita mai amfani da rukuni zuwa Lighttpd.

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = lighttpd
; RPM: Keep a group allowed to write in log dir.
group = lighttpd

Hakanan, PHP-FPM ta tsoffin amfani /var/run/php/php7.0-fpm.sock soket, kuna buƙatar yin PHP-FPM don amfani da haɗin TCP. Sanya layin a saurara kamar haka:

;listen = /var/run/php/php7.0-fpm.sock
listen = 127.0.0.1:9000 

15. Yanzu fara sabis ɗin PHP-FPM kuma tabbatar cewa an ba shi damar farawa ta atomatik a lokacin taya ta amfani da waɗannan umarnin.

# systemctl start php-fpm.service
# systemctl enable php-fpm.service

Mataki na 4: Kunna PHP da PHP-FPM tare da FastCGI a cikin Lighttpd

16. Anan, muna buƙatar gyara fayiloli uku /etc/php.ini, /etc/lighttpd/modules.conf da /etc/lighttpd/conf.d/fastcgi.conf don bawa PHP tallafi ga Lighttpd.

Bude fayil na farko /etc/php.ini.

# vi /etc/php.ini

Kada a yi sharhi game da layin da ke zuwa wanda ya ce layi cgi.fix_pathinfo = 1.

; cgi.fix_pathinfo provides *real* PATH_INFO/PATH_TRANSLATED support for CGI.  PHP's
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is.  For more information on PATH_INFO, see the cgi specs.  Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec.  A setting
; of zero causes PHP to behave as before.  Default is 1.  You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://php.net/cgi.fix-pathinfo
cgi.fix_pathinfo=1

Sannan bude fayil na biyu mai suna /etc/lighttpd/modules.conf.

# vi /etc/lighttpd/modules.conf

Un-comment da layi mai zuwa wanda yace sun hada da "conf.d/fastcgi.conf".

##
## FastCGI (mod_fastcgi)
##
include "conf.d/fastcgi.conf"

Na gaba, buɗe fayil na uku da ake kira /etc/lighttpd/conf.d/fastcgi.conf.

# vi /etc/lighttpd/conf.d/fastcgi.conf

Yanzu ƙara wannan akwatin mai zuwa a ƙasan fayil ɗin kuma adana shi.

fastcgi.server += ( ".php" =>
        ((
                "host" => "127.0.0.1",
                "port" => "9000",
                "broken-scriptfilename" => "enable"
        ))
)

Sake kunna sabis na Lighttpd don nuna canje-canje da ba da damar tallafi na PHP.

# systemctl restart lighttpd

Mataki 5: Gwada PHP da PHP-FPM tare da Tallafin FastCGI a cikin Lighttpd

17. Kamar yadda muka fada a sama cewa asalin rubutaccen tushe na Lighttpd shine/var/www/lighttpd /. Don haka, a nan za mu ƙirƙiri fayil ɗin phpinfo.php a cikin wannan kundin adireshin.

# vi /var/www/lighttpd/info.php

Sanya layuka masu zuwa a ciki. Wannan ƙananan lambar za su nuna bayanai game da shigarwar PHP tare da sigar su.

<?php
phpinfo();
?>

18. Buɗe burauzarka kuma yi amfani da waɗannan hanyoyin.

http://Your-Domain.com/info.php
OR
http://Your-IP-addr/info.php

Za ku ga bayanan aiki na PHP, PHP-FPM, da MySQL tare da yawancin wasu matakan da aka riga aka kunna.