CentOS 7 पर PHP, PHP-FPM और MariaDB के साथ लाइटटैप कैसे स्थापित करें


लाइटटैप अन्य वेब सर्वरों की तुलना में कम मेमोरी उपयोग के साथ गति-गंभीर वातावरण के लिए डिज़ाइन किया गया एक खुला स्रोत, सुरक्षित, तेज, लचीला और अधिक अनुकूलित वेब सर्वर है।

यह प्रभावी सीपीयू-लोड प्रबंधन के साथ एक सर्वर में समानांतर 10,000 कनेक्शन को संभाल सकता है और उन्नत सुविधा के साथ आता है जैसे कि FastCGI, SCGI, Auth, Output-Compression, URL-Rewriting और बहुत कुछ।

लाइटटैप हर लिनक्स सर्वर के लिए उत्कृष्ट समाधान है, इसकी उच्च गति io- बुनियादी ढांचे के कारण जो हमें अन्य वैकल्पिक वेब-सर्वरों की तुलना में समान हार्डवेयर के साथ कई गुना बेहतर प्रदर्शन करने की अनुमति देता है।

इस ट्यूटोरियल में, हम PHPt-FPM और MariaDB CentOS/RHEL 7 के साथ लाइटटैप स्थापित करने का तरीका बताएंगे। hostname के साथ वितरण tecmint.example.com और IP पता 192.168.0.103

चरण 1: CentOS 7 पर लाइटटपैड स्थापित करें

1। लाइटटैप स्थापित करने के लिए, सबसे पहले आपको निम्न आदेश का उपयोग करके अपने सिस्टम सॉफ़्टवेयर पैकेज और उपलब्ध रिपॉजिटरी को अपडेट करना होगा।

# yum -y update

2। इसके बाद, आपको अपने सिस्टम पर EPEL रिपॉजिटरी को सक्षम करने और निम्नलिखित आदेशों का उपयोग करके सॉफ़्टवेयर पैकेज अपडेट करने की आवश्यकता है।

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

3। जब आप EPEL रिपॉजिटरी को सक्षम कर लेते हैं, तो आप अब निम्न कमांड चलाकर लाइटटैप इंस्टॉल कर सकते हैं।

# yum install lighttpd

4। Lighttpd पैकेज इंस्टॉल हो जाने के बाद, आप बूट समय पर स्वचालित रूप से शुरू करने के लिए सेवा को सक्षम और सक्षम कर सकते हैं और निम्न कमांड का उपयोग करके स्थिति को सत्यापित करना सुनिश्चित कर सकते हैं।

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

यदि आपको स्थिति में नीचे के समान कोई त्रुटि संदेश दिखाई देता है, तो आपको किसी भी त्रुटि संदेश को प्रदर्शित किए बिना इसे ठीक से शुरू करने के लिए कुछ चीजों को ठीक करने की आवश्यकता है।

Dec 10 02:14:26 linux-console.net lighttpd[1463]: 2018-12-10 02:14:26: (network.c.167) warning: please use server.use-ipv6 only for hostnames, not without server.bind / empty address...ONLY changes
Dec 10 02:14:26 linux-console.net lighttpd[1463]: 2018-12-10 02:14:26: (server.c.1352) can't have more connections than fds/2:  1024 1024
Hint: Some lines were ellipsized, use -l to show in full.

किसी भी संपादक के साथ /etc/lighttpd/lighttpd.conf नामक फ़ाइल खोलें।

# vi /etc/lighttpd/lighttpd.conf

server.use-ipv6 को से सक्षम करने वाली रेखा बदलें से अक्षम करें । यह ऊपर दिखाए गए त्रुटि संदेशों को ठीक करेगा।

##
## Use IPv6?
##
server.use-ipv6 = "disable"

अब लाइटटैप शुरू करने के लिए फिर से प्रयास करें, यह बिना किसी त्रुटि संदेशों के 100% काम करना चाहिए।

# systemctl restart lighttpd
# systemctl status lighttpd

5। अब निम्नलिखित कमांड का उपयोग करके अपने सिस्टम पर स्थापित लाइटटैप के संस्करण को सत्यापित करें।

# lighttpd -v

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

6। अब आपको अपने फ़ायरवॉल पर HTTP और HTTPS ट्रैफ़िक की अनुमति देने की आवश्यकता है।

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

7। अब अपना ब्राउज़र खोलें और अपने लाइटटैप वेब सर्वर को काम करते हुए देखने के लिए निम्न URL पर इंगित करें।

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

लाइटटपैड के लिए डिफ़ॉल्ट दस्तावेज़ रूट निर्देशिका /var/www/lighttpd/ है और मुख्य कॉन्फ़िगरेशन फ़ाइल /etc/lighttpd/lighttpd.conf के अंतर्गत स्थित है।

