柚子快報激活碼778899分享:lnmp架構(gòu)
柚子快報激活碼778899分享:lnmp架構(gòu)
簡介
LNMP架構(gòu)是一種常見的Web服務(wù)器架構(gòu),由Linux、Nginx、MySQL和PHP組成。它是一套成熟、穩(wěn)定、安全的Web服務(wù)器架構(gòu),廣泛應(yīng)用于各類中大型企業(yè)級應(yīng)用和互聯(lián)網(wǎng)站點(diǎn)。LNMP架構(gòu)的主要特點(diǎn)和優(yōu)勢如下:
高性能和高并發(fā):Nginx作為LNMP架構(gòu)中的Web服務(wù)器,具有出色的性能和高并發(fā)處理能力。它采用事件驅(qū)動的非阻塞I/O模型,能夠高效地處理大量并發(fā)連接和請求,適合于高流量的網(wǎng)站和應(yīng)用程序。同時,Nginx在處理請求時采用較少的內(nèi)存資源,對系統(tǒng)資源的消耗相對較低,使得LNMP架構(gòu)在資源受限的環(huán)境下表現(xiàn)出色。 安全性高:LNMP架構(gòu)提供了許多安全性保障。例如,Nginx可以通過HTTP認(rèn)證和SSL/TLS加密來提供數(shù)據(jù)和服務(wù)的安全性。 靈活性:LNMP可以安裝于多個平臺和多個版本的Linux操作系統(tǒng)上,同時還可以容易地進(jìn)行自定義和擴(kuò)展以適應(yīng)不同的應(yīng)用需求。 易用性:LNMP具有易用性,不需要額外的復(fù)雜配置即可完成安裝和配置。 高可靠性:LNMP使用MySQL作為后端數(shù)據(jù)庫,具有數(shù)據(jù)可靠性高、備份恢復(fù)容易等優(yōu)點(diǎn)。同時,MySQL還提供了復(fù)制和分區(qū)等特性,以支持容錯和高可用性需求。
LNMP架構(gòu)的工作原理主要如下:用戶通過瀏覽器訪問Nginx Web網(wǎng)站,Nginx服務(wù)器接收到用戶的請求后,先判斷請求的URL,根據(jù)URL和配置進(jìn)行匹配,檢測請求的Web文件是靜態(tài)還是動態(tài)網(wǎng)站。如果是靜態(tài)HTML,Nginx直接處理并響應(yīng)給客戶端;如果是動態(tài)PHP(或其他腳本語言),Nginx會將請求發(fā)送給后端的PHP模塊或CGI,PHP解釋器將動態(tài)網(wǎng)頁解析為靜態(tài)的HTML網(wǎng)頁,然后返回給Nginx,Nginx再將解析后的HTML靜態(tài)網(wǎng)頁結(jié)果返回給客戶。
總的來說,LNMP架構(gòu)以其高性能、安全性、靈活性、易用性和高可靠性,成為目前互聯(lián)網(wǎng)公司主流的一種Web架構(gòu),特別適用于處理高并發(fā)、多并發(fā)連接、大流量網(wǎng)站的情景。
環(huán)境
redhat 9
nginx:1.24.0
步驟
修改主機(jī)名
[root@admin ~]# hostnamectl hostname lnmp
[root@admin ~]# bash
[root@lnmp ~]#
?設(shè)置防火墻規(guī)則允許http,https通行
[root@lnmp ~]# firewall-cmd --zone=public --add-service=http --permanent
success //zone設(shè)置防火墻區(qū)域public,適用于
[root@lnmp ~]#
[root@lnmp ~]# firewall-cmd --zone=public --add-service=https --permanent
success
[root@lnmp ~]# firewall-cmd --zone=public --add-port=443/tcp --permanent
success
[root@lnmp ~]# firewall-cmd --zone=public --add-port=8080/tcp --permanent
success
[root@lnmp ~]# firewall-cmd --reload
success
下載nginx源碼包,并解壓
官網(wǎng):https://nginx.org/download/nginx-1.24.0.tar.gz
[root@lnmp ~]# wget -c https://nginx.org/download/nginx-1.24.0.tar.gz
--2024-04-23 09:23:37-- https://nginx.org/download/nginx-1.24.0.tar.gz
正在解析主機(jī) nginx.org (nginx.org)... 3.125.197.172, 52.58.199.22, 2a05:d014:5c0:2600::6, ...
正在連接 nginx.org (nginx.org)|3.125.197.172|:443... 已連接。
已發(fā)出 HTTP 請求,正在等待回應(yīng)... 200 OK
長度:1112471 (1.1M) [application/octet-stream]
正在保存至: “nginx-1.24.0.tar.gz”
nginx-1.24.0.tar.gz 100%[===========================================================================================>] 1.06M 835KB/s 用時 1.3s
2024-04-23 09:23:39 (835 KB/s) - 已保存 “nginx-1.24.0.tar.gz” [1112471/1112471])
[root@lnmp ~]#
[root@lnmp ~]# wget -c https://nginx.org/download/nginx-1.24.0.tar.gz //-c斷點(diǎn)續(xù)傳
--2024-04-23 09:23:37-- https://nginx.org/download/nginx-1.24.0.tar.gz
正在解析主機(jī) nginx.org (nginx.org)... 3.125.197.172, 52.58.199.22, 2a05:d014:5c0:2600::6, ...
正在連接 nginx.org (nginx.org)|3.125.197.172|:443... 已連接。
已發(fā)出 HTTP 請求,正在等待回應(yīng)... 200 OK
長度:1112471 (1.1M) [application/octet-stream]
正在保存至: “nginx-1.24.0.tar.gz”
nginx-1.24.0.tar.gz 100%[===========================================================================================>] 1.06M 835KB/s 用時 1.3s
2024-04-23 09:23:39 (835 KB/s) - 已保存 “nginx-1.24.0.tar.gz” [1112471/1112471])
[root@lnmp ~]# tar xf nginx-1.24.0.tar.gz
?安裝依賴包
[root@lnmp ~]# yum -y install gcc make gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
正在更新 Subscription Management 軟件倉庫。
無法讀取客戶身份
本系統(tǒng)尚未在權(quán)利服務(wù)器中注冊??墒褂?subscription-manager 進(jìn)行注冊。
上次元數(shù)據(jù)過期檢查:0:00:07 前,執(zhí)行于 2024年04月23日 星期二 09時51分27秒。
軟件包 pcre-8.44-3.el9.3.x86_64 已安裝。
軟件包 zlib-1.2.11-39.el9.x86_64 已安裝。
軟件包 openssl-1:3.0.7-6.el9_2.x86_64 已安裝。
依賴關(guān)系解決。
=================================================================================================================================================================================
軟件包 架構(gòu) 版本 倉庫 大小
=================================================================================================================================================================================
安裝:
gcc x86_64 11.3.1-4.3.el9 aa 32 M
gcc-c++ x86_64 11.3.1-4.3.el9 aa 13 M
make x86_64 1:4.3-7.el9 bb 542 k
openssl-devel x86_64 1:3.0.7-6.el9_2 aa 4.1 M
pcre-devel x86_64 8.44-3.el9.3 aa 511 k
zlib-devel x86_64 1.2.11-39.el9 aa 47 k
安裝依賴關(guān)系:
glibc-devel x86_64 2.34-60.el9 aa 54 k
glibc-headers x86_64 2.34-60.el9 aa 556 k
kernel-headers x86_64 5.14.0-284.11.1.el9_2 aa 5.0 M
libstdc++-devel x86_64 11.3.1-4.3.el9 aa 2.4 M
libxcrypt-devel x86_64 4.4.18-3.el9 aa 32 k
pcre-cpp x86_64 8.44-3.el9.3 aa 28 k
pcre-utf16 x86_64 8.44-3.el9.3 aa 188 k
pcre-utf32 x86_64 8.44-3.el9.3 aa 178 k
事務(wù)概要
=================================================================================================================================================================================
安裝 14 軟件包
省略。。。。。。
?創(chuàng)建nginx用戶
[root@lnmp ~]# useradd -s /sbin/nologin nginx
進(jìn)行預(yù)編譯 、編譯安裝
--with-http_ssl_module //Nginx 將會被編譯以支持 SSL/TLS 功能,通常用于 HTTPS 連接。
[root@lnmp ~]# useradd -s /sbin/nologin nginx
[root@lnmp ~]# cd /usr/local/src/nginx-1.24.0/
[root@lnmp nginx-1.24.0]# ls
auto CHANGES CHANGES.ru conf configure contrib html LICENSE man README src
[root@lnmp nginx-1.24.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module
checking for OS
+ Linux 5.14.0-284.11.1.el9_2.x86_64 x86_64
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 11.3.1 20221121 (Red Hat 11.3.1-4) (GCC)
checking for gcc -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gcc builtin atomic operations ... found
省略。。。。。。
[root@lnmp nginx-1.24.0]# make && make install //編譯安裝
make -f objs/Makefile
make[1]: 進(jìn)入目錄“/usr/local/src/nginx-1.24.0”
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \
-o objs/src/core/nginx.o \
src/core/nginx.c
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unu
省略。。。。。
啟動nginx,然后查看端口
[root@lnmp ~]# /usr/local/nginx/sbin/nginx
[root@lnmp ~]# ss -anltp | grep 80
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=8247,fd=6),("nginx",pid=8246,fd=6))
[root@lnmp ~]#
?瀏覽器訪問 ip
?安裝php、設(shè)置開機(jī)自啟
[root@lnmp ~]# yum -y install php*
正在更新 Subscription Management 軟件倉庫。
無法讀取客戶身份
本系統(tǒng)尚未在權(quán)利服務(wù)器中注冊。可使用 subscription-manager 進(jìn)行注冊。
上次元數(shù)據(jù)過期檢查:0:24:30 前,執(zhí)行于 2024年04月23日 星期二 09時51分27秒。
依賴關(guān)系解決。
=================================================================================================================================================================================
軟件包 架構(gòu) 版本 倉庫 大小
===================
省略 。。。。。。
[root@lnmp ~]# systemctl start php-fpm.service
[root@lnmp ~]# systemctl enable php-fpm.service
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
[root@lnmp ~]#
?配置nginx讓其支持php服務(wù)
[root@lnmp ~]# vim /usr/local/nginx/conf/nginx.conf
65 location ~ \.php$ {
66 root html;
67 fastcgi_pass 127.0.0.1:9000;
68 fastcgi_index index.php;
69 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;//修改請求腳本路徑
70 include fastcgi_params;
71 }
#修改php配置文件
[root@lnmp ~]# vim /etc/php-fpm.d/www.conf
24 user = nginx //改為nginx
25 ; RPM: Keep a group allowed to write in log dir.
26 group = nginx //改為nginx
38 listen = 127.0.0.1:9000 //listen改為本地IP加9000端口
[root@lnmp ~]# systemctl reload php-fpm
#增加一個index.php文件測試php是否可用
[root@lnmp ~]# vim /usr/local/nginx/html/index.php
1
2 phpinfo();
3 ?>
[root@lnmp ~]# /usr/local/nginx/sbin/nginx -s stop
[root@lnmp ~]# /usr/local/nginx/sbin/nginx
[root@lnmp ~]# ss -anltp |grep 80
LISTEN 0 511 0.0.0.0:80 0.0.0.0:* users:(("nginx",pid=12862,fd=6),("nginx",pid=12861,fd=6))
[root@lnmp ~]# ss -anltp | grep 9000
LISTEN 0 511 127.0.0.1:9000 0.0.0.0:* users:(("php-fpm",pid=18409,fd=10),("php-fpm",pid=13729,fd=10),("php-fpm",pid=13728,fd=10),("php-fpm",pid=13727,fd=10),("php-fpm",pid=13726,fd=10),("php-fpm",pid=13725,fd=10),("php-fpm",pid=13724,fd=8))
[root@lnmp ~]#
?瀏覽器測試
?安裝mariadb
[root@lnmp ~]# yum -y install mariadb*
正在更新 Subscription Management 軟件倉庫。
無法讀取客戶身份
本系統(tǒng)尚未在權(quán)利服務(wù)器中注冊。可使用 subscription-manager 進(jìn)行注冊。
上次元數(shù)據(jù)過期檢查:1:36:51 前,執(zhí)行于 2024年04月23日 星期二 09時51分27秒。
軟件包 mariadb-connector-c-3.2.6-1.el9_0.x86_64 已安裝。
軟件包 mariadb-connector-c-config-3.2.6-1.el9_0.noarch 已安裝。
依賴關(guān)系解決。
====================================================================================================================================================================================
軟件包 架構(gòu) 版本 倉庫 大小
====================================================================================================================================================================================
安裝:
mariadb x86_64 3:10.5.16-2.el9_0 aa 1.6 M
mariadb-backup x86_64 3:10.5.16-2.el9_0 aa 6.4 M
mariadb-common x86_64 3:10.5.16-2.el9_0 aa 39 k
mariadb-connector-c-devel x86_64 3.2.6-1.el9_0 aa 62 k
mariadb-connector-odbc x86_64 3.1.12-3.el9 aa 115 k
mariadb-embedded x86_64 3:10.5.16-2.el9_0 aa 5.3 M
mariadb-errmsg x86_64 3:10.5.16-2.el9_0 aa 227 k
mariadb-gssapi-server x86_64 3:10.5.16-2.el9_0 aa 21 k
mariadb-java-client noarch 3.0.3-1.el9 aa 969 k
mariadb-oqgraph-engine x86_64 3:10.5.16-2.el9_0 aa 87 k
mariadb-pam x86_64 3:10.5.16-2.el9_0 aa 31 k
mariadb-server x86_64 3:10.5.16-2.el9_0 aa 9.4 M
mariadb-server-galera x86_64 3:10.5.16-2.el9_0 aa 31 k
mariadb-server-utils x86_64 3:10.5.16-2.el9_0 aa 222 k
安裝依賴關(guān)系:
Judy x86_64 1.0.5-28.el9 aa 134 k
boost-program-options x86_64 1.75.0-8.el9 aa 108 k
copy-jdk-configs noarch 4.0-3.el9 aa 29 k
galera x86_64 26.4.11-1.el9_0 aa 1.2 M
java-11-openjdk-headless x86_64 1:11.0.18.0.10-2.el9_1 aa 40 M
javapackages-filesystem noarch 6.0.0-4.el9 aa 17 k
jna x86_64 5.6.0-8.el9 aa 274 k
jna-contrib noarch 5.6.0-8.el9 aa 549 k
lksctp-tools x86_64 1.0.19-2.el9 bb 98 k
lua x86_64 5.4.4-3.el9 aa 192 k
lua-posix x86_64 35.0-8.el9 aa 155 k
mysql-selinux noarch 1.0.5-1.el9_0 aa 37 k
perl-DBD-MariaDB x86_64 1.21-16.el9_0 aa 156 k
perl-Sys-Hostname x86_64 1.23-480.el9 aa 20 k
slf4j noarch 1.7.30-13.el9 aa 73 k
tzdata-java noarch 2022g-2.el9 aa 233 k
事務(wù)概要
====================================================================================================================================================================================
安裝 30 軟件包
[root@lnmp ~]# systemctl restart mariadb.service
[root@lnmp ~]# systemctl enable mariadb.service
Created symlink /etc/systemd/system/mysql.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/mysqld.service → /usr/lib/systemd/system/mariadb.service.
Created symlink /etc/systemd/system/multi-user.target.wants/mariadb.service → /usr/lib/systemd/system/mariadb.service.
[root@lnmp ~]# mysql_secure_installation //初始化設(shè)置
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
haven't set the root password yet, you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password or using the unix_socket ensures that nobody
can log into the MariaDB root user without the proper authorisation.
You already have your root account protected, so you can safely answer 'n'.
Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
... Success!
You already have your root account protected, so you can safely answer 'n'.
Change the root password? [Y/n]
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]
... 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]
... 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]
- 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]
... 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
?修改mariadb配置文件
[root@lnmp ~]# vim /etc/my.cnf.d/mariadb-server.cnf
[mysqld]
17 init_connect='SET collation_connection = utf8_unicode_ci'
18 init_connect='SET NAMES utf8'
19 character-set-server=utf8
20 collation-server=utf8_unicode_ci
21 skip-character-set-client-handshake
[root@lnmp ~]# vim /etc/my.cnf.d/mysql-clients.cnf
6 [mysql]
7 default-character-set=utf8
#重啟服務(wù)
[root@lnmp ~]# systemctl restart mariadb.service
[root@lnmp ~]# systemctl enable mariadb.service
[root@lnmp ~]#
?部署discuz論壇
官網(wǎng):Discuz!官方網(wǎng)站 - 開放、連接、共贏
下載并解壓
[root@lnmp ~]# wget https://gitee.com/Discuz/DiscuzX/attach_files/1621557/download
--2024-04-23 12:00:26-- https://gitee.com/Discuz/DiscuzX/attach_files/1621557/download
正在解析主機(jī) gitee.com (gitee.com)... 180.76.198.77
正在連接 gitee.com (gitee.com)|180.76.198.77|:443... 已連接。
已發(fā)出 HTTP 請求,正在等待回應(yīng)... 302 Found
位置:https://foruda.gitee.com/attach_file/1703208479609778362/discuz_x3.5_sc_utf8_20231221.zip?token=faa18eb48c16a19d7dfae3068a01b3f2&ts=1713844827&attname=Discuz_X3.5_SC_UTF8_20231221.zip [跟隨至新的 URL]
--2024-04-23 12:00:27-- https://foruda.gitee.com/attach_file/1703208479609778362/discuz_x3.5_sc_utf8_20231221.zip?token=faa18eb48c16a19d7dfae3068a01b3f2&ts=1713844827&attname=Discuz_X3.5_SC_UTF8_20231221.zip
正在解析主機(jī) foruda.gitee.com (foruda.gitee.com)... 180.76.198.77
正在連接 foruda.gitee.com (foruda.gitee.com)|180.76.198.77|:443... 已連接。
已發(fā)出 HTTP 請求,正在等待回應(yīng)... 200 OK
長度:11593050 (11M) [application/zip]
正在保存至: “download”
download 100%[==============================================================================================>] 11.06M 524KB/s 用時 22s
2024-04-23 12:00:49 (515 KB/s) - 已保存 “download” [11593050/11593050])
[root@lnmp ~]# unzip download //直接解壓即可
Archive: download
inflating: LICENSE
inflating: qqqun.png
creating: readme/
inflating: readme.html
省略 。。。。。。
把解壓后的upload下的文件都復(fù)制到nginx的html下
[root@lnmp ~]# rm -rf /usr/local/nginx/html/*
[root@lnmp ~]# \cp -r upload/* /usr/local/nginx/html/
修改nginx配置
[root@lnmp ~]# vim /usr/local/nginx/conf/nginx.conf
43 location / {
44 root /usr/local/nginx/html/; //修改路徑
45 index index.php index.html index.htm; //增加index.php文件
46 }
65 location ~ \.php$ {
66 root /usr/local/nginx/html/;
67 fastcgi_pass 127.0.0.1:9000;
68 fastcgi_index index.php;
69 fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; //腳本路徑
70 include fastcgi_params;
[root@lnmp ~]# /usr/local/nginx/sbin/nginx -s reload
[root@lnmp ~]# chown -R nginx:nginx /usr/local/nginx/html/
[root@lnmp ~]# chmod 777 -R /usr/local/nginx/html/
[root@lnmp ~]# setenforce 0
[root@lnmp ~]# systemctl restart firewalld.service
瀏覽器訪問
?回到linux,進(jìn)入MySQL創(chuàng)建一個登錄用戶,并授權(quán)
[root@lnmp ~]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.5.16-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)]>
MariaDB [(none)]> create user 'DZ'@'%' identified by '123456';
Query OK, 0 rows affected (0.005 sec)
MariaDB [(none)]> grant all privileges on *.* to 'DZ'@'%';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> flush privileges; //刷新權(quán)限表
Query OK, 0 rows affected (0.001 sec)
?回到瀏覽器刷新再次填寫
?下一步等待安裝完成
?進(jìn)入后界面如下
柚子快報激活碼778899分享:lnmp架構(gòu)
推薦閱讀
本文內(nèi)容根據(jù)網(wǎng)絡(luò)資料整理,出于傳遞更多信息之目的,不代表金鑰匙跨境贊同其觀點(diǎn)和立場。
轉(zhuǎn)載請注明,如有侵權(quán),聯(lián)系刪除。