Otu esi etinye Lighttpd na PHP na MariaDB na CentOS/RHEL 8/7


Lighttpd bụ isi mmalite mepere emepe, echekwara, ngwa ngwa, mgbanwe na sava weebụ emebere maka gburugburu dị oke egwu yana obere ebe nchekwa na-eji ya tụnyere sava weebụ ndị ọzọ.

Ọ nwere ike ijikwa ihe ruru njikọ 10,000 na otu ihe nkesa nwere njikwa ibu CPU dị irè ma na-abịa na njirimara dị elu dị ka FastCGI, SCGI, Auth, Output-Compression, URL-Rewriting na ọtụtụ ndị ọzọ.

Lighttpd bụ ezigbo ngwọta maka ihe nkesa Linux ọ bụla, n'ihi ngwa ngwa io-infrastructure ya dị elu nke na-enye anyị ohere iji otu ngwaike rụọ ọrụ ọtụtụ ugboro karịa nke sava weebụ ọzọ.

N'ime nkuzi a, anyị ga-akọwa otu esi etinye Lighttpd na PHP, PHP-FPM, na MariaDB na nkesa CentOS/RHEL 8/7 nwere aha nnabata linux-console.net na adreesị IP 192.168.0.103.

Nzọụkwụ 1: Wụnye Lighttpd Web Server

1. Iji wụnye Lighttpd, nke mbụ, ịkwesịrị imelite ngwugwu ngwanrọ sistemụ gị yana ebe nchekwa dịnụ site na iji iwu yum na-esonụ.

# yum -y update

2. Ọzọ, ịkwesịrị ịme ka ebe nchekwa EPEL dị na sistemụ gị wee melite ngwugwu ngwanrọ site na iji iwu ndị a.

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

3. Ozugbo i mebere ebe nchekwa EPEL, ị nwere ike tinye Lighttpd ugbu a site na ịme iwu na-esonụ.

# yum install lighttpd

4. Ozugbo etinyere ngwugwu Lighttpd, ị nwere ike ịmalite ma mee ka ọrụ ahụ malite na-akpaghị aka n'oge buut ma jide n'aka na ị kwadoro ọnọdụ ahụ site na iji iwu ndị a.

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

5. Ugbu a nyochaa ụdị Lighttpd arụnyere na sistemụ gị site na iji iwu a.

# lighttpd -v

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

6. Ugbu a ịkwesịrị ikwe ka okporo ụzọ HTTP na HTTPS na firewall gị.

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

7. Ugbu a mepee ihe nchọgharị gị wee tụọ aka na URL ndị a ka ịhụ sava weebụ Lighttpd gị na-arụ ọrụ.

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

Akwụkwọ ndekọ mgbọrọgwụ ndabere maka Lighttpd bụ /var/www/lighttpd/ na faịlụ nhazi bụ isi dị n'okpuru /etc/lighttpd/lighttpd.conf.

Kwụpụ 2: Ịwụnye MariaDB dị ka MySQL na CentOS 7

8. Ọzọ, wụnye nkwado MySQL maka Lighttpd site na iji iwu ndị a.

# yum -y install mariadb mariadb-server

9. Ozugbo echichi zuru ezu, malite, mee, ma nyochaa ọnọdụ nke MariaDB site na iji iwu ndị a.

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

10. N'ikpeazụ, ị ga-achọ ijide n'aka nwụnye MariaDB gị site n'inye iwu na-esonụ.

# mysql_secure_installation

A ga-akpali gị ajụjụ ole na ole dị iche iche gbasara nrụnye MariaDB gị yana otu ịchọrọ ịchekwa ya. Ị nwere ike ịgbanwe paswọọdụ onye ọrụ mgbọrọgwụ nchekwa data, gbanyụọ nchekwa data ule, gbanyụọ ndị ọrụ na-amaghị aha, ma gbanyụọ mgbọrọgwụ nbanye na anya.

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. Gbalịa ijikọ na MySQL nkesa na-enyocha data data dị na gị nchekwa data nkesa na-esonụ iwu na ọnụ.

# 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)]>

Kwụpụ 3: Wụnye PHP na PHP-FPM na FastCGI na CentOS 7

12. Iji mee ka PHP-FPM nwee nkwado FastCGI, nke mbụ, ịkwesịrị ịwụnye PHP yana mgbakwunye dị mkpa site na iji iwu a.

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

13. Ozugbo PHP arụnyere, ugbu a mee ka PHP-FPM na FastCGI nkwado maka Lighttpd, iji mee nke a ịkwesịrị ịwụnye ngwugwu ndị a.

# yum -y install php-fpm lighttpd-fastcgi

14. Ugbu a mepee faịlụ a na-akpọ /etc/php-fpm.d/www.conf.

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

Tọọ onye ọrụ na otu ka 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

Ọzọkwa, PHP-FPM site na ndabara na-eji /var/run/php/php7.0-fpm.sock socket, ịkwesịrị ịme PHP-FPM iji jiri njikọ TCP. Mee ka ahịrị ntị dị ka nke a:

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

15. Ugbu a malite ọrụ PHP-FPM ma jide n'aka na ị ga-eme ka ọ malite na-akpaghị aka n'oge buut site na iji iwu ndị a.

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

Kwụpụ 4: Na-enyere PHP na PHP-FPM aka na FastCGI na Lighttpd

16. N'ebe a, anyị kwesịrị ịgbanwe faịlụ atọ /etc/php.ini, /etc/lighttpd/modules.conf na /etc/lighttpd/conf.d/fastcgi.conf iji mee ka nkwado PHP maka Lighttpd.

Mepee faịlụ mbụ /etc/php.ini.

# vi /etc/php.ini

Wepu okwu ahịrị na-esote nke na-ekwu ahịrị 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

Mepee faịlụ nke abụọ akpọrọ /etc/lighttpd/modules.conf.

# vi /etc/lighttpd/modules.conf

Wepu okwu ahịrị na-esote nke na-ekwu gụnyere conf.d/fastcgi.conf.

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

Ọzọ, mepee faịlụ nke atọ a na-akpọ /etc/lighttpd/conf.d/fastcgi.conf.

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

Ugbu a tinye akpa a na ala nke faịlụ wee chekwaa ya.

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

Malitegharịa ọrụ Lighttpd iji gosipụta mgbanwe wee mee nkwado PHP.

# systemctl restart lighttpd

Kwụpụ 5: Na-anwale PHP na PHP-FPM na nkwado FastCGI na Lighttpd

17. Dị ka anyị kwuru n'elu na ndabere akwụkwọ mgbọrọgwụ maka Lighttpd bụ /var/www/lighttpd/. Yabụ, ebe a anyị ga-emepụta faịlụ phpinfo.php n'ime ndekọ a.

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

Tinye ahịrị ndị a na ya. Obere koodu a ga-egosipụta ozi gbasara nrụnye PHP na ụdị ha.

<?php
phpinfo();
?>

18. Mepee ihe nchọgharị gị wee gaa na njikọ ndị a.

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

Ị ga-ahụ ozi na-arụ ọrụ nke PHP, PHP-FPM, na MySQL na ọtụtụ modul ndị ọzọ enyerelarị.