//nginx 下载地址http://nginx.org/download/nginx-1.22.0.tar.gz [root@node8 ~]# cd /usr/src/[root@node8 src]# ls
debug kernels nginx-1.22.0.tar.gz
//创建nginx主和组,并创建日志存放目录[root@node8 src]# useradd -r -M -s /sbin/nologin nginx
[root@node8 src]# mkdir /var/log/nginx
[root@node8 src]# chown -R nginx.nginx /var/log/nginx/[root@node8 src]# ll -d /var/log/nginx/
drwxr-xr-x.2 nginx nginx 6 Sep 311:50/var/log/nginx///安装依赖包[root@node8 src]# yum -y install pcre-devel openssl openssl-devel gd-devel gcc gcc-c++ make
[root@node8 src]# tar xf nginx-1.22.0.tar.gz
[root@node8 src]# ls
debug kernels nginx-1.22.0 nginx-1.22.0.tar.gz
[root@node8 src]# cd nginx-1.22.0//进行编译安装[root@node8 nginx-1.22.0]# ./configure \
>--prefix=/usr/local/nginx \
>--user=nginx \
>--group=nginx \
>--with-debug \
>--with-http_ssl_module \
>--with-http_realip_module \
>--with-http_image_filter_module \
>--with-http_gunzip_module \
>--with-http_gzip_static_module \
>--with-http_stub_status_module \
>--http-log-path=/var/log/nginx/access.log \
>--error-log-path=/var/log/nginx/error.log
[root@node8 nginx-1.22.0]# make && make install
//配置nginx[root@node8 ~]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' >/etc/profile.d/nginx.sh
[root@node8 ~]# source /etc/profile.d/nginx.sh
[root@node8 ~]# nginx
[root@node8 ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 01280.0.0.0:800.0.0.0:*
LISTEN 01280.0.0.0:220.0.0.0:*
LISTEN 0128[::]:22[::]:*[root@node8 ~]# systemctl disable --now firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.[root@node8 ~]# setenforce 0//配置nginx服务文件[root@node8 ~]# cd /usr/lib/systemd/system
[root@node8 system]# cp sshd.service nginx.service
[root@node8 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@node8 system]# systemctl daemon-reload
[root@node8 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@node8 system]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 01280.0.0.0:800.0.0.0:*
LISTEN 01280.0.0.0:220.0.0.0:*
LISTEN 0128[::]:22[::]:*[root@node8 system]# nginx -s stop
//设置为开机自启[root@node8 system]# systemctl enable --now nginx
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /usr/lib/systemd/system/nginx.service.[root@node8 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-0313:02:19 CST;3s ago
Process:39274 ExecStart=/usr/local/nginx/sbin/nginx(code=exited, status=0/SUCCESS)
Main PID:39275(nginx)
mysql二进制安装与配置
[root@node8 ~]# yum -y install ncurses-compat-libs ncurses-devel openssl-devel openssl cmake mariadb-devel
[root@node8 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@node8 src]# tar xf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz -C /usr/local/[root@node8 src]# cd /usr/local/[root@node8 local]# ls
bin games lib libexec nginx share
etc include lib64 mysql-8.0.20-linux-glibc2.12-x86_64 sbin src
[root@node8 local]# mv mysql-8.0.20-linux-glibc2.12-x86_64 mysql
[root@node8 local]# chown -R mysql.mysql mysql //修改目录/usr/local/mysql的属主属组[root@node8 local]# ll -d mysql/
drwxr-xr-x.9 mysql mysql 129 Sep 312:45 mysql///添加环境变量 头文件 man文件[root@node8 local]# echo 'export PATH=/usr/local/mysql/bin:$PATH' >/etc/profile.d/mysql.sh
[root@node8 local]# source /etc/profile.d/mysql.sh
[root@node8 local]# which mysql
/usr/local/mysql/bin/mysql
[root@node8 local]# ln -s /usr/local/mysql/include /usr/include/mysql
[root@node8 local]# vi /etc/ld.so.conf.d/mysql.conf
/usr/local/mysql/lib
[root@node8 local]# ldconfig
[root@node8 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@node8 ~]# mkdir -p /opt/data
[root@node8 ~]# chown -R mysql.mysql /opt/data/[root@node8 ~]# ll /opt/
total 0
drwxr-xr-x.2 mysql mysql 6 Sep 312:55 data
//初始化数据库 添加-insecure 初始化是不生成密码可以免密登录[root@node8 ~]# 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@node8 ~]# 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@node8 ~]# cd /usr/local/mysql/[root@node8 mysql]# ls
bin docs include lib LICENSE man README share support-files
[root@node8 mysql]# cd support-files/[root@node8 support-files]# cp mysql.server mysqld
[root@node8 support-files]# chown -R mysql.mysql mysqld
[root@node8 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@node8 support-files]# vi mysqld
basedir=/usr/local/mysql
datadir=/opt/data
[root@node8 support-files]# /usr/local/mysql/support-files/mysqld start
Starting MySQL.Logging to '/opt/data/lnmp.err'.. SUCCESS![root@node8 support-files]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 01280.0.0.0:800.0.0.0:*
LISTEN 01280.0.0.0:220.0.0.0:*
LISTEN 0128*:3306*:*
LISTEN 0128[::]:22[::]:*
LISTEN 070*:33060*:*//修改密码[root@node8 ~]# 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@node8 ~]# 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@node8 ~]# cd /usr/lib/systemd/system
[root@node8 system]# cp sshd.service mysqld.service
[root@node8 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@node8 system]# systemctl daemon-reload
[root@node8 system]# pkill mysql
[root@node8 system]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 01280.0.0.0:800.0.0.0:*
LISTEN 01280.0.0.0:220.0.0.0:*
LISTEN 0128[::]:22[::]:*[root@node8 system]# systemctl enable --now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.[root@node8 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-0313:10:34 CST;10s ago
Process:39590 ExecStart=/usr/local/mysql/support-files/mysqld start(code=exited, sta>
Main PID:39603(mysqld_safe)
Tasks:40(limit:11201)
php安装与配置
//准备工作 安装php包和依赖包[root@node8 ~]# cd /usr/src/[root@node8 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@node8 src]# tar xf php-8.0.23.tar.gz
[root@node8 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@node8 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@node8 src]# cd php-8.0.23[root@node8 php-8.0.23]# ./configure --prefix=/usr/local/php8 \
>--with-config-file-path=/etc \
>--enable-fpm \
>--enable-inline-optimization \
>--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-json \
>--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@node8 php-8.0.23]# make && make install
//创建环境变量[root@node8 php-8.0.23]# echo 'export PATH=/usr/local/php8/bin:$PATH' >/etc/profile.d/php8.sh
[root@node8 php-8.0.23]# source /etc/profile.d/php8.sh
[root@node8 php-8.0.23]# which php
/usr/local/php8/bin/php
//配置php-fpm[root@node8 php-8.0.23]# \cp php.ini-production /etc/php.ini //将生产环境文件 复制到etc下[root@node8 php-8.0.23]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@node8 php-8.0.23]# chmod +x /etc/rc.d/init.d/php-fpm //此文件需要执行权限所以复制过去要看是否有执行(x)权限[root@node8 php-8.0.23]# cp /usr/local/php8/etc/php-fpm.conf.default/usr/local/php8/etc/php-fpm.conf //将php-fpm.conf.default 复制一份名为php-fpm.conf[root@node8 php-8.0.23]# cp /usr/local/php8/etc/php-fpm.d/www.conf.default/usr/local/php8/etc/php-fpm.d/www.conf //将www.conf.default 复制一份名为www.conf//开启服务检查端口[root@node8 php-8.0.23]# service php-fpm start
Starting php-fpm done
[root@node8 php-8.0.23]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 01280.0.0.0:800.0.0.0:*
LISTEN 01280.0.0.0:220.0.0.0:*
LISTEN 0128127.0.0.1:90000.0.0.0:*
LISTEN 0128*:3306*:*
LISTEN 0128[::]:22[::]:*
LISTEN 070*:33060*:*