nginx
编译安装ngink
的网络地址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
[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
[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++
[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
./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
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
./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
[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]#
[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
退出,查看
[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 [::]:*
启动
[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 ~]#
[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 ~]#
/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
httpd
编译安装 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)... 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'
apr-1.6.5.tar.g 100%[====>] 1.02M 22.1KB/s in 44s
2022-04-08 16:28:19 (23.9 KB/s) - 'apr-1.6.5.tar.gz' saved [1073556/1073556]
[root@SYL3 ~]# ls
1.1.txt apr-util-1.6.1.tar.gz nginx-1.20.2.tar.gz
anaconda-ks.cfg httpd-2.4.53.tar.gz
apr-1.6.5.tar.gz nginx-1.20.2
[root@SYL3 ~]#
[root@SYL3 ~]# tar xf apr-util-1.6.1.tar.gz
[root@SYL3 ~]# tar xf apr-1.6.5.tar.gz
[root@SYL3 ~]# tar xf httpd-2.4.53.tar.gz
[root@SYL3 ~]# ls
1.1.txt apr-util-1.6.1 nginx-1.20.2
anaconda-ks.cfg apr-util-1.6.1.tar.gz nginx-1.20.2.tar.gz
apr-1.6.5 httpd-2.4.53
apr-1.6.5.tar.gz httpd-2.4.53.tar.gz
[root@SYL3 ~]#
apr-1.6.5
解压目录,并且预编译解决问题[root@SYL3 ~]# cd apr-1.7.0
[root@SYL3 apr-1.7.0]# ls
CHANGES apr.dsp configure libapr.mak strings
CMakeLists.txt apr.dsw configure.in libapr.rc support
LICENSE apr.mak docs locks tables
Makefile.in apr.pc.in dso memory test
Makefile.win apr.spec emacs-mode misc threadproc
NOTICE atomic encoding mmap time
NWGNUmakefile build file_io network_io tools
README build-outputs.mk helpers passwd user
README.cmake build.conf include poll
apr-config.in buildconf libapr.dep random
apr.dep config.layout libapr.dsp shmem
[root@SYL3 apr-1.7.0]# ./configure --prefix=/usr/local/apr
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
Configuring APR library
Platform: x86_64-pc-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.7.0
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/root/apr-1.7.0':
configure: error: no acceptable C compiler found in $PATH
在/root/apr-1.7.0中配置错误:
错误:在$PATH中找不到可接受的C编译器
See `config.log' for more details
[root@SYL3 apr-1.7.0]#
[root@SYL3 apr-1.7.0]# dnf -y install gcc gcc-c++
[root@SYL3 apr-1.7.0]# ./configure --prefix=/usr/local/apr
[root@SYL3 apr-1.7.0]# ls
CHANGES apr.dep config.layout include poll
CMakeLists.txt apr.dsp config.log libapr.dep random
LICENSE apr.dsw config.nice libapr.dsp shmem
Makefile apr.mak config.status libapr.mak strings
Makefile.in apr.pc configure libapr.rc support
Makefile.win apr.pc.in configure.in libtool tables
NOTICE apr.spec docs locks test
NWGNUmakefile atomic dso memory threadproc
README build emacs-mode misc time
README.cmake build-outputs.mk encoding mmap tools
apr-1-config build.conf file_io network_io user
apr-config.in buildconf helpers passwd
[root@SYL3 apr-1.7.0]#
[root@SYL3 apr-1.7.0]# nproc
4
[root@SYL3 apr-1.7.0]# make -j 3
/sha2.lo random/unix/sha2_glue.lo shmem/unix/shm.lo support/unix/waitio.lo threadproc/unix/proc.lo threadproc/unix/procsup.lo threadproc/unix/signals.lo threadproc/unix/thread.lo threadproc/unix/threadpriv.lo time/unix/time.lo time/unix/timestr.lo user/unix/groupinfo.lo user/unix/userinfo.lo -lrt -lcrypt -lpthread -ldl
make[1]: Leaving directory '/root/apr-1.7.0'
[root@SYL3 apr-1.7.0]# make install
/usr/bin/install -c -m 755 /root/apr-1.7.0/build/mkdir.sh /usr/local/apr/build-1
for f in make_exports.awk make_var_export.awk; do \
/usr/bin/install -c -m 644 /root/apr-1.7.0/build/${f} /usr/local/apr/build-1; \
done
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config
[root@SYL3 apr-1.7.0]#
[root@SYL3 ~]# ls /usr/local/
apr bin etc games include lib lib64 libexec sbin share src
[root@SYL3 ~]# ls /usr/local/apr/
bin build-1 include lib
apr-util
进行预编译并解决问题[root@SYL3 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
APR-util Version: 1.6.1
checking for chosen layout... apr-util
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
Applying apr-util hints file rules for x86_64-pc-linux-gnu
checking for APR... no
configure: error: APR could not be located. Please use the --with-apr option.
配置:错误:APR不能被定位。 请使用——with-apr选项。
[root@SYL3 apr-util-1.6.1]#
[root@SYL3 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
APR-util Version: 1.6.1
checking for chosen layout... apr-util
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
Applying apr-util hints file rules for x86_64-pc-linux-gnu
checking for APR... configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.
[root@SYL3 apr-util-1.6.1]#
[root@SYL3 apr-util-1.6.1]#
[root@SYL3 apr-util-1.6.1]# nproc
4
[root@SYL3 apr-util-1.6.1]# make -j 3
compilation terminated.
make[1]: *** [/root/apr-util-1.6.1/build/rules.mk:206: xml/apr_xml.lo] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/root/apr-util-1.6.1'
make: *** [/root/apr-util-1.6.1/build/rules.mk:118: all-recursive] Error 1
编译终止。
[1]: * * *(/根/ apr-util-1.6.1 /构建/规则。 可:206:xml / apr_xml。 lo)错误1
make[1]: *** Waiting for unfinished jobs....
make[1]: leave directory '/root/apr-util-1.6.1'
: * * *(/根/ apr-util-1.6.1 /构建/规则。 mk:118: all-recursive]错误1
[root@SYL3 apr-util-1.6.1]#
[root@SYL3 apr-util-1.6.1]# yum -y install expat-devel
[root@SYL3 apr-util-1.6.1]# make -j 3
m/sdbm.lo dbm/sdbm/sdbm_hash.lo dbm/sdbm/sdbm_lock.lo dbm/sdbm/sdbm_pair.lo encoding/apr_base64.lo hooks/apr_hooks.lo ldap/apr_ldap_stub.lo ldap/apr_ldap_url.lo memcache/apr_memcache.lo misc/apr_date.lo misc/apr_queue.lo misc/apr_reslist.lo misc/apr_rmm.lo misc/apr_thread_pool.lo misc/apu_dso.lo misc/apu_version.lo redis/apr_redis.lo strmatch/apr_strmatch.lo uri/apr_uri.lo xlate/xlate.lo xml/apr_xml.lo -lrt -lcrypt -lpthread -ldl /usr/local/apr/lib/libapr-1.la -lrt -lcrypt -lpthread -ldl
make[1]: Leaving directory '/root/apr-util-1.6.1'
[root@SYL3 apr-util-1.6.1]#
[root@SYL3 apr-util-1.6.1]# make install
make[1]: Entering directory '/root/apr-util-1.6.1'
make[1]: Nothing to be done for 'local-all'.
make[1]: Leaving directory '/root/apr-util-1.6.1'
/usr/local/apr/build-1/mkdir.sh /usr/local/apr-util/include/apr-1 /usr/local/apr-util/lib/pkgconfig \
/usr/local/apr-util/lib /usr/local/apr-util/bin
for f in /root/apr-util-1.6.1/include/*.h /root/apr-util-1.6.1/include/*.h; do \
/usr/bin/install -c -m 644 ${f} /usr/local/apr-util/include/apr-1; \
done
/usr/bin/install -c -m 644 apr-util.pc /usr/local/apr-util/lib/pkgconfig/apr-util-1.pc
list=''; for i in $list; do \
( cd $i ; make DESTDIR= install ); \
done
/bin/sh /usr/local/apr/build-1/libtool --mode=install /usr/bin/install -c -m 755 libaprutil-1.la /usr/local/apr-util/lib
libtool: install: /usr/bin/install -c -m 755 .libs/libaprutil-1.so.0.6.1 /usr/local/apr-util/lib/libaprutil-1.so.0.6.1
libtool: install: (cd /usr/local/apr-util/lib && { ln -s -f libaprutil-1.so.0.6.1 libaprutil-1.so.0 || { rm -f libaprutil-1.so.0 && ln -s libaprutil-1.so.0.6.1 libaprutil-1.so.0; }; })
libtool: install: (cd /usr/local/apr-util/lib && { ln -s -f libaprutil-1.so.0.6.1 libaprutil-1.so || { rm -f libaprutil-1.so && ln -s libaprutil-1.so.0.6.1 libaprutil-1.so; }; })
libtool: install: /usr/bin/install -c -m 755 .libs/libaprutil-1.lai /usr/local/apr-util/lib/libaprutil-1.la
libtool: install: /usr/bin/install -c -m 755 .libs/libaprutil-1.a /usr/local/apr-util/lib/libaprutil-1.a
libtool: install: chmod 644 /usr/local/apr-util/lib/libaprutil-1.a
libtool: install: ranlib /usr/local/apr-util/lib/libaprutil-1.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /usr/local/apr-util/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/apr-util/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr-util/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr-util/bin/apu-1-config
[root@SYL3 apr-util-1.6.1]#
[root@SYL3 ~]# ls /usr/local/apr-util/
bin include lib
[root@SYL3 ~]#
httpd
进行预编译并解决问题[root@SYL3 httpd-2.4.53]# ./configure --prefix=/usr/local/httpd
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... yes
setting CC to "gcc"
setting CPP to "gcc -E"
setting CFLAGS to " -g -O2 -pthread"
setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"
setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... no
configure: error: APR-util not found. Please read the documentation.
错误:APR-util未找到。 请阅读文档。
[root@SYL3 httpd-2.4.53]#
[root@SYL3 httpd-2.4.53]# ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
checking for pcre2-config... no
checking for pcre-config... no
configure: error: pcre(2)-config for libpcre not found. PCRE is required and available from http://pcre.org/
Configure: error: pcre(2)-config for libpcre not found PCRE是必需的,可从http://pcre.org/获得
[root@SYL3 httpd-2.4.53]#
[root@SYL3 httpd-2.4.53]# rpm -qa | grep pcre
pcre2-10.32-2.el8.x86_64
pcre-8.42-6.el8.x86_64
[root@SYL3 httpd-2.4.53]# yum -y install pcre-devel //安装完成后在进行预编译
[root@SYL3 httpd-2.4.53]# ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
Server Version: 2.4.53
Install prefix: /usr/local/httpd
C compiler: gcc
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
[root@SYL3 httpd-2.4.53]#
[root@SYL3 httpd-2.4.53]# nproc
4
[root@SYL3 httpd-2.4.53]# make -j 3
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:52: htdigest] Error 1
make[2]: Leaving directory '/root/httpd-2.4.53/support'
make[1]: *** [/root/httpd-2.4.53/build/rules.mk:75: all-recursive] Error 1
make[1]: Leaving directory '/root/httpd-2.4.53/support'
make: *** [/root/httpd-2.4.53/build/rules.mk:75: all-recursive] Error 1
[root@SYL3 httpd-2.4.53]#
[root@SYL3 httpd-2.4.53]# yum -y install libxml2-devel
apr -util
之后在进行编译[root@SYL3 httpd-2.4.53]# rm -rf /usr/local/apr-util
[root@SYL3 apr-util-1.6.1]# make clean
[root@SYL3 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@SYL3 apr-util-1.6.1]# make -j 3
[root@SYL3 apr-util-1.6.1]# make install
make[1]: Entering directory '/root/apr-util-1.6.1'
make[1]: Nothing to be done for 'local-all'.
make[1]: Leaving directory '/root/apr-util-1.6.1'
/usr/local/apr/build-1/mkdir.sh /usr/local/apr-util/include/apr-1 /usr/local/apr-util/lib/pkgconfig \
/usr/local/apr-util/lib /usr/local/apr-util/bin
for f in /root/apr-util-1.6.1/include/*.h /root/apr-util-1.6.1/include/*.h; do \
/usr/bin/install -c -m 644 ${f} /usr/local/apr-util/include/apr-1; \
done
/usr/bin/install -c -m 644 apr-util.pc /usr/local/apr-util/lib/pkgconfig/apr-util-1.pc
list=''; for i in $list; do \
( cd $i ; make DESTDIR= install ); \
done
/bin/sh /usr/local/apr/build-1/libtool --mode=install /usr/bin/install -c -m 755 libaprutil-1.la /usr/local/apr-util/lib
libtool: install: /usr/bin/install -c -m 755 .libs/libaprutil-1.so.0.6.1 /usr/local/apr-util/lib/libaprutil-1.so.0.6.1
libtool: install: (cd /usr/local/apr-util/lib && { ln -s -f libaprutil-1.so.0.6.1 libaprutil-1.so.0 || { rm -f libaprutil-1.so.0 && ln -s libaprutil-1.so.0.6.1 libaprutil-1.so.0; }; })
libtool: install: (cd /usr/local/apr-util/lib && { ln -s -f libaprutil-1.so.0.6.1 libaprutil-1.so || { rm -f libaprutil-1.so && ln -s libaprutil-1.so.0.6.1 libaprutil-1.so; }; })
libtool: install: /usr/bin/install -c -m 755 .libs/libaprutil-1.lai /usr/local/apr-util/lib/libaprutil-1.la
libtool: install: /usr/bin/install -c -m 755 .libs/libaprutil-1.a /usr/local/apr-util/lib/libaprutil-1.a
libtool: install: chmod 644 /usr/local/apr-util/lib/libaprutil-1.a
libtool: install: ranlib /usr/local/apr-util/lib/libaprutil-1.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/sbin" ldconfig -n /usr/local/apr-util/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/apr-util/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr-util/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr-util/bin/apu-1-config
[root@SYL3 apr-util-1.6.1]#
httpd
进行编译[root@SYL3 httpd-2.4.53]# ./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
[root@SYL3 httpd-2.4.53]# make -j 3
make[4]: Leaving directory '/root/httpd-2.4.53/modules/mappers'
make[3]: Leaving directory '/root/httpd-2.4.53/modules/mappers'
make[2]: Leaving directory '/root/httpd-2.4.53/modules'
make[2]: Entering directory '/root/httpd-2.4.53/support'
make[2]: Leaving directory '/root/httpd-2.4.53/support'
make[1]: Leaving directory '/root/httpd-2.4.53'
[root@SYL3 httpd-2.4.53]#
[root@SYL3 httpd-2.4.53]# make install
mkdir /usr/local/httpd/cgi-bin
Installing header files
mkdir /usr/local/httpd/include
Installing build system files
mkdir /usr/local/httpd/build
Installing man pages and online manual
mkdir /usr/local/httpd/man
mkdir /usr/local/httpd/man/man1
mkdir /usr/local/httpd/man/man8
mkdir /usr/local/httpd/manual
make[1]: Leaving directory '/root/httpd-2.4.53'
[root@SYL3 httpd-2.4.53]#
[root@SYL3 httpd-2.4.53]# echo $?
0
[root@SYL3 httpd-2.4.53]#
[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 ~]# /usr/local/httpd/bin/httpd
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe88:169d%ens160. Set the 'ServerName' directive globally to suppress this message
[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 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[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 ~]# 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 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@SYL3 ~]#
查看
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 1206sec preferred_lft 1206sec
inet6 fe80::20c:29ff:fe88:169d/64 scope link noprefixroute
valid_lft forever preferred_lft forever
[root@SYL3 local]#
[root@SYL3 ~]# echo 'export PATH=/usr/local/httpd/bin:$PATH' > /etc/profile.d/httpd.sh
[root@SYL3 ~]# cat /etc/profile.d/httpd.sh
export PATH=/usr/local/httpd/bin:$PATH
[root@SYL3 ~]# echo
[root@SYL3 ~]# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@SYL3 ~]# pkill httpd
[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 ~]# httpd
-bash: httpd: command not found
[root@SYL3 ~]# httpd
-bash: httpd: command not found
[root@SYL3 ~]# source /etc/profile.d/httpd.sh
[root@SYL3 ~]# echo $PATH
/usr/local/httpd/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
[root@SYL3 ~]# pkill httpd
[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 ~]# httpd
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe88:169d%ens160. Set the 'ServerName' directive globally to suppress this message
[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 *:80 *:*
LISTEN 0 128 [::]:22 [::]:*
[root@SYL3 ~]#
Linux中磁盘的命名方式与磁盘的接口有关,规则如下:
在设备名称的定义规则如下, 其他的分区可以以此类推
系统的第一块SCSI接口的硬盘名称为/dev/sda
系统的第二块SCSI接口的硬盘名称为/dev/sdb
系统中分区由数字编号表示, 1-4留给主分区使用和扩展分区, 逻辑分区从5开始
MBR:主引导记录,是位于磁盘最前边的一段引导代码,主要用来引导操作系统的加载与启动
GPT:GUID磁盘分区表,全局唯一标识磁盘分区表”,是一个实体硬盘的分区表的结构布局的标准
[root@SYL3 ~]# df
Filesystem 1K-blocks Used Available Use% Mounted on
devtmpfs 897416 0 897416 0% /dev
tmpfs 916616 0 916616 0% /dev/shm
tmpfs 916616 8904 907712 1% /run
tmpfs 916616 0 916616 0% /sys/fs/cgroup
/dev/mapper/rhel-root 17811456 2096344 15715112 12% /
/dev/sda1 1038336 216572 821764 21% /boot
tmpfs 183320 0 183320 0% /run/user/0
df -i //查看inode使用情况
df -h //以G或者T或者M人性化方式显示
df -T //查看文件类型
df -h
查看每个分区的容量
[root@SYL3 ~]# df -h
//设备名称 //磁盘大小 已用大小 可用大小 使用百分比 挂载点
Filesystem Size Used Avail Use% Mounted on
devtmpfs 877M 0 877M 0% /dev
tmpfs 896M 0 896M 0% /dev/shm
tmpfs 896M 8.7M 887M 1% /run
tmpfs 896M 0 896M 0% /sys/fs/cgroup
/dev/mapper/rhel-root 17G 2.1G 15G 12% /
/dev/sda1 1014M 212M 803M 21% /boot
tmpfs 180M 0 180M 0% /run/user/0
df -i
查看inode
(磁盘块在磁盘中的位置)使用情况
[root@SYL3 ~]# df -i
Filesystem Inodes IUsed IFree IUse% Mounted on
devtmpfs 224354 412 223942 1% /dev
tmpfs 229154 1 229153 1% /dev/shm
tmpfs 229154 603 228551 1% /run
tmpfs 229154 17 229137 1% /sys/fs/cgroup
/dev/mapper/rhel-root 8910848 46622 8864226 1% /
/dev/sda1 524288 310 523978 1% /boot
tmpfs 229154 5 229149 1% /run/user/0
[root@SYL3 ~]#
df -T
查看文件类型
[root@SYL3 ~]# df -T
Filesystem Type 1K-blocks Used Available Use% Mounted on
devtmpfs devtmpfs 897416 0 897416 0% /dev
tmpfs tmpfs 916616 0 916616 0% /dev/shm
tmpfs tmpfs 916616 8904 907712 1% /run
tmpfs tmpfs 916616 0 916616 0% /sys/fs/cgroup
/dev/mapper/rhel-root xfs 17811456 2098396 15713060 12% /
/dev/sda1 xfs 1038336 216572 821764 21% /boot
tmpfs tmpfs 183320 0 183320 0% /run/user/0
[root@SYL3 ~]#
[root@SYL3 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 1G 0 part /boot
`-sda2 8:2 0 19G 0 part
|-rhel-root 253:0 0 17G 0 lvm /
`-rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 5G 0 disk
sdc 8:32 0 5G 0 disk
sr0 11:0 1 10.2G 0 rom
[root@SYL3 ~]#
du -sh opt //人性化输出显示大小
-s:列出总和
-h:人性化显示容量信息
du -sh
[root@SYL3 ~]# du -sh /opt/
0 /opt/
[root@SYL3 ~]# du -sh anaconda-ks.cfg
4.0K anaconda-ks.cfg
[root@SYL3 ~]#
分区工具有fdisk和gdisk,当硬盘小于2T的时候我们应该用fdisk来分区,而当硬盘大于2T的时候则应用gdisk来进行分区
Command action
a toggle a bootable flag //切换分区启动标记
b edit bsd disklabel //编辑sdb磁盘标签
c toggle the dos compatibility flag //切换dos兼容模式
d delete a partition //删除分区
l list known partition types //显示分区类型
m print this menu //显示帮助菜单
n add a new partition //新建分区
o create a new empty DOS partition table //创建新的空白分区表
p print the partition table //显示分区表的信息
q quit without saving changes //不保存退出
s create a new empty Sun disklabel //创建新的Sun磁盘标签
t change a partition's system id //修改分区ID,可以通过l查看id
u change display/entry units //修改容量单位,磁柱或扇区
v verify the partition table //检验分区表
w write table to disk and exit //保存退出
x extra functionality (experts only) //拓展功能
MBR格式分区用fdisk -l 查看有个dos标志
fdisk -l
列出当前系统的硬盘分区情况
创建主分区
[root@SYL3 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n //创建分区
Partition type
p primary (0 primary, 0 extended, 4 free)
e extended (container for logical partitions)
Select (default p): 默认主分区
Using default response p.
Partition number (1-4, default 1): 默认编号为1
First sector (2048-10485759, default 2048): 默认扇区
Last sector, +sectors or +size{K,M,G,T,P} (2048-10485759, default 10485759): +600M
Created a new partition 1 of type 'Linux' and of size 600 MiB.
Command (m for help): p 显示分区表信息
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos//MBR格式分区
Disk identifier: 0xb99991fc
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1230847 1228800 600M 83 Linux
Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p):
Using default response p.
Partition number (2-4, default 2):
First sector (1230848-10485759, default 1230848):
Last sector, +sectors or +size{K,M,G,T,P} (1230848-10485759, default 10485759): +200M
Created a new partition 2 of type 'Linux' and of size 200 MiB.
Command (m for help): p
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb99991fc
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1230847 1228800 600M 83 Linux
/dev/sdb2 1230848 1640447 409600 200M 83 Linux
Command (m for help): w //保存
查看分区情况
[root@SYL3 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 1G 0 part /boot
`-sda2 8:2 0 19G 0 part
|-rhel-root 253:0 0 17G 0 lvm /
`-rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 5G 0 disk
|-sdb1 8:17 0 600M 0 part
`-sdb2 8:18 0 200M 0 part
sdc 8:32 0 5G 0 disk
sr0 11:0 1 10.2G 0 rom
[root@SYL3 ~]#
创建扩展分区,会占用
[root@SYL3 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
Partition type
p primary (2 primary, 0 extended, 2 free)
e extended (container for logical partitions)
Select (default p): e //创建扩展分区
Partition number (3,4, default 3):
First sector (1640448-10485759, default 1640448):
Last sector, +sectors or +size{K,M,G,T,P} (1640448-10485759, default 10485759):
Created a new partition 3 of type 'Extended' and of size 4.2 GiB.
Command (m for help): p
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb99991fc
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1230847 1228800 600M 83 Linux
/dev/sdb2 1230848 1640447 409600 200M 83 Linux
/dev/sdb3 1640448 10485759 8845312 4.2G 5 Extend
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
查看分区
[root@SYL3 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 1G 0 part /boot
`-sda2 8:2 0 19G 0 part
|-rhel-root 253:0 0 17G 0 lvm /
`-rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 5G 0 disk
|-sdb1 8:17 0 600M 0 part
|-sdb2 8:18 0 200M 0 part
`-sdb3 8:19 0 1K 0 part
sdc 8:32 0 5G 0 disk
sr0 11:0 1 10.2G 0 rom
[root@SYL3 ~]#
创建逻辑分区
[root@SYL3 ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n
All space for primary partitions is in use.
Adding logical partition 5
First sector (1642496-10485759, default 1642496):
Last sector, +sectors or +size{K,M,G,T,P} (1642496-10485759, default 10485759): +1000M
Created a new partition 5 of type 'Linux' and of size 1000 MiB.
Command (m for help): p
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb99991fc
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1230847 1228800 600M 83 Linux
/dev/sdb2 1230848 1640447 409600 200M 83 Linux
/dev/sdb3 1640448 10485759 8845312 4.2G 5 Extend
/dev/sdb5 1642496 3690495 2048000 1000M 83 Linux
Command (m for help):
更改swap空间
Command (m for help): l
0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Rufus alignment
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto
1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep
1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT
Command (m for help): t
Partition number (1-3,5, default 5):
Hex code (type L to list all codes): 82 //82代表linux swap空间
Changed type of partition 'Linux' to 'Linux swap / Solaris'.
Command (m for help): p
Disk /dev/sdb: 5 GiB, 5368709120 bytes, 10485760 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos//MBR格式分区
Disk identifier: 0xb99991fc
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 1230847 1228800 600M 83 Linux
/dev/sdb2 1230848 1640447 409600 200M 83 Linux
/dev/sdb3 1640448 10485759 8845312 4.2G 5 Extended
/dev/sdb5 1642496 3690495 2048000 1000M 82 Linux swap / Solaris
Command (m for help): w
The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.
查看分区
[root@SYL3 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 1G 0 part /boot
`-sda2 8:2 0 19G 0 part
|-rhel-root 253:0 0 17G 0 lvm /
`-rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 5G 0 disk
|-sdb1 8:17 0 600M 0 part
|-sdb2 8:18 0 200M 0 part
|-sdb3 8:19 0 1K 0 part
`-sdb5 8:21 0 1000M 0 part
sdc 8:32 0 5G 0 disk
sr0 11:0 1 10.2G 0 rom
[root@SYL3 ~]#
[root@SYL3 ~]# gdisk /dev/sdc //用gdisk分区
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
MBR: not present
BSD: not present
APM: not present
GPT: not present
Creating new GPT entries.
Command (? for help): help//查看帮助文档
b back up GPT data to a file
c change a partition's name
d delete a partition
i show detailed information on a partition
l list known partition types
n add a new partition
o create a new empty GUID partition table (GPT)
p print the partition table
q quit without saving changes
r recovery and transformation options (experts only)
s sort partitions
t change a partition's type code
v verify disk
w write table to disk and exit
x extra functionality (experts only)
? print this menu
Command (? for help): n//创建分区
Partition number (1-128, default 1): 默认编号
First sector (34-10485726, default = 2048) or {+-}size{KMGTP}: //默认
Last sector (2048-10485726, default = 10485726) or {+-}size{KMGTP}: +500M//分配500M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
Command (? for help): p//打印
Disk /dev/sdc: 10485760 sectors, 5.0 GiB
Model: VMware Virtual S
Sector size (logical/physical): 512/512 bytes
Disk identifier (GUID): 4B0CC6ED-D599-4704-AF15-4D1C718FCC0C
Partition table holds up to 128 entries
Main partition table begins at sector 2 and ends at sector 33
First usable sector is 34, last usable sector is 10485726
Partitions will be aligned on 2048-sector boundaries
Total free space is 9461693 sectors (4.5 GiB)
Number Start (sector) End (sector) Size Code Name
1 2048 1026047 500.0 MiB 8300 Linux filesystem
Command (? for help): n
Partition number (2-128, default 2):
First sector (34-10485726, default = 1026048) or {+-}size{KMGTP}:
Last sector (1026048-10485726, default = 10485726) or {+-}size{KMGTP}: +300M
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
Command (? for help): w//保存
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sdc.
The operation has completed successfully.
[root@SYL3 ~]#
重新读取分区,在查看
[root@SYL3 ~]# partprobe//重新读取
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
[root@SYL3 ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
|-sda1 8:1 0 1G 0 part /boot
`-sda2 8:2 0 19G 0 part
|-rhel-root 253:0 0 17G 0 lvm /
`-rhel-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 5G 0 disk
|-sdb1 8:17 0 600M 0 part
|-sdb2 8:18 0 200M 0 part
|-sdb3 8:19 0 512B 0 part
`-sdb5 8:21 0 1000M 0 part
sdc 8:32 0 5G 0 disk
|-sdc1 8:33 0 500M 0 part
`-sdc2 8:34 0 300M 0 part
sr0 11:0 1 10.2G 0 rom
[root@SYL3 ~]#
mkfs
命令格式化磁盘,创建文件系统格式化sdb1的空间
[root@SYL3 ~]# mkfs.ext4 /dev/sdb1
mke2fs 1.45.6 (20-Mar-2020)
Creating filesystem with 153600 4k blocks and 38400 inodes
Filesystem UUID: 38b24400-9866-49bd-9237-39f123460fe3
Superblock backups stored on blocks:
32768, 98304
Allocating group tables: done
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
[root@SYL3 ~]#
fstab
配置文件介绍:[root@SYL3 ~]# ls /etc/fstab
/etc/fstab
[root@SYL3 ~]#
[root@localhost ~]# vim /etc/fstab
//分区标识(UUID或设备名) 挂载点 文件类型 挂载参数 不检查 不备份
UUID=e271b5b2-b1ba-4b18-bde5-66e394fb02d9 /db1 xfs defaults 0 0
//挂载参数, 可写fstab配置文件, 也可以mount时使用-o参数指定
参数 参数意义 系统默认值
async 系统每隔一段时间把内存数据写入磁盘中,
sync 时时同步内存和磁盘中数据;
suid,nosuid 允许/不允许分区有suid属性 suid
rw,ro 可以指定文件系统是只读(ro)或可写(rw) rw
exec,noexec 允许/不允许可执行文件执行,不要挂载根分区 exec
user,nouser 允许/不允许root外的其他用户挂载分区 nouser
auto,noauto 开机自动挂载/不自动挂载 auto
default 默认文件系统挂载设置 rw, suid, dev, exec, auto, nouser, async
//加载所有配置
[root@localhost ~]# mount -a
[root@SYL3 ~]# blkid /dev/sdb1
/dev/sdb1: UUID="38b24400-9866-49bd-9237-39f123460fe3" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="b99991fc-01"
[root@SYL3 ~]#
[root@SYL3 ~]# vi /etc/fstab
[root@SYL3 ~]# cat /etc/fstab |grep ext4
UUID="38b24400-9866-49bd-9237-39f123460fe3" /media ext4 defaults 00
[root@SYL3 ~]#
[root@SYL3 ~]# mount -a //加载所有配置
[root@SYL3 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 877M 0 877M 0% /dev
tmpfs 896M 0 896M 0% /dev/shm
tmpfs 896M 8.8M 887M 1% /run
tmpfs 896M 0 896M 0% /sys/fs/cgroup
/dev/mapper/rhel-root 17G 2.0G 15G 12% /
/dev/sda1 1014M 212M 803M 21% /boot
tmpfs 180M 0 180M 0% /run/user/0
/dev/sdb1 575M 912K 532M 1% /media
[root@SYL3 ~]#
命令:mount挂载磁盘,实质为文件系统指定访问入口
mount -t //指定文件系统挂载分区,如ext3,ext4, xfs
mount -a //重新读取/etc/fstab配置文件的所有分区
mount -o //指定挂载参数
//fstab被损坏情况下,让只读文件系统可写(正常情况下不使用)
[root@localhost ~]#mount -o rw,remount /
//挂载/dev/sdb1至db1目录
[root@localhost ~]# mkdir /db1
[root@localhost ~]# mount -t xfs /dev/sdb1 /db1
[root@SYL3 ~]# umount UUID="38b24400-9866-49bd-9237-39f123460fe3" //用UUID卸载
[root@SYL3 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 877M 0 877M 0% /dev
tmpfs 896M 0 896M 0% /dev/shm
tmpfs 896M 8.8M 887M 1% /run
tmpfs 896M 0 896M 0% /sys/fs/cgroup
/dev/mapper/rhel-root 17G 2.1G 15G 12% /
/dev/sda1 1014M 212M 803M 21% /boot
tmpfs 180M 0 180M 0% /run/user/0
[root@SYL3 ~]# mount -a
[root@SYL3 ~]# umount /dev/sdb1 //用设备名卸载
[root@SYL3 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 877M 0 877M 0% /dev
tmpfs 896M 0 896M 0% /dev/shm
tmpfs 896M 8.8M 887M 1% /run
tmpfs 896M 0 896M 0% /sys/fs/cgroup
/dev/mapper/rhel-root 17G 2.1G 15G 12% /
/dev/sda1 1014M 212M 803M 21% /boot
tmpfs 180M 0 180M 0% /run/user/0
[root@SYL3 ~]#
umount -lf //强制卸载挂载
//使用站点目录卸载
[root@localhost ~]# umount /db1
//使用设备名卸载/dev/sdb1
[root@localhost ~]# umount /dev/sdb1
//umount不能卸载的情况
[root@localhost db1]# umount /db1
umount: /db1: device is busy.
(In some cases useful info about processes that use
the device is found by lsof(8) or fuser(1)
//如上情况解决办法有两种, 切换至其他目录 或使用'-l'选项强制卸载
[root@localhost db1]# umount -l /db1