源代码包的安装与磁盘分区
文章目录
-
- 源代码包的安装与磁盘分区
-
- 1. ` nginx ` 编译安装
-
- 1.1 [` ngink ` 网络地址](http://nginx.org/en/download.html)
- 1.2 下载并解压` ngink `
- 1.3 进入解压目录,检查安装环境
- 1.4 预编译和解决问题
- 1.5 解决问题并产生makefile文件
- 1.6 查看并指定CPU编译安装核心数
- 1.7 退出,查看
- 1.8 启动nginx,访问地址
- 1.9 修改环境变量,读取
- 注意事项
- 2. ` httpd ` 编译安装
-
- 2.1.1 [apr下载地址](https://downloads.apache.org/apr/)
- 2.1.2 [apr-util下载地址](https://downloads.apache.org/apr/)
- 2.1.3 [httpd下载地址](https://downloads.apache.org/httpd/)
- 2.2 下载并解压
- 2.3 进入` apr-1.6.5 ` 解压目录和解决问题的预编译
- 2.4 进入 ` apr-util ` 预编译和解决问题
- 2.5 进入 ` httpd ` 预编译和解决问题
- 2.6. 启动httpd并访问
- 2.7 修改环境变量,读取和访问
- 8.磁盘管理
-
- 8.1 磁盘分类
- 8.2 磁盘命名
- 8.3 MBR与GPT
-
- 8.3.1 MBR与GPT可以相互转换,转换会导致数据丢失
- 8.4 磁盘容量检查
-
- 8.4.1 使用df命令检查磁盘容量
- 8.4.2 使用lsblk检查分区情况:
- 8.4.3 使用du命令查看目录或文件的容量,以k为单位,无参数:
- 8.5 添加磁盘
- 8.6 磁盘分区
-
- 8.6.1 fdisk分区--- MBR 小于2T 命令敲错了用Ctrl u,
- 8.6.2 gdisk分区 --- GPT 大于2T,fdisk -l 查看类型为gpt格式为GPT
- 8.7 分区完成后,磁盘格式化 --- mkfs
-
- 8.7.1 使用`mkfs`命令格式化磁盘,创建文件系统
- 8.8 挂载磁盘
-
- 8.8.1 永久挂载
- 8.8.2 临时挂载
- 8.9 卸载磁盘
1. nginx
编译安装
1.1 ngink
的网络地址
1.2 下载并解压ngink
[root@SYL3 ~]# wget http://nginx.org/download/nginx-1.20.2.tar.gz --2022-04-08 13:46:49-- http://nginx.org/download/nginx-1.20.2.tar.gz Resolving nginx.org (nginx.org)... 3.125.197.172, 52.58.199.22, 2a05:d014:edb:5702::6, ... Connecting to nginx.org (nginx.org)|3.125.197.172|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1062124 (1.0M) [application/octet-stream]
Saving to: 'nginx-1.20.2.tar.gz'
nginx-1.20.2.ta 100%[====>] 1.01M 97.6KB/s in 10s
2022-04-08 13:47:00 (100 KB/s) - 'nginx-1.20.2.tar.gz' saved [1062124/1062124]
[root@SYL3 ~]# tar xf nginx-1.20.2.tar.gz
[root@SYL3 ~]# ls
1.1.txt anaconda-ks.cfg nginx-1.20.2 nginx-1.20.2.tar.gz
1.3 进入解压目录,并检查安装环境
[root@SYL3 ~]# cd nginx-1.20.2
[root@SYL3 nginx-1.20.2]# ls
CHANGES LICENSE auto configure html src
CHANGES.ru README conf contrib man
1.4 进行预编译并且解决问题
- 1.缺少编译器
[root@SYL3 nginx-1.20.2]# ./configure --prefix=/usr/local/nginx
checking for OS
+ Linux 4.18.0-348.el8.x86_64 x86_64
checking for C compiler ... not found
./configure: error: C compiler cc is not found
./configure: error: C编译器没有找到cc
[root@SYL3 nginx-1.20.2]# yum -y install gcc gcc-c++
- 2.HTTP重写需要PCRE库
[root@SYL3 nginx-1.20.2]# ./configure --prefix=/usr/local/nginx
./configure: error: the HTTP rewrite module requires the PCRE library.
./configure: error: HTTP重写模块需要PCRE库。
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
[root@SYL3 nginx-1.20.2]# yum -y install pcre-devel
Failed to set locale, defaulting to C.UTF-8
Updating Subscription Management repositories.
Unable to read consumer identity
- 3.HTTP gzip模块需要zlib库。
./configure: error: the HTTP gzip module requires the zlib library.
./configure: error: HTTP gzip模块需要zlib库。
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
[root@SYL3 nginx-1.20.2]#
[root@SYL3 nginx-1.20.2]# yum -y install zlib-devel
- 4.安装nginx的时候没有指定openssl的解压路径
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using system zlib library
配置概述
+使用系统PCRE库
+ OpenSSL库未使用
+使用系统zlib库
[root@SYL3 nginx-1.20.2]# ./configure --help|grep ssl
--with-http_ssl_module enable ngx_http_ssl_module
--with-mail_ssl_module enable ngx_mail_ssl_module
--with-stream_ssl_module enable ngx_stream_ssl_module
--with-stream_ssl_preread_module enable ngx_stream_ssl_preread_module
--with-openssl=DIR set path to OpenSSL library sources
--with-openssl-opt=OPTIONS set additional build options for OpenSSL
[root@SYL3 nginx-1.20.2]# ./configure --prefix=/usr/local/nginx --with-http_ssl_module
- 指定openssl后,SSL模块需要OpenSSL库
./configure: error: SSL modules require the OpenSSL library.
./configure:错误:SSL模块需要OpenSSL库。
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
[root@SYL3 nginx-1.20.2]#
[root@SYL3 nginx-1.20.2]# yum -y install openssl openssl-devel
Configuration summary
+ using system PCRE library
+ using system OpenSSL library
+ using system zlib library
1.5 解决问题,并且生成了makefile文件
[root@SYL3 nginx-1.20.2]# ls
CHANGES LICENSE README conf contrib man src
CHANGES.ru Makefile auto configure html objs
[root@SYL3 nginx-1.20.2]#
1.6 查看并指定CPU的核心数,编译并安装
- 编译
[root@SYL3 nginx-1.20.2]# nproc
4
[root@SYL3 nginx-1.20.2]# make -j 3
bash: make: command not found
[root@SYL3 nginx-1.20.2]# yum -y install make
[root@SYL3 nginx-1.20.2]# make -j 3
objs/src/http/modules/ngx_http_upstream_random_module.o \
objs/src/http/modules/ngx_http_upstream_keepalive_module.o \
objs/src/http/modules/ngx_http_upstream_zone_module.o \
objs/ngx_modules.o \
-ldl -lpthread -lcrypt -lpcre -lssl -lcrypto -ldl -lpthread -lz \
-Wl,-E
make[1]: Leaving directory '/root/nginx-1.20.2'
[root@SYL3 nginx-1.20.2]#
- 安装
[root@SYL3 nginx-1.20.2]# make install
make -f objs/Makefile install
make[1]: Entering directory '/root/nginx-1.20.2'
test -d '/usr/local/nginx' || mkdir -p '/usr/local/nginx'
test -d '/usr/local/nginx/sbin' \
|| mkdir -p '/usr/local/nginx/sbin'
test ! -f '/usr/local/nginx/sbin/nginx' \
|| mv '/usr/local/nginx/sbin/nginx' \
'/usr/local/nginx/sbin/nginx.old'
cp objs/nginx '/usr/local/nginx/sbin/nginx'
test -d '/usr/local/nginx/conf' \
|| mkdir -p '/usr/local/nginx/conf'
cp conf/koi-win '/usr/local/nginx/conf'
cp conf/koi-utf '/usr/local/nginx/conf'
cp conf/win-utf '/usr/local/nginx/conf'
test -f '/usr/local/nginx/conf/mime.types' \
|| cp conf/mime.types '/usr/local/nginx/conf'
cp conf/mime.types '/usr/local/nginx/conf/mime.types.default'
test -f '/usr/local/nginx/conf/fastcgi_params' \
|| cp conf/fastcgi_params '/usr/local/nginx/conf'
cp conf/fastcgi_params \
'/usr/local/nginx/conf/fastcgi_params.default'
test -f '/usr/local/nginx/conf/fastcgi.conf' \
|| cp conf/fastcgi.conf '/usr/local/nginx/conf'
cp conf/fastcgi.conf '/usr/local/nginx/conf/fastcgi.conf.defa
1.7 退出,查看
-
退出,查看
-
[root@SYL3 ~]# ls /usr/local/ bin games lib libexec sbin src etc include lib64 nginx share [root@SYL3 ~]# ls /usr/local/nginx/ conf html logs sbin [root@SYL3 ~]# ss -antl 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 [::]:22 [::]:*
1.8 启动nginx,访问地址
-
启动
-
[root@SYL3 ~]# /usr/local/nginx/sbin/nginx [root@SYL3 ~]# ss -antl 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 [::]:*
-
访问地址
-
[root@SYL3 ~]# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: ens160: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 link/ether 00:0c:29:88:16:9d brd ff:ff:ff:ff:ff:ff inet 192.168.232.128/24 brd 192.168.232.255 scope global dynamic noprefixroute ens160 valid_lft 1347sec preferred_lft 1347sec inet6 fe80::20c:29ff:fe88:169d/64 scope link noprefixroute valid_lft forever preferred_lft forever [root@SYL3 ~]#
-
关闭防火墙
-
[root@SYL3 nginx-1.20.2]# cd [root@SYL3 ~]# systemctl disable --now firewalld Removed /etc/systemd/system/multi-user.target.wants/firewalld.service. Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. [root@SYL3 ~]#
1.9 修改环境变量并且读取
[root@SYL3 ~]# ls /etc/profile.d/
colorgrep.csh colorxzgrep.sh gawk.sh sh.local
colorgrep.sh colorzgrep.csh lang.csh which2.csh
colorls.csh colorzgrep.sh lang.sh which2.sh
colorls.sh csh.local less.csh
colorxzgrep.csh gawk.csh less.sh
[root@SYL3 ~]# echo 'export PATH=/usr/local/nginx/sbin:$PATH' > /etc/profile.d/nginx.sh
[root@SYL3 ~]# cat /etc/profile.d/nginx.sh
export PATH=/usr/local/nginx/sbin:$PATH
[root@SYL3 ~]# echo $PATH/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@SYL3 ~]# source
-bash: source: filename argument required
source: usage: source filename [arguments]
[root@SYL3 ~]# source /etc/profile.d/nginx.sh
[root@SYL3 ~]# echo $PATH
/usr/local/nginx/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@SYL3 ~]# pkill nginx
[root@SYL3 ~]# ss -antl
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 [::]:22 [::]:*
[root@SYL3 ~]# nginx
[root@SYL3 ~]# ss -antl
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 [::]:*
[root@SYL3 ~]#
注意事项
- 如果安装时不是使用的默认路径,则必须要修改PATH环境变量,以能够识别此程序的二进制文件路径;
- 修改/etc/profile文件或在/etc/profile.d/目录建立一个以.sh为后缀的文件,在里面定义export PATH=$PATH:/path/to/somewhere
- 默认情况下,系统搜索库文件的路径只有/lib,/usr/lib
- 增添额外库文件搜索路径方法:
- 在/etc/ld.so.conf.d/中创建以.conf为后缀名的文件,而后把要增添的路径直接写至此文件中。此时库文件增添的搜索路径重启后有效,若要使用增添的路径立即生效则要使用ldconfig命令
- ldconfig:通知系统重新搜索库文件
- 增添额外库文件搜索路径方法:
/etc/ld.so.conf和/etc/ls.so.conf.d/*.conf //配置文件
/etc/ld.so.cache //缓存文件
-v //显示重新搜索库的过程
-p //打印出系统启动时自动加载并缓存到内存中的可用库文件名及文件路径映射关系
-
头文件:输出给系统
-
默认:系统在/usr/include中找头文件,若要增添头文件搜索路径,使用链接进行
-
ls /usr/local/nginx/ ls -s /usr/local/nginx/include /usr/include/nginx
-
-
man文件路径:安装在–prefix指定的目录下的man目录
-
默认:系统在/usr/share/man中找man文件。此时因为编译安装的时候不是安装到默认路径下,如果要查找man文件则可以使用以下两种方法:
-
man -M /path/to/man_dir command
-
在/etc/man_db.conf文件中添加一条MANPATH
-
-
2. httpd
编译安装
2.1.1 apr下载地址
2.1.2 apr-util下载地址
2.1.3 httpd的下载地址
2.2 下载并解压
- 下载
1.apr/apr-1.6.5.tar.gz 2.apr/apr-1.6.5.tar.gz 3./httpd/httpd-2.4.53.tar.gz
[root@SYL3 ~]# wget https://downloads.apache.org/apr/apr-1.6.5.tar.gz --2022-04-08 16:08:41-- https://downloads.apache.org/apr/apr-1.6.5.tar.gz Resolving downloads.apache.org (downloads.apache.org)... 135.181.214.104, 88.99.95.219, 2a01:4f8:10a:201a::2, ... Connecting to downloads.apache.org (downloads.apache.org)|135.181.214.104|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 1073556 (1.0M) [application/x-gzip] Saving to: 'apr-1.6.5.tar.gz.1' apr-1.6.5.tar.g 100%[====>] 1.02M 24.8KB/s in 47s 2022-04-08 16:09:29 (22.3 KB/s) - 'apr-1.6.5.tar.gz.1' saved [1073556/1073556] [root@SYL3 ~]# wget https://downloads.apache.org/httpd/httpd-2.4.53.tar.gz --2022-04-08 16:20:57-- https://downloads.apache.org/httpd/httpd-2.4.53.tar.gz Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f9:3a:2c57::2, ... Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 9726558 (9.3M) [application/x-gzip] Saving to: 'httpd-2.4.53.tar.gz' httpd-2.4.53.ta 100%[====>] 9.28M 87.8KB/s in 3m 40s 2022-04-08 16:24:39 (43.1 KB/s) - 'httpd-2.4.53.tar.gz' saved [9726558/9726558] [root@SYL3 ~]# wget https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz --2022-04-08 16:26:15-- https://downloads.apache.org/apr/apr-util-1.6.1.tar.gz Resolving downloads.apache.org (downloads.apache.org)... 88.99.95.219, 135.181.214.104, 2a01:4f9:3a:2c57::2, ... Connecting to downloads.apache.org (downloads.apache.org)|88.99.95.219|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 554301 (541K) [application/x-gzip] Saving to: 'apr-util-1.6.1.tar.gz' apr-util-1.6.1. 100%[====>] 541.31K 33.6KB/s in 18s 2022-04-08 16:26:34 (30.7 KB/s) - 'apr-util-1.6.1.tar.gz' saved [554301/554301] [root@SYL3 ~]# wget https://downloads.apache.org/apr/apr-1.6.5.tar.gz --2022-04-08 16:27:33-- https://downloads.apache.org/apr/apr-1.6.5.tar.gz Resolving downloads.apache.org (downloads.apache.org 标签:
pcb传感器进口201a75