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


Lighttpd buɗaɗɗen tushe ne, amintacce, mai sauri, sassauƙa, kuma ƙarin ingantaccen sabar gidan yanar gizo wanda aka ƙera don mahalli masu mahimmancin sauri tare da ƙarancin amfani da ƙwaƙwalwar ajiya idan aka kwatanta da sauran sabar yanar gizo.

Yana iya ɗaukar har zuwa haɗin kai 10,000 a layi daya a cikin sabar guda ɗaya tare da ingantaccen sarrafa nauyin CPU kuma ya zo tare da saiti na ci gaba kamar FastCGI, SCGI, Auth, Output-Compression, URL-Rewriting da ƙari mai yawa.

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

A cikin wannan koyawa, zamuyi bayanin yadda ake shigar da Lighttpd tare da PHP, PHP-FPM, da MariaDB akan rarrabawar CentOS/RHEL 8/7 tare da sunan mai masaukin linux-console.net da adireshin IP 192.168.0.103.

Mataki 1: Shigar Lighttpd Web Server

1. Don shigar da Lighttpd, da farko, kuna buƙatar sabunta fakitin software na tsarin ku da ma'ajiyar ajiyar ku ta amfani da umarnin yum mai zuwa.

# yum -y update

2. Na gaba, kuna buƙatar kunna ma'ajin EPEL akan tsarin ku kuma sabunta fakitin software ta amfani da umarni masu zuwa.

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

3. Da zarar kun kunna ma'ajiyar EPEL, yanzu zaku iya shigar da Lighttpd ta hanyar aiwatar da umarni mai zuwa.

# yum install lighttpd

4. Da zarar an shigar da fakitin Lighttpd, zaku iya farawa kuma kunna sabis ɗin don farawa ta atomatik a lokacin taya kuma tabbatar da tabbatar da matsayin ta amfani da umarni masu zuwa.

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

5. Yanzu tabbatar da nau'in Lighttpd da aka sanya akan 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 ba da izinin zirga-zirgar HTTP da HTTPS akan Tacewar zaɓinku.

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

7. Yanzu bude burauzar ku kuma ku nuna URL mai zuwa don ganin sabar yanar gizon ku ta Lighttpd tana aiki.

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

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

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

8. Na gaba, shigar da goyon bayan MySQL don Lighttpd ta amfani da umarni masu zuwa.

# yum -y install mariadb mariadb-server

9. Da zarar an gama shigarwa, fara, kunna, da kuma tabbatar da matsayin MariaDB ta amfani da umarni masu zuwa.

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

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

# mysql_secure_installation

Za a yi muku wasu ƴan tambayoyi daban-daban game da shigarwar MariaDB da kuma yadda kuke son amintar da shi. Kuna iya canza kalmar sirrin tushen tushen bayanai, musaki bayanan gwajin, musaki masu amfani da ba a san su ba, da kuma hana tushen shiga daga 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 duba bayanan da ke akwai akan uwar garken bayananku tare da umarni masu zuwa 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 3: Shigar da PHP da PHP-FPM tare da FastCGI akan CentOS 7

12. Don ba da damar PHP-FPM tare da tallafin FastCGI, da farko, kuna buƙatar shigar da PHP tare da kari mai mahimmanci ta amfani da umarni mai zuwa.

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

13. Da zarar an shigar da PHP, yanzu ba da damar tallafin PHP-FPM da FastCGI don Lighttpd, don yin wannan kuna buƙatar shigar da waɗannan fakiti kuma.

# yum -y install php-fpm lighttpd-fastcgi

14. Yanzu bude fayil mai suna /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 tsohuwa yana amfani da /var/run/php/php7.0-fpm.sock soket, kuna buƙatar yin PHP-FPM don amfani da haɗin TCP. Yi layin saurara ya zama kamar haka:

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

15. Yanzu fara sabis na PHP-FPM kuma tabbatar da kunna shi don farawa ta atomatik a lokacin taya ta amfani da umarni masu zuwa.

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

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

16. Anan, muna buƙatar canza fayiloli guda uku /etc/php.ini, /etc/lighttpd/modules.conf da /etc/lighttpd/conf.d/fastcgi.conf don ba da damar tallafin PHP don Lighttpd.

Bude fayil na farko /etc/php.ini.

# vi /etc/php.ini

Ba da sharhi kan layi mai 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

Rashin ba da sharhi kan layi mai zuwa wanda ya ce sun haɗa da conf.d/fastcgi.conf.

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

Na gaba, buɗe fayil na uku mai suna /etc/lighttpd/conf.d/fastcgi.conf.

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

Yanzu ƙara akwati mai zuwa a kasan fayil ɗin kuma ajiye shi.

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

Sake kunna sabis ɗin Lighttpd don nuna canje-canje da ba da damar tallafin PHP.

# systemctl restart lighttpd

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

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

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

Ƙara layin masu zuwa gare shi. Wannan ƙaramin lambar zai nuna bayani game da shigarwa na PHP tare da nau'ikan su.

<?php
phpinfo();
?>

18. Bude burauzar ku kuma kewaya zuwa hanyoyin da ke biyowa.

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

Za ku ga bayanin aiki na PHP, PHP-FPM, da MySQL tare da ɗimbin sauran kayayyaki waɗanda aka riga aka kunna.