[root@localhost ~]# yum -y install vim wget
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
111 2.7 MB/s | 2.8 kB 00:00
222 3.1 MB/s | 3.2 kB 00:00
依赖关系解决。
=========================================================================================================
软件包 架构 版本 仓库 大小
=========================================================================================================
安装:
//安装开发工具包
[root@localhost ~]# yum groups mark install 'Development Tools' -y
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元数据过期检查:0:02:10 前,执行于 2021年09月23日 星期四 03时24分12秒。
依赖关系解决。
=========================================================================================================
软件包 架构 版本 仓库 大小
=========================================================================================================
安装组:
Development Tools
事务概要
=========================================================================================================
完毕!
//创建apache服务的用户和组
[root@localhost ~]# useradd -r -M -s /sbin/nologin apache
[root@localhost ~]#
//安装依赖包
[root@localhost ~]# yum -y install openssl-devel pcre-devel expat-devel libtool gcc gcc-c++ make
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
上次元数据过期检查:0:04:17 前,执行于 2021年09月23日 星期四 03时24分12秒。
依赖关系解决。
//下载和安装apr以及apr-util
[root@master src]# wget https://dlcdn.apache.org/httpd/httpd-2.4.49.tar.gz
--2021-09-23 03:50:18-- https://dlcdn.apache.org/httpd/httpd-2.4.49.tar.gz
正在解析主机 dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
正在连接 dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:9421895 (9.0M) [application/x-gzip]
正在保存至: “httpd-2.4.49.tar.gz”
httpd-2.4.49.tar.gz 100%[=====================================>] 8.99M 675KB/s 用时 11s
2021-09-23 03:50:29 (873 KB/s) - 已保存 “httpd-2.4.49.tar.gz” [9421895/9421895])
[root@master src]# wget https://dlcdn.apache.org/apr/apr-1.7.0.tar.gz
--2021-09-23 03:51:11-- https://dlcdn.apache.org/apr/apr-1.7.0.tar.gz
正在解析主机 dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
正在连接 dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1093896 (1.0M) [application/x-gzip]
正在保存至: “apr-1.7.0.tar.gz”
apr-1.7.0.tar.gz 100%[=====================================>] 1.04M 744KB/s 用时 1.4s
2021-09-23 03:51:14 (744 KB/s) - 已保存 “apr-1.7.0.tar.gz” [1093896/1093896])
[root@master src]# wget https://dlcdn.apache.org/apr/apr-util-1.6.1.tar.gz
--2021-09-23 03:51:25-- https://dlcdn.apache.org/apr/apr-util-1.6.1.tar.gz
正在解析主机 dlcdn.apache.org (dlcdn.apache.org)... 151.101.2.132, 2a04:4e42::644
正在连接 dlcdn.apache.org (dlcdn.apache.org)|151.101.2.132|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:554301 (541K) [application/x-gzip]
正在保存至: “apr-util-1.6.1.tar.gz”
apr-util-1.6.1.tar.gz 100%[=====================================>] 541.31K 486KB/s 用时 1.1s
2021-09-23 03:51:27 (486 KB/s) - 已保存 “apr-util-1.6.1.tar.gz” [554301/554301])
[root@master src]# ls
apr-1.7.0.tar.gz debug kernels
apr-util-1.6.1.tar.gz httpd-2.4.49.tar.gz mysql57-community-release-el7-10.noarch.rpm
[root@master src]# tar xf apr-1.7.0.tar.gz
[root@master src]# tar xf apr-util-1.6.1.tar.gz
[root@master src]# tar xf httpd-2.4.49.tar.gz
[root@master src]# ls
apr-1.7.0 apr-util-1.6.1.tar.gz httpd-2.4.49.tar.gz
apr-1.7.0.tar.gz debug kernels
apr-util-1.6.1 httpd-2.4.49 mysql57-community-release-el7-10.noarch.rpm
[root@master src]# cd apr-1.7.0
[root@master apr-1.7.0]# vim configure
cfgfile=${ofile}T
trap "$RM \"$cfgfile\"; exit 1" 1 2 15
# $RM "$cfgfile" //将此行加上注释,或者删除此行
[root@master apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@master apr-1.7.0]# make && make install
[root@master src]# cd apr-util-1.6.1
[root@master apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@master apr-util-1.6.1]# make && make install
//编译安装httpd
[root@master httpd-2.4.49]# ./configure --prefix=/usr/local/apache \
> --enable-so \
> --enable-ssl \
> --enable-cgi \
> --enable-rewrite \
> --with-zlib \
> --with-pcre \
> --with-apr=/usr/local/apr \
> --with-apr-util=/usr/local/apr-util/ \
> --enable-modules=most \
> --enable-mpms-shared=all \
> --with-mpm=prefork
[root@master httpd-2.4.49]# make && make install
//安装后配置
[root@master ~]# echo 'export PATH=/usr/local/apache/bin:$PATH' > /etc/profile.d/httpd.sh
[root@master ~]# source /etc/profile.d/httpd.sh
[root@master ~]# ln -s /usr/local/apache/include/ /usr/include/httpd
[root@master ~]# echo 'MANPATH /usr/local/apache/man' >> /etc/man.config
[root@master ~]# vim /usr/local/apache/conf/httpd.conf
ServerName www.example.com:80 //取消ServerName前面的注释
//启动apache
[root@master ~]# systemctl disable --now firewalld
[root@master ~]# setenforce 0
setenforce: SELinux is disabled
[root@master ~]# apachectl start
[root@master ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
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 [::]:*
[root@master ~]#
//设置开机自启
[root@master ~]# vim /usr/lib/systemd/system/httpd.service
[root@master ~]# cat /usr/lib/systemd/system/httpd.service
[Unit]
Description=Httpd server daemon
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/apache/bin/apachectl start
ExecStop=/usr/local/apache/bin/apachectl stop
ExecReload=/bin/kill -HUP $MAINPID
[Install]
WantedBy=multi-user.target
[root@master ~]#
[root@master ~]# apachectl stop
[root@master ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
[root@master ~]# systemctl enable --now httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@master ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
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 [::]:*
[root@master ~]#
[root@master ~]# systemctl status httpd
● httpd.service - Httpd server daemon
Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2021-09-23 04:23:12 EDT; 42s ago
Process: 184524 ExecStart=/usr/local/apache/bin/apachectl start (code=exited, status=0/SUCCESS)
Main PID: 184527 (httpd)
Tasks: 6 (limit: 23789)
Memory: 5.5M
CGroup: /system.slice/httpd.service
├─184527 /usr/local/apache/bin/httpd -k start
├─184528 /usr/local/apache/bin/httpd -k start
├─184529 /usr/local/apache/bin/httpd -k start
├─184530 /usr/local/apache/bin/httpd -k start
├─184531 /usr/local/apache/bin/httpd -k start
安装mysql
//安装依赖包
[root@master ~]# yum -y install ncurses-devel openssl-devel openssl cmake mariadb-devel
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
警告:加载 '/etc/yum.repos.d/CentOS8-Base-163.repo' 失败,跳过。
//创建用户和组
[root@master ~]# useradd -r -M -s /sbin/nologin mysql
//下载二进制格式的mysql软件包
[root@master ~]# cd /usr/local/
[root@master local]# ls
apache apr apr-util bin etc games include lib lib64 libexec sbin share src
[root@master local]# ls
apache apr-util etc include lib64 mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz share
apr bin games lib libexec sbin src
//解压软件至/usr/local/
[root@master local]# tar xf mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
[root@master local]# ls
apache apr-util etc include lib64 mysql-5.7.35-linux-glibc2.12-x86_64 sbin src
apr bin games lib libexec mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz share
[root@master local]# mv mysql-5.7.35-linux-glibc2.12-x86_64 mysql
[root@master local]# ls
apache apr-util etc include lib64 mysql sbin src
apr bin games lib libexec mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz share
//修改目录/usr/local/mysql的属主属组
[root@master local]# chown -R mysql.mysql mysql
[root@master local]# ll
总用量 650712
drwxr-xr-x 14 root root 164 9月 23 04:05 apache
drwxr-xr-x 6 root root 58 9月 23 03:57 apr
drwxr-xr-x 5 root root 43 9月 23 04:00 apr-util
drwxr-xr-x. 2 root root 6 8月 12 2018 bin
drwxr-xr-x. 2 root root 6 8月 12 2018 etc
drwxr-xr-x. 2 root root 6 8月 12 2018 games
drwxr-xr-x. 2 root root 6 8月 12 2018 include
drwxr-xr-x. 2 root root 6 8月 12 2018 lib
drwxr-xr-x. 2 root root 6 8月 12 2018 lib64
drwxr-xr-x. 2 root root 6 8月 12 2018 libexec
drwxr-xr-x 9 mysql mysql 129 9月 23 04:30 mysql
-rw-r--r-- 1 root root 666328842 9月 23 04:29 mysql-5.7.35-linux-glibc2.12-x86_64.tar.gz
drwxr-xr-x. 2 root root 6 8月 12 2018 sbin
drwxr-xr-x. 5 root root 49 7月 11 22:37 share
drwxr-xr-x. 2 root root 6 8月 12 2018 src
[root@master local]#
//添加环境变量
[root@master local]# cd
[root@master ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh
[root@master ~]# source /etc/profile.d/mysql.sh
[root@master ~]# ls /usr/local/mysql/
bin include LICENSE README support-files
docs lib man share
[root@master ~]# ln -s /usr/local/mysql/include /usr/include/mysql
[root@master ~]#
[root@master ~]# vim /etc/man_db.conf
[root@master ~]# cat /etc/man_db.conf
MANDATORY_MANPATH /usr/man
MANDATORY_MANPATH /usr/share/man
MANDATORY_MANPATH /usr/local/share/man
MANDATORY_MANPATH /usr/local/apache/man
MANDATORY_MANPATH /usr/local/mysql/man //添加这一行内容
[root@master ~]# vim /etc/ld.so.conf.d/mysql.conf
[root@master ~]# cat /etc/ld.so.conf.d/mysql.conf
/usr/local/msyql/lib
[root@master ~]# ldconfig
[root@master ~]#
//建立数据存放目录
[root@master ~]# mkdir /opt/data
[root@master ~]# chown -R mysql.mysql /opt/data
[root@master ~]# bash
//初始化数据库
[root@master ~]# mysqld --initialize-insecure --user mysql --datadir /opt/data
2021-09-23T08:40:55.702402Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-09-23T08:40:55.866438Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-09-23T08:40:55.890405Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-09-23T08:40:55.945819Z 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: f7eed72a-1c49-11ec-a94b-000c29773b76.
2021-09-23T08:40:55.946724Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-09-23T08:40:56.534234Z 0 [Warning] A deprecated TLS version TLSv1 is enabled. Please use TLSv1.2 or higher.
2021-09-23T08:40:56.534260Z 0 [Warning] A deprecated TLS version TLSv1.1 is enabled. Please use TLSv1.2 or higher.
2021-09-23T08:40:56.534638Z 0 [Warning] CA certificate ca.pem is self signed.
2021-09-23T08:40:56.585420Z 1 [Warning] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.
//生成配置文件
[root@master ~]# cat > /etc/my.cnf <<EOF
> [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
> EOF
[root@master ~]# 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@master ~]#
[root@master ~]# cp /usr/lib/systemd/system/httpd.service /usr/lib/systemd/system/mysqld.service
[root@master ~]# vim /usr/lib/systemd/system/mysqld.service
[root@master ~]# cat /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@master ~]#
[root@master ~]# vim /usr/local/mysql/support-files/mysql.server
basedir=/usr/local/mysql
datadir=/opt/data //修改这两行内容
//开机自启
[root@master ~]# systemctl daemon-reload
[root@master ~]# systemctl enable --now mysqld
Created symlink /etc/systemd/system/multi-user.target.wants/mysqld.service → /usr/lib/systemd/system/mysqld.service.
[root@master ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
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 80 *:3306 *:*
LISTEN 0 128 [::]:22 [::]:*
//修改密码
[root@master ~]# yum -y install ncurses-compat-libs
[root@master ~]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.35 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, 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('xiongke');
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> quit
Bye
[root@master ~]# mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.7.35 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, 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(8.0.10)
下载php
[root@master ~]# wget https://www.php.net/distributions/php-8.0.10.tar.xz
--2021-09-23 04:57:30-- https://www.php.net/distributions/php-8.0.10.tar.xz
正在解析主机 www.php.net (www.php.net)... 185.85.0.29, 2a02:cb40:200::1ad
正在连接 www.php.net (www.php.net)|185.85.0.29|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:10703088 (10M) [application/octet-stream]
正在保存至: “php-8.0.10.tar.xz”
php-8 0% 0 --.-KB/s php-8. 0% 39.74K 44.6KB/s php-8.0 1% 135.74K 105KB/s php-8.0. 2% 295.74K 194KB/s php-8.0.1 3% 343.74K 195KB/s php-8.0.10 3% 391.74K 194KB/s php-8.0.10. 4% 439.74K 195KB/s hp-8.0.10.t 4% 487.74K 194KB/s p-8.0.10.ta 5% 535.74K 194KB/s php-8.0.10 87% 8.98M 164KB/s 剩余 8s
//安装依赖包
[root@master ~]# yum -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
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
警告:加载 '/etc/yum.repos.d/CentOS8-Base-163.repo' 失败,跳过。
Repository base is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository AppStream is listed more than once in the configuration
[root@master ~]# yum -y install php-mysqlnd
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
//编译安装php
[root@master ~]# tar xf php-8.0.10.tar.xz -C /usr/src/
[root@master php-8.0.10]# yum -y install libsqlite3x-devel.x86_64
[root@master php-8.0.10]# 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
[root@master php-8.0.10]# ./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
[root@master php-8.0.10]# make
-------------
clicommand.inc
directorygraphiterator.inc
directorytreeiterator.inc
invertedregexiterator.inc
pharcommand.inc
phar.inc
Build complete.
Don't forget to run 'make test'.
[root@master php-8.0.10]# make install
Installing shared extensions: /usr/local/php8/lib/php/extensions/no-debug-non-zts-20200930/
Installing PHP CLI binary: /usr/local/php8/bin/
Installing PHP CLI man page: /usr/local/php8/php/man/man1/
Installing PHP FPM binary: /usr/local/php8/sbin/
Installing PHP FPM defconfig: /usr/local/php8/etc/
Installing PHP FPM man page: /usr/local/
-----------------
You may want to add: /usr/local/php8/lib/php to your php.ini include_path
/usr/src/php-8.0.10/build/shtool install -c ext/phar/phar.phar /usr/local/php8/bin/phar.phar
ln -s -f phar.phar /usr/local/php8/bin/phar
Installing PDO headers: /usr/local/php8/include/php/ext/pdo/
[root@master php-8.0.10]#
//安装后配置
[root@master php-8.0.10]# echo 'export PATH=/usr/local/php8/bin:$PATH' > /etc/profile.d/php.sh
[root@master php-8.0.10]# source /etc/profile.d/php.sh
[root@master php-8.0.10]# php -v
PHP 8.0.10 (cli) (built: Sep 23 2021 06:46:50) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.10, Copyright (c) Zend Technologies
[root@master php-8.0.10]# cp /usr/local/php8/etc/php-fpm.conf.default /usr/local/php8/etc/php-fpm.conf
[root@master php-8.0.10]# cd /usr/local/php8/etc/
[root@master etc]# ls
pear.conf php-fpm.conf.default
php-fpm.conf php-fpm.d
[root@master etc]# cd php-fpm.d/
[root@master php-fpm.d]# ls
www.conf.default
[root@master php-fpm.d]# cp www.conf.default www.conf
[root@master php-fpm.d]#
//配置php-fpm
[root@master php-8.0.10]# cp php.ini-production /etc/php.ini
cp:是否覆盖'/etc/php.ini'? y