欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

LNMP簡(jiǎn)介(最新推薦)

 更新時(shí)間:2023年08月18日 10:27:21   作者:事愿人為  
LNMP是指一組通常一起使用來(lái)運(yùn)行動(dòng)態(tài)網(wǎng)站或者服務(wù)器的自由軟件名稱首字母縮寫,L指Linux,N指Nginx,M一般指MySQL,也可以指MariaDB,P一般指PHP,也可以指Perl或Python

LNMP介紹

一、LNMP是什么

LNMP是指一組通常一起使用來(lái)運(yùn)行動(dòng)態(tài)網(wǎng)站或者服務(wù)器的自由軟件名稱首字母縮寫。L指Linux,N指Nginx,M一般指MySQL,也可以指MariaDB,P一般指PHP,也可以指Perl或Python。

二、LNMP介紹

LNMP代表的就是:Linux系統(tǒng)下Nginx+MySQL+PHP這種網(wǎng)站服務(wù)器架構(gòu)。

(1)Linux是一類Unix計(jì)算機(jī)操作系統(tǒng)的統(tǒng)稱,是目前最流行的免費(fèi)操作系統(tǒng)。代表版本有:debian、centos、ubuntu、fedora、gentoo等。

(2)Nginx (engine x) 是一個(gè)高性能的HTTP和反向代理web服務(wù)器,同時(shí)也提供了IMAP/POP3/SMTP服務(wù)。其特點(diǎn)是占有內(nèi)存少,并發(fā)能力強(qiáng),事實(shí)上nginx的并發(fā)能力在同類型的網(wǎng)頁(yè)服務(wù)器中表現(xiàn)較好

(3)MySQL是一種開(kāi)放源代碼的關(guān)系型數(shù)據(jù)庫(kù)管理系統(tǒng)(RDBMS),使用最常用的數(shù)據(jù)庫(kù)管理語(yǔ)言--結(jié)構(gòu)化查詢語(yǔ)言(SQL)進(jìn)行數(shù)據(jù)庫(kù)管理。MySQL不僅是開(kāi)放源代碼的,也因?yàn)槠渌俣?、可靠性和適應(yīng)性而備受關(guān)注。大多數(shù)人都認(rèn)為在不需要事務(wù)化處理的情況下,MySQL是管理內(nèi)容最好的選擇。

(4)PHP即“超文本預(yù)處理器”,是一種通用開(kāi)源腳本語(yǔ)言。PHP是在服務(wù)器端執(zhí)行的腳本語(yǔ)言,與C語(yǔ)言類似,是常用的網(wǎng)站編程語(yǔ)言。因?yàn)镻HP的開(kāi)源性、免費(fèi)性、快捷性等特點(diǎn)使其成為目前最流行的編程語(yǔ)言。

三、優(yōu)點(diǎn)

(1)四種軟件均為免費(fèi)開(kāi)源軟件,組合到一起,成為一個(gè)免費(fèi)、高效、擴(kuò)展性強(qiáng)的網(wǎng)站服務(wù)系統(tǒng)。

(2)Nginx使用更少的資源,支持更多的并發(fā)連接,體現(xiàn)更高的效率。

(3)Nginx 既可以在內(nèi)部直接支持Rails和PHP,也可以支持作為 HTTP代理服務(wù)器對(duì)外進(jìn)行服務(wù)。

(4)Nginx 安裝非常的簡(jiǎn)單,配置文件非常簡(jiǎn)潔(還能夠支持perl語(yǔ)法)。Nginx支持平滑加載新的配置,還能夠在不間斷服務(wù)的情況下進(jìn)行軟件版本的升級(jí)。

環(huán)境說(shuō)明:

系統(tǒng)主機(jī)名IP服務(wù)
centos8nginx192.168.111.141nginx
centos8mysql192.168.111.142mysql
centos8php192.168.111.143php

分離部署LNMP

部署nginx

//修改名字
[root@localhost ~]# hostnamectl set-hostname nginx
[root@localhost ~]# bash
[root@nginx ~]# 
//關(guān)閉防火墻和selinux
[root@nginx ~]# setenforce 0
[root@nginx ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
[root@nginx ~]# systemctl disable --now firewalld
[root@nginx ~]# reboot
//配置yum源
[root@nginx ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@nginx ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
//創(chuàng)建用戶
[root@nginx ~]# useradd -rMs /sbin/nologin nginx
//安裝依賴包
[root@nginx ~]# dnf -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++ make wget vim
//下載nginx包并解壓
[root@nginx ~]# wget http://nginx.org/download/nginx-1.20.2.tar.gz
[root@nginx ~]# tar xf nginx-1.20.2.tar.gz 
//進(jìn)行編譯安裝
[root@nginx ~]# cd nginx-1.20.2
[root@nginx nginx-1.20.2]# ./configure \
 --prefix=/usr/local/nginx \
 --user=nginx \
 --group=nginx \
 --with-debug \
 --with-http_ssl_module \
 --with-http_realip_module \
 --with-http_gunzip_module \
 --with-http_gzip_static_module \
 --with-http_stub_status_module
[root@nginx nginx-1.20.2]# make -j $(grep 'processor' /proc/cpuinfo | wc -l) && make install
//配置環(huán)境變量
[root@nginx ~]# echo "export PATH=$PATH:/usr/local/nginx/sbin" > /etc/profile.d/nginx.sh
[root@nginx ~]# source /etc/profile.d/nginx.sh
//配置system啟動(dòng)服務(wù)
[root@nginx ~]# vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=nginx server daemon
After=network.target 
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecStop=/usr/local/nginx/sbin/nginx -s stop
ExecReload=/bin/kill -HUP \$MAINPID
[Install]
WantedBy=multi-user.target
[root@nginx ~]# systemctl daemon-reload
//啟動(dòng)nginx
[root@nginx ~]# systemctl enable --now nginx
[root@nginx ~]# ss -anlt
State        Recv-Q       Send-Q               Local Address:Port               Peer Address:Port       Process       
LISTEN       0            128                        0.0.0.0:80                      0.0.0.0:*                        
LISTEN       0            128                        0.0.0.0:22                      0.0.0.0:*                        
LISTEN       0            128                           [::]:22                         [::]:*          

部署mysql

//修改名字
[root@localhost ~]# hostnamectl set-hostname mysql
[root@localhost ~]# bash
[root@mysql ~]# 
//關(guān)閉防火墻
[root@mysql ~]# setenforce 0
[root@mysql ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
[root@mysql ~]# systemctl disable --now firewalld
//配置yum源
[root@mysql ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@mysql ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
//創(chuàng)建用戶
[root@mysql ~]# useradd -rMs /sbin/nologin mysql
//下載依賴包
[root@mysql ~]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel ncurses-compat-libs
//下載mysql包并解壓
[root@mysql ~]# wget https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz
[root@mysql ~]# tar xf mysql-5.7.38-linux-glibc2.12-x86_64.tar.gz -C /usr/local/
//修改包名,更改屬主屬組
[root@mysql ~]# cd /usr/local/
[root@mysql local]# mv mysql-5.7.38-linux-glibc2.12-x86_64 mysql
[root@mysql local]# chown -R mysql.mysql mysql*
[root@mysql local]# ll -d mysql/
drwxr-xr-x. 9 mysql mysql 129 Oct 11 13:42 mysql/
//配置環(huán)境變量
[root@mysql local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@mysql local]# source /etc/profile.d/mysql.sh
//創(chuàng)建頭文件
[root@mysql local]# ln -s /usr/local/mysql/include /usr/include/mysql
//添加幫助文檔
[root@mysql local]# vim /etc/man_db.conf 
MANDATORY_MANPATH                       /usr/man
MANDATORY_MANPATH                       /usr/share/man
MANDATORY_MANPATH                       /usr/local/share/man
MANDATORY_MANPATH                       /usr/local/mysql/man
//創(chuàng)建庫(kù)文件
[root@mysql ~]# vim /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib/
[root@mysql ~]# ldconfig 
//創(chuàng)建數(shù)據(jù)存放路勁
[root@mysql ~]# mkdir -p /opt/data
[root@mysql ~]# chown -R mysql.mysql /opt/data/
[root@mysql ~]# ll -d /opt/data/
drwxr-xr-x. 2 mysql mysql 6 Oct 11 13:48 /opt/data/
//初始化數(shù)據(jù)庫(kù)
[root@mysql ~]# mysqld --initialize --user mysql --datadir /opt/data/
2022-10-11T05:49:31.198902Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2022-10-11T05:49:31.347232Z 0 [Warning] InnoDB: New log files created, LSN=45790
2022-10-11T05:49:31.366252Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2022-10-11T05:49:31.427201Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 7a1816e2-4928-11ed-a649-000c29074265.
2022-10-11T05:49:31.428093Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2022-10-11T05:49:31.649647Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2022-10-11T05:49:31.649663Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2022-10-11T05:49:31.649960Z 0 [Warning] CA certificate ca.pem is self signed.
2022-10-11T05:49:31.695538Z 1 [Note] A temporary password is generated for root@localhost: h.#agi;KB7%t		//臨時(shí)密碼
[root@mysql ~]# echo 'h.#agi;KB7%t' > pass
//編寫配置文件
[root@mysql ~]# dnf -y remove mariadb*
[root@mysql ~]# vim /etc/my.cnf
[mysqld]
basedir = /usr/local/mysql
datadir = /opt/data
socket = /tmp/mysql.sock
port = 3306
pid-file = /opt/data/mysql.pid
user = mysql
skip-name-resolve
//編寫system控制腳本
[root@mysql ~]# vim /usr/lib/systemd/system/mysqld.service
[Unit]
Description=mysql server daemon
After=network.target 
[Service]
Type=forking
ExecStart=/usr/local/mysql/support-files/mysql.server start
ExecStop=/usr/local/mysql/support-files/mysql.server stop
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
[root@mysql ~]# systemctl daemon-reload
//設(shè)置開(kāi)機(jī)自啟
[root@mysql ~]# systemctl enable --now mysqld
[root@mysql ~]# ss -anlt
State        Recv-Q       Send-Q               Local Address:Port               Peer Address:Port       Process       
LISTEN       0            128                        0.0.0.0:22                      0.0.0.0:*                        
LISTEN       0            80                               *:3306                          *:*                        
LISTEN       0            128                           [::]:22                         [::]:*                       
//設(shè)置mysql密碼
[root@mysql ~]# cat pass 
h.#agi;KB7%t
[root@mysql ~]# mysql -uroot -p'h.#agi;KB7%t'
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.7.38
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> set password = password('123456');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> exit
Bye
//修改后驗(yàn)證
[root@mysql ~]# mysql -uroot -p123456
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.38 MySQL Community Server (GPL)
Copyright (c) 2000, 2022, Oracle and/or its affiliates.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> 

部署php

//修改名字
[root@localhost ~]# hostnamectl set-hostname php
[root@localhost ~]# bash
[root@php ~]# 
//關(guān)閉防火墻和selinux
[root@php ~]# setenforce 0
[root@php ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/selinux/config
[root@php ~]# systemctl disable --now firewalld
//配置yum源
[root@php ~]# curl -o /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-8.5.2111.repo
[root@php ~]# sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
//安裝依賴包
[root@php ~]# yum -y install gcc gcc-c++ glibc automake autoconf libtool make libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5-devel  openssl openssl-devel sqlite-devel libcurl-devel libpng-devel libjpeg-devel freetype-devel libicu-devel libxslt-devel systemd-devel  gmp-devel net-snmp net-snmp-devel libsqlite3x-devel libzip-devel --allowerasing --skip-broken --nobest
[root@php ~]# yum -y install http://mirror.centos.org/centos/8-stream/PowerTools/x86_64/os/Packages/oniguruma-devel-6.8.2-2.el8.x86_64.rpm
//下載PHP包并解壓
[root@php ~]# wget https://www.php.net/distributions/php-8.1.11.tar.gz
[root@php ~]# tar xf php-8.1.11.tar.gz
//編譯安裝
[root@php ~]# cd php-8.1.11
[root@php php-8.1.11]# ./configure --prefix=/usr/local/php8 \
--with-config-file-path=/usr/local/php8/etc \
--enable-fpm \
--enable-mysqlnd \
--with-mysqli \
--with-pdo-mysql \
--enable-opcache \
--with-pcre-jit \
--enable-gd \
--with-jpeg \
--with-freetype \
--with-gettext \
--with-curl \
--with-openssl \
--enable-sockets \
--enable-mbstring \
--enable-xml \
--with-zip \
--with-zlib \
--with-snmp \
--with-mhash \
--enable-ftp \
--enable-bcmath \
--enable-soap \
--enable-shmop \
--enable-sysvsem \
--enable-pcntl \
--with-gmp
//顯示這個(gè)表示沒(méi)問(wèn)題了
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE. By continuing this installation  |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+
Thank you for using PHP.
[root@php php-8.1.11]# make && make install
//配置環(huán)境變量
[root@php ~]# echo 'export PATH=/usr/local/php8/bin:$PATH' > /etc/profile.d/php8.sh
[root@php ~]# source /etc/profile.d/php8.sh
//配置php-fpm
[root@php ~]# cd php-8.1.11
[root@php php-8.1.11]# cp php.ini-production /etc/php.ini
cp: overwrite '/etc/php.ini'? y
[root@php php-8.1.11]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@php php-8.1.11]# chmod +x /etc/rc.d/init.d/php-fpm
[root@php php-8.1.11]# cp /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf
[root@php php-8.1.11]# cp /usr/local/php8/etc/php-fpm.d/www.conf.default /usr/local/php8/etc/php-fpm.d/www.conf
//啟動(dòng)php-fpm
[root@php ~]# service php-fpm start
Starting php-fpm  done
[root@php ~]# ss -anlt
State        Recv-Q       Send-Q               Local Address:Port               Peer Address:Port       Process       
LISTEN       0            128                        0.0.0.0:22                      0.0.0.0:*                        
LISTEN       0            128                      127.0.0.1:9000                    0.0.0.0:*                        
LISTEN       0            128                           [::]:22                         [::]:*                

安裝后配置

php端配置

//修改配置文件
[root@php ~]# vim /usr/local/php8/etc/php-fpm.d/www.conf
listen = 192.168.111.143:9000		//修改為php本機(jī)IP
listen.allowed_clients = 192.168.111.141	//允許指定ip訪問(wèn)
//在php端上配置網(wǎng)站
[root@php ~]# mkdir -p /var/www/html
[root@php ~]# vim /var/www/html/index.php
<?php
    phpinfo();
?>
//重啟php-fpm服務(wù)
[root@php ~]# service php-fpm restart
Gracefully shutting down php-fpm . done
Starting php-fpm  done
[root@php ~]# ss -anlt
State        Recv-Q       Send-Q               Local Address:Port               Peer Address:Port       Process       
LISTEN       0            128                        0.0.0.0:22                      0.0.0.0:*                        
LISTEN       0            128                192.168.111.143:9000                    0.0.0.0:*                        
LISTEN       0            128                           [::]:22                         [::]:*   

nginx服務(wù)器端

//創(chuàng)建一個(gè).php結(jié)尾的文件,用于匹配
[root@nginx ~]# touch /usr/local/nginx/html/index.php
//修改配置文件
[root@nginx ~]# vim /usr/local/nginx/conf/nginx.conf
#查找index
        location / {
            root   html;
            index  index.php index.html index.htm;		//添加index.php
        }
#大概65-71行,取消注釋
 location ~ \.php$ {
            root           /var/www/html;			//指向php端index.php文件位置
            fastcgi_pass   192.168.111.143:9000;	//ip地址為php服務(wù)器地址
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;		//將/scripts更改為$document_root
            include        fastcgi_params;
        }
//重啟服務(wù)
[root@nginx ~]# systemctl restart nginx

瀏覽器訪問(wèn)

到此這篇關(guān)于LNMP簡(jiǎn)介(最新推薦)的文章就介紹到這了,更多相關(guān)LNMP簡(jiǎn)介內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評(píng)論