CentOS/RHEL 8/7-de PHP we MariaDB bilen Lighttpd-i nädip gurmaly
Lighttpd, beýleki web serwerleri bilen deňeşdirilende ýadyň az ulanylmagy bilen çalt kritiki gurşaw üçin döredilen açyk çeşme, ygtybarly, çalt, çeýe we has optimal web serweridir.
CPU-da täsirli dolandyryş bilen bir serwerde 10,000-e çenli baglanyşygy dolandyryp bilýär we FastCGI, SCGI, Auth, Output-Compression, URL-Rewriting we başgalar ýaly ösen aýratynlyk toplumy bilen gelýär.
“Lighttpd”, ýokary tizlikli io-infrastrukturasy sebäpli, beýleki alternatiw web serwerlerine garanyňda şol bir enjam bilen birnäçe esse gowy öndürijiligi ölçemäge mümkinçilik berýän her Linux serweri üçin ajaýyp çözgütdir.
Bu gollanmada, Lighttpd-i PHP, PHP-FPM we MariaDB bilen CentOS/RHEL 8/7 paýlanyşynda hostname linux-console.net we IP adresi 192.168.0.103 bilen nädip gurmalydygyny düşündireris.
1-nji ädim: Lighttpd web serwerini guruň
1. Lighttpd-i gurmak üçin ilki bilen aşakdaky yum buýrugyny ulanyp ulgam programma üpjünçilik paketleriňizi we elýeterli ammarlary täzelemeli.
# yum -y update
2. Ondan soň, ulgamyňyzdaky EPEL ammaryny işletmeli we aşakdaky buýruklary ulanyp programma üpjünçiligini täzelemeli.
# yum -y install epel-release # yum -y update
3. EPEL ammaryny açanyňyzdan soň, aşakdaky buýrugy işledip, Lighttpd gurup bilersiňiz.
# yum install lighttpd
4. “Lighttpd” paketleri gurlandan soň, hyzmaty awtomatiki usulda başlamaga başlap, aşakdaky buýruklary ulanyp, ýagdaýy barlap bilersiňiz.
# systemctl start lighttpd # systemctl enable lighttpd # systemctl status lighttpd
5. Indi aşakdaky buýrugy ulanyp ulgamyňyza gurlan Lighttpd wersiýasyny barlaň.
# lighttpd -v lighttpd/1.4.55 (ssl) - a light and fast webserver
6. Indi gorag diwaryňyzda HTTP we HTTPS traffigine rugsat bermeli.
# firewall-cmd --permanent --zone=public --add-service=http # firewall-cmd --permanent --zone=public --add-service=https # firewall-cmd --reload
7. Indi brauzeriňizi açyň we Lighttpd web serweriňiziň işleýändigini görmek üçin aşakdaky URL-e görkeziň.
http://Your-Domain.com OR http://Your-IP-addr
Lighttpd üçin deslapky resminama kök katalogy/var/www/lighttpd/we esasy konfigurasiýa faýly /etc/lighttpd/lighttpd.conf astynda ýerleşýär.
2-nji ädim: CentOS 7-de MariaDB-ni MySQL hökmünde gurmak
8. Ondan soň, aşakdaky buýruklary ulanyp, Lighttpd üçin MySQL goldawyny guruň.
# yum -y install mariadb mariadb-server
9. Gurmak tamamlanandan soň, aşakdaky buýruklary ulanyp, MariaDB-iň ýagdaýyny başlaň, işlediň we barlaň.
# systemctl start mariadb.service # systemctl enable mariadb.service # systemctl status mariadb.service
10. Netijede, aşakdaky buýrugy berip, MariaDB gurnamagyňyzy üpjün etmeli bolarsyňyz.
# mysql_secure_installation
MariaDB gurnamagyňyz we ony nädip goramak isleýändigiňiz barada size birnäçe dürli sorag berler. Maglumat bazasynyň kök ulanyjy parolyny üýtgedip, synag maglumatlar bazasyny öçürip, näbelli ulanyjylary öçürip we kök girişini uzakdan öçürip bilersiňiz.
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. MySQL serwerine birikdirip görüň we terminaldaky aşakdaky buýruklar bilen maglumatlar bazasynyň serwerindäki bar bolan maglumat bazalaryny gözden geçiriň.
# 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)]>
3-nji ädim: CentOS 7-de FastCGI bilen PHP we PHP-FPM gurmak
12. FastCGI goldawy bilen PHP-FPM-i işletmek üçin ilki bilen aşakdaky buýrugy ulanyp, zerur giňeltmeler bilen birlikde PHP gurmaly.
# yum -y install php php-mysqlnd php-pdo php-gd php-mbstring
13. PHP gurlansoň, indi Lighttpd üçin PHP-FPM we FastCGI goldawyny işlediň, munuň üçin bu paketleri hem gurmaly bolarsyňyz.
# yum -y install php-fpm lighttpd-fastcgi
14. Indi /etc/php-fpm.d/www.conf atly bir faýl açyň.
# vi /etc/php-fpm.d/www.conf
Ulanyjyny we toparyny Lighttpd-e düzüň.
; 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
Şeýle hem, PHP-FPM deslapky görnüşde /var/run/php/php7.0-fpm.sock rozetkasyny ulanýar, TCP birikmesini ulanmak üçin PHP-FPM etmeli. diňlemek
setirini aşakdaky ýaly ediň:
;listen = /var/run/php/php7.0-fpm.sock listen = 127.0.0.1:9000
15. Indi PHP-FPM hyzmatyna başlaň we aşakdaky buýruklary ulanyp, boot wagtynda awtomatiki başlamagyny üpjün ediň.
# systemctl start php-fpm.service # systemctl enable php-fpm.service
4-nji ädim: Lighttpd-de FastCGI bilen PHP we PHP-FPM açmak
16. Bu ýerde, Lighttpd üçin PHP goldawyny işjeňleşdirmek üçin /etc/php.ini, /etc/lighttpd/modules.conf we /etc/lighttpd/conf.d/fastcgi.conf üç faýly üýtgetmeli.
Ilkinji faýl /etc/php.ini açyň.
# vi /etc/php.ini
Cgi.fix_pathinfo=1 setiri diýilýän aşakdaky setire düşündiriş bermäň.
; 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
Soňra /etc/lighttpd/modules.conf atly ikinji faýly açyň.
# vi /etc/lighttpd/modules.conf
Conf.d/fastcgi.conf diýilýän aşakdaky setire teswir ýazmaň.
## ## FastCGI (mod_fastcgi) ## include "conf.d/fastcgi.conf"
Ondan soň /etc/lighttpd/conf.d/fastcgi.conf atly üçünji faýly açyň.
# vi /etc/lighttpd/conf.d/fastcgi.conf
Indi faýlyň aşagyna aşakdaky konteýner goşuň we ýazdyryň.
fastcgi.server += ( ".php" => (( "host" => "127.0.0.1", "port" => "9000", "broken-scriptfilename" => "enable" )) )
Üýtgeşmeleri görkezmek we PHP goldawyny işjeňleşdirmek üçin Lighttpd hyzmatyny täzeden açyň.
# systemctl restart lighttpd
5-nji ädim: Lighttpd-de FastCGI goldawy bilen PHP we PHP-FPM synagy
17. aboveokarda aýdyşymyz ýaly Lighttpd üçin deslapky resminama kökü/var/www/lighttpd /. Şeýlelikde, bu ýerde bu kataloga phpinfo.php faýly dörederis.
# vi /var/www/lighttpd/info.php
Oňa aşakdaky setirleri goşuň. Bu kiçijik kod bölegi, wersiýalary bilen PHP gurmak barada maglumatlary görkezer.
<?php phpinfo(); ?>
18. Brauzeriňizi açyň we aşakdaky baglanyşyklara geçiň.
http://Your-Domain.com/info.php OR http://Your-IP-addr/info.php
PHP, PHP-FPM we MySQL-iň iş maglumatlaryny eýýäm işledilen başga-da köp modul bilen görersiňiz.