चरण 2: CentOS 7 में मारियाडीबी को MySQL के रूप में स्थापित करना

8। अगला, निम्न आदेशों का उपयोग करके लाइटकैप के लिए MySQL समर्थन स्थापित करें।

# yum -y install mariadb mariadb-server

9। एक बार इंस्टॉलेशन पूरा हो जाने के बाद, निम्न आदेशों का उपयोग करके MariaDB की स्थिति को शुरू, सक्षम और सत्यापित करें।

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

10। अंत में, आपको निम्नलिखित आदेश जारी करके अपनी मारबीडीबी स्थापना को सुरक्षित करना होगा।

# mysql_secure_installation

आपको अपने MariaDB इंस्टॉलेशन के बारे में कुछ अलग-अलग प्रश्न बताए जाएंगे और आप इसे कैसे सुरक्षित करना चाहेंगे। आप डेटाबेस रूट उपयोगकर्ता पासवर्ड को बदल सकते हैं, परीक्षण डेटाबेस को अक्षम कर सकते हैं, अनाम उपयोगकर्ताओं को अक्षम कर सकते हैं और रूट लॉगिन को दूरस्थ रूप से अक्षम कर सकते हैं।

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 authorisation. 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 सर्वर से कनेक्ट करने का प्रयास करें और टर्मिनल पर निम्न आदेशों के साथ अपने डेटाबेस सर्वर पर मौजूदा डेटाबेस की समीक्षा करें।

# 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: CentOS 7 पर FastCGI के साथ PHP और PHP-FPM स्थापित करना

12। PHP-FPM को FastCGI समर्थन के साथ सक्षम करने के लिए, पहले आपको आवश्यक एक्सटेंशन के साथ PHP इंस्टॉल करना होगा। निम्नलिखित आदेश।

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

13। एक बार PHP स्थापित, अब सक्षम PHP-FPM और FastCGI Lighttpd , ऐसा करने के लिए आपको इन पैकेजों को भी स्थापित करना होगा।

# yum -y install php-fpm lighttpd-fastcgi

14। अब /etc/php-fpm.d/www.conf नामक एक फ़ाइल खोलें।

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

उपयोगकर्ता और समूह को 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

15। अब PHP-FPM सेवा शुरू करें और निम्न आदेशों का उपयोग करके इसे स्वचालित रूप से बूट समय पर शुरू करने में सक्षम करना सुनिश्चित करें।

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

चरण 4: लाइटकैप में FastCGI के साथ PHP और PHP-FPM को सक्षम करना

16। यहां, हमें तीन फ़ाइलों को संशोधित करने की आवश्यकता है /etc/php.ini , /etc/lighttpd/modules.conf और Lighttpd के लिए PHP समर्थन सक्षम करने के लिए /etc/lighttpd/conf.d/fastcgi.conf

पहली फ़ाइल खोलें /etc/php.ini

# vi /etc/php.ini

निम्न पंक्ति को अन-टिप्पणी करें जो कहती है लाइन 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

फिर /etc/lighttpd/modules.conf नामक दूसरी फ़ाइल खोलें।

# vi /etc/lighttpd/modules.conf

निम्नलिखित लाइन को अन-कॉमेंट करें जो कहती है कि "conf.d/fastcgi.conf" शामिल करें।

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

अगला, /etc/lighttpd/conf.d/fastcgi.conf नामक तीसरी फ़ाइल खोलें।

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

अब फाइल के नीचे दिए गए कंटेनर को जोड़ें और इसे सेव करें।

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

परिवर्तनों को प्रतिबिंबित करने और PHP समर्थन को सक्षम करने के लिए लाइटटैप सेवा को पुनरारंभ करें।

# systemctl restart lighttpd

17। जैसा कि हमने ऊपर कहा है कि लाइटटैप के लिए डिफ़ॉल्ट दस्तावेज़ रूट /var/www/lighttpd/ है। तो, यहां हम इस निर्देशिका में एक phpinfo.php फ़ाइल बनाएंगे।

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

इसमें निम्न पंक्तियाँ जोड़ें। कोड का यह छोटा सा टुकड़ा उनके संस्करणों के साथ PHP स्थापना के बारे में जानकारी प्रदर्शित करेगा।

<?php
phpinfo();
?>

18। अपना ब्राउज़र खोलें और निम्न लिंक पर जाएं।

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

आपको PHP , PHP-FPM और MySQL की कार्य सूचना बहुत सारे अन्य मॉड्यूल के साथ दिखाई देगी जो पहले से ही सक्षम हैं।