LNMP环境部署
一.Nginx离线部署
- 所有依赖包都可以在pkgs.org中下载.
1. 安装相关依赖
离线安装相关依赖
1 | rpm -ivh https://mirrors.aliyun.com/rockylinux/8/BaseOS/x86_64/os/Packages/k/kernel-headers-4.18.0-553.el8_10.x86_64.rpm \ |
离线安装pcre、openssl、zlib依赖
1 | rpm -ivh https://mirrors.aliyun.com/rockylinux/8/BaseOS/x86_64/os/Packages/p/pcre-devel-8.42-6.el8.x86_64.rpm \ |
2.创建组和用户
1 | groupadd www && useradd www -s /sbin/nologin -g www |
3.源代码安装Nginx
1 | # 下载地址:https://nginx.org/en/download.html |
4.配置环境变量,启动nginx服务
1 | # vim /etc/profile,在最后一行添加如下: |
二.PHP离线部署
1.安装相关依赖
1 | dnf install -y gcc \ |
2.创建组和用户
1 | groupadd www && useradd www -s /sbin/nologin -g www |
3.三步安装
1 | wget https://www.php.net/distributions/php-8.2.20.tar.gz && tar -xvf php-8.2.20.tar.gz |
4.复制配置文件
1 | cp php.ini-development /usr/local/php/lib/php.ini |
5.创建php-fpm.service
1 | # cp /usr/local/src/php-8.2.20/sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm.service |
- nginx添加php-fpm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27# nginx conf配置php支持
server {
listen 80;
server_name 192.168.64.10;
root /home/www/html;
location / {
index index.php index.html index.htm;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
三.MySQL 8 RPM包部署
1.安装依赖
1 | dnf -y install compat-openssl10 ncurses-compat-libs openssl-devel perl-Getopt-Long perl-libs |
2.下载rpm安装包
1 | wget --no-check-certificate https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-x86_64/mysql-community-client-8.0.37-1.el7.x86_64.rpm \ |
3.安装
1 | [root@iZ0jlh32uzw0d35tst4rdaZ src]# rpm -ivh mysql-community-common-8.0.37-1.el7.x86_64.rpm \ |
4.修改my.cnf
配置文件中数据存储路径datadir
和日志存放路径log-error
1 | [mysqld] |
5.创建mysqld.log
文件,修改datadir
和log-error
路径的mysql权限
1 | mkdir -p /data/mysql/{data,log} |
6.启动mysqld服务
1 | [root@iZ0jlh32uzw0d35tst4rdaZ etc]# systemctl start mysqld |
7.查看初始化密码并登录
1 | [root@iZ0jlh32uzw0d35tst4rdaZ etc]# grep 'temporary password' /data/mysql/log/mysqld.log |
8.SQL语句
1 | # 初始化完成登录后需要修改root密码 |