[root@lnmp ~]# cd /usr/lib/systemd/system[root@lnmp system]# cp sshd.service nginx.service[root@lnmp system]# vi nginx.service Documentation=man:sshd(8) man:sshd_config(5)Wants=sshd-keygen.tar`get
EnvironmentFile=-/etc/crypto-policies/back-ends/opensshserver.config
EnvironmentFile=-/etc/sysconfig/sshd
ExecStart=/usr/local/nginx/sbin/nginx
Restart=on-failure
RestartSec=42s
KillMode=process
[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=/usr/local/nginx/sbin/nginx -s reload
[Install]WantedBy=multi-user.target
[root@lnmp system]# systemctl daemon-reload[root@lnmp system]# systemctl status nginx
● nginx.service - nginx server daemon
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: inactive (dead)[root@lnmp system]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 01280.0.0.0:80 0.0.0.0:*
LISTEN 01280.0.0.0:22 0.0.0.0:*
LISTEN 0128[::]:22 [::]:*
[root@lnmp system]# nginx -s stop[root@lnmp system]# systemctl enable --now nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.
[root@lnmp system]# systemctl status nginx
● nginx.service - nginx server daemon
Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2022-09-03 13:02:19 CST; 3s ago
Process: 39274ExecStart=/usr/local/nginx/sbin/nginx (code=exited, status=0/SUCCESS)
Main PID: 39275(nginx)
mysql二进制安装
//mysql 下载地址https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
[root@lnmp ~]# useradd -r -M -s /sbin/nologin mysql //创建用户[root@lnmp ~]# yum -y install ncurses-compat-libs ncurses-devel openssl-devel openssl cmake mariadb-devel[root@lnmp src]# ls
debug mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz nginx-1.22.0.tar.gz
kernels nginx-1.22.0 php-8.0.23.tar.gz
[root@lnmp src]# tar xf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz -C /usr/local/[root@lnmp src]# cd /usr/local/[root@lnmp local]# ls
bin games lib libexec nginx share
etc include lib64 mysql-8.0.20-linux-glibc2.12-x86_64 sbin src
[root@lnmp local]# mv mysql-8.0.20-linux-glibc2.12-x86_64 mysql[root@lnmp local]# chown -R mysql.mysql mysql //修改目录/usr/local/mysql的属主属组[root@lnmp local]# ll -d mysql/
drwxr-xr-x. 9 mysql mysql 129 Sep 312:45 mysql/
//添加环境变量 头文件 man文件
[root@lnmp local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh [root@lnmp local]# source /etc/profile.d/mysql.sh [root@lnmp local]# which mysql
/usr/local/mysql/bin/mysql
[root@lnmp local]# ln -s /usr/local/mysql/include /usr/include/mysql[root@lnmp local]# vi /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
[root@lnmp local]# ldconfig [root@lnmp local]# vi /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
//建立数据存放目录
[root@lnmp ~]# mkdir -p /opt/data[root@lnmp ~]# chown -R mysql.mysql /opt/data/[root@lnmp ~]# ll /opt/
total 0
drwxr-xr-x. 2 mysql mysql 6 Sep 312:55 data
//初始化数据库 添加-insecure 初始化是不生成密码可以免密登录
[root@lnmp ~]# mysqld --initialize-insecure --user mysql --datadir /opt/data 2022-09-03T04:57:52.794989Z 0[System][MY-013169][Server] /usr/local/mysql/bin/mysqld (mysqld 8.0.20) initializing of server in progress as process 391502022-09-03T04:57:52.812873Z 1[System][MY-013576][InnoDB] InnoDB initialization has started.
2022-09-03T04:57:54.088964Z 1[System][MY-013577][InnoDB] InnoDB initialization has ended.
2022-09-03T04:57:55.572208Z 6[Warning][MY-010453][Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
//生成配置文件
[root@lnmp ~]# cat /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
//配置服务启动脚本
[root@lnmp ~]# cd /usr/local/mysql/[root@lnmp mysql]# ls
bin docs include lib LICENSE man README share support-files
[root@lnmp mysql]# cd support-files/[root@lnmp support-files]# cp mysql.server mysqld[root@lnmp support-files]# chown -R mysql.mysql mysqld[root@lnmp support-files]# ll
total 32
-rwxr-xr-x. 1 mysql mysql 10576 Sep 313:05 mysqld
-rwxr-xr-x. 1 mysql mysql 1061 Mar 262020 mysqld_multi.server
-rw-r--r--. 1 mysql mysql 2048 Mar 272020 mysql-log-rotate
-rwxr-xr-x. 1 mysql mysql 10576 Mar 272020 mysql.server
[root@lnmp support-files]# vi mysqldbasedir=/usr/local/mysql
datadir=/opt/data
[root@lnmp support-files]# /usr/local/mysql/support-files/mysqld start
Starting MySQL.Logging to '/opt/data/lnmp.err'.. SUCCESS![root@lnmp support-files]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 01280.0.0.0:80 0.0.0.0:*
LISTEN 01280.0.0.0:22 0.0.0.0:*
LISTEN 0128 *:3306 *:*
LISTEN 0128[::]:22 [::]:*
LISTEN 070 *:33060 *:* //修改密码
[root@lnmp ~]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.20 MySQL Community Server - GPL
Copyright (c)2000, 2020, Oracle and/or its affiliates. All rights reserved.
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> alter user 'root'@'localhost' identified by 'test111';
Query OK, 0 rows affected (0.00 sec)
mysql>exit
Bye
//使用修改之后的密码登录
[root@lnmp ~]# mysql -uroot -ptest111
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 9
Server version: 8.0.20 MySQL Community Server - GPL
Copyright (c)2000, 2020, Oracle and/or its affiliates. All rights reserved.
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>
//设置开机自启
[root@lnmp ~]# cd /usr/lib/systemd/system[root@lnmp system]# cp sshd.service mysqld.service[root@lnmp system]# vi mysqld.service [Unit]Description=mysql server daemon
Wants=sshd-keygen.target
[Service]Type=forking
ExecStart=/usr/local/mysql/support-files/mysqld start
ExecStop=/usr/local/mysql/support-files/mysqld stop
ExecReload=/bin/kill -HUP $MAINPID[Install]WantedBy=multi-user.target
[root@lnmp system]# systemctl daemon-reload[root@lnmp system]# pkill mysql[root@lnmp system]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 01280.0.0.0:80 0.0.0.0:*
LISTEN 01280.0.0.0:22 0.0.0.0:*
LISTEN 0128[::]:22 [::]:*
[root@lnmp system]# systemctl enable --now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
[root@lnmp system]# systemctl status mysqld
● mysqld.service - mysql server daemon
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disab>
Active: active (running) since Sat 2022-09-03 13:10:34 CST; 10s ago
Process: 39590ExecStart=/usr/local/mysql/support-files/mysqld start (code=exited, sta>
Main PID: 39603(mysqld_safe)
Tasks: 40(limit: 11201)
php编译安装
//下载地址 https://www.php.net/distributions/php-8.0.23.tar.gz
//准备工作 安装php包和依赖包
[root@lnmp ~]# cd /usr/src/[root@lnmp src]# ls
debug mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz nginx-1.22.0.tar.gz
kernels nginx-1.22.0 php-8.0.23.tar.gz
[root@lnmp src]# tar xf php-8.0.23.tar.gz [root@lnmp src]# ls
debug nginx-1.22.0 php-8.0.23.tar.gz
kernels nginx-1.22.0.tar.gz
mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz php-8.0.23
[root@lnmp src]# dnf -y install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libicu-devel libjpeg libjpeg-devel libpng libpng-devel openldap-devel pcre-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel mhash mhash-devel php-mysqlnd sqlite-devel http://mirror.centos.org/centos/8-stream/PowerTools/x86_64/os/Packages/oniguruma-devel-6.8.2-2.el8.x86_64.rpm libzip-devel[root@lnmp src]# cd php-8.0.23[root@lnmp php-8.0.23]# ./configure --prefix=/usr/local/php8 \> --with-config-file-path=/etc \> --enable-fpm \> --disable-debug \> --disable-rpath \> --enable-shared \> --enable-soap \> --with-openssl \> --enable-bcmath \> --with-iconv \> --with-bz2 \> --enable-calendar \> --with-curl \> --enable-exif \> --enable-ftp \> --enable-gd \> --with-jpeg \> --with-zlib-dir \> --with-freetype \> --with-gettext \> --enable-mbstring \> --enable-pdo \> --with-mysqli=mysqlnd \> --with-pdo-mysql=mysqlnd \> --with-readline \> --enable-shmop \> --enable-simplexml \> --enable-sockets \> --with-zip \> --enable-mysqlnd-compression-support \> --with-pear \> --enable-pcntl \> --enable-posix
+--------------------------------------------------------------------+
| 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@lnmp php-8.0.23]# make && make install