在 centOS9 上配置 web 环境依赖软件包
当前 centos 版本与 redhat 对应的版本的命令 | |
适用于 RedHat、CentOS | |
适用于所有的 linux,包括Redhat、SuSE、Debian、Centos等 | |
此命令适用于所有的 Linux 分发版,包括 RedHat、SUSE、Debian…等分发版。 在默认情况下,Linux 中是不带 lsb_release 命令的,安装命令 dnf -y install redhat-lsb 。LSB是Linux Standard Base的缩写,用来显示 LSB 和特定版本的相关信息。如果使用该命令时不带参数,则默认加上-v 参数。 |
对于新的 centOS 服务器,根据实际情况,需要升级软件包的,进行下面操作。
# 只升级所有包,不升级软件和系统内核dnf -y upgrade
安装工具包
cd /tmpdnf -y install vimdnf -y install wgetdnf -y install zip unzipdnf -y install tree
安装常规软件包
配置 PHP、MySQL、Nginx 环境,需要很多依赖包。下面一次性安装上这些依赖包。
#!/bin/bash myum() { if ! rpm -qa|grep -q "^$1" then dnf install -y $1 check_ok else echo $1 already installed. fi } check_ok() { if [ $? != 0 ] then echo "Error, Check the error log." fi } for p in gcc gcc-c++ cmake make autoconf automake boost boost-devel boost-doc oniguruma bison bison-devel e2fsprogs e2fsprogs-devel lynx pcre pcre-devel perl-CPAN openssl openssl-devel openssh-server zlib zlib-devel nghttp2 libnghttp2-devel expat-devel file flex perl perl-Data-Dumper perl-devel crontabs libjpeg libjpeg-devel libpng libpng-devel openjpeg-devel python-devel python-imaging l gd gd-devel gettext gettext-devel git-core libwebp-devel gmp gmp-devel bzip2-devel libxml2 libxml2-devel curl curl-devel libcurl libcurl-devel libmcrypt libmcrypt-devel libicu libicu-devel libgcrypt libtool libaio libaio-devel libtirpc libtirpc-level mcrypt mhash jemalloc-devel python-devel freetype freetype-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel krb5-devel libidn libidn-devel nss_ldap libev-devel libevent libevent-devel libxslt libxslt-devel readline readline-devel rpcgen krb5 krb5-devel openldap openldap-devel openldap-clients openldap-servers icu sqlite sqlite-devel;do myum $p;done
复制上面内容,粘贴到mysoftware.sh文件中,然后保存退出,运行。如此依赖的软件包基本都能安装上了。
cd /tmpvim mysoftware.shsh mysoftware.sh
dnf info apr # Version: 1.7.0dnf info apr-util # Version: 1.6.1dnf info cmake # Version: 3.20.2dnf info gcc # Version: 11.3.1
经过查询php、mysql、Nginx依赖的组件(cmake、apr、apr-util)都符合要求。
centOS 中目录含义
bin
:所有用户,皆可用的可执行程序目录。sbin
:超级用户,才能使用的可执行程序目录。
/bin
:所有用户,皆可用的,系统程序。/sbin
:超级用户,才能用的,系统程序。
/usr/bin
:所有用户,都可用的,系统安装的应用程序,会随着系统升级而改变。/usr/sbin
:超级用户,才能用的,系统安装的应用程序,会随着系统升级而改变。
/usr/local/bin
:所有用户,都可用的,用户安装的应用程序,不会被系统升级而覆盖同名文件。/usr/local/sbin
:超级用户,才能用的,用户安装的应用程序,不会被系统升级而覆盖同名文件。