自学内容网 自学内容网

Linux的软件安装

一、Mysql的在线与离线安装

进入Mysql的官网按照下图步骤可以看到安装的方式:MySQL

1.1、在线安装

yum list | grep "^mysql"

        

在上图中选择自己想要的版本进行下载即可(这里推荐mysql-server.x86_64 ),安装好后需要看看自己Linux上有没有依赖,没有的话需要在Mysql官网下载

1.2、离线安装

按照下图的步骤进行rpm包的下载

安装好后传输到Linux中

mkdir /MySQL  # 这里可以是任何
tar xf mysql-8.0.36-1.el8.x86_64.rpm-bundle.tar -C /MySQL/
ll /MySQL/

dnf install mysql-community-server-8.0.36-1.el8.x86_64.rpm

这里是缺少了其他的依赖(按照提示把所缺少的都下载),可以通过dnf install *.rpm全部下载

dnf install mysql-community-server-8.0.36-1.el8.x86_64.rpm mysql-community-client-8.0.36-1.el8.x86_64.rpm mysql-community-common-8.0.36-1.el8.x86_64.rpm mysql-community-icu-data-files-8.0.36-1.el8.x86_64.rpm mysql-community-libs-8.0.36-1.el8.x86_64.rpm mysql-community-client-plugins-8.0.36-1.el8.x86_64.rpm

1.3、验证安装

systemctl enable --now mysqld  # 注意这个后面有个d
systemctl status mysqld
netstat -lnupt | grep 3306  # 通过查看mysql的端口3306验证是否开启服务

md5sum mysql-8.0.36-1.el8.x86_64.rpm-bundle.tar  # 离线安装的rpm包可以通过md5去进行验证完整性

1.4、配置使用

mysql  # 需要密码,密码在官方的日志文件里面
grep -i password /var/log/mysqld.log
mysql -uroot -p:n#dhlkgg2rI  # 这里-p后面的密码看你日志的最后部分

但在上图发现用临时的密码无法进行操作,按照提示进行密码修改即可(密码有复杂度要求)

配置免密登录Mysql,在/etc/my.conf文件中添加3~5的内容,然后直接通过mysql命令进入

# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html
[client]
user=root
password=MySQL@123

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
# default-authentication-plugin=mysql_native_password

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

二、Mysql的二进制安装

wget -c https://mirrors.aliyun.com/mysql/MySQL-8.0/mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz  # 获取二进制压缩包
 
groupadd -g 27 -r mysql
useradd -u 27 -g 27 -c 'MySQL Server' -r -s /sbin/nologin mysql

tar xf mysql-8.0.28-linux-glibc2.12-x86_64.tar.xz -C /usr/local/
ln -sv /usr/local/mysql-8.0.28-linux-glibc2.12-x86_64/ /usr/local/mysql
cd /usr/local/mysql
mkdir mysql-files
chown mysql:mysql mysql-files
chmod 750 mysql-files
bin/mysqld --initialize --user=mysql
bin/mysql_ssl_rsa_setup
bin/mysqld_safe --user=mysql &

vi /etc/profile.d/mysql.sh
export PATH=$PATH:/usr/local/mysql/bin/

source /etc/profile.d/mysql.sh
yum install ncurses-compat-libs


grep -i password /var/log/mysql/mysqld.log  # 临时的位置在末尾
mysql -uroot -p'nnr765aXFa)p'
alter user root@localhost identified by 'MySQL@123';


mysqladmin -uroot -p'MySQL@123' shutdown
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld


# cat /etc/my.cnf
basedir=/usr/local/mysql/
datadir=/usr/local/mysql/data/
socket=/tmp/mysql.sock

log-error=/usr/local/mysql/data/mysqld.log
pid-file=/usr/local/mysql/data/mysqld.pid

三、httpd的源码编译安装

httpd官网:Welcome! - The Apache HTTP Server Project

tar xfj httpd-2.4.62.tar.bz2 -C /usr/src/
cd /usr/src/
ls
rpm -e httpd --nodeps  # 这个不能跟httpd同时运行,最好是删除
yum -y install apr apr-devel cyrus-sasl-devel expat-devel libdb-devel openldap-devel apr-util-devel apr-util pcre-devel pcre gcc make  # 下载依赖

如果出现了一下错误就运行 yum clean packages (清理yum的缓存中的所有软件包文件)

依赖下好的样子

#进入到/etc/src/httpd-2.4.62/目录下
cd /usr/src/httpd-2.4.62/
./configure --prefix=/usr/local/httpd --enable-so  --enable-rewrite  --enable-charset-lite  --enable-cgi
make
make install
echo "export PATH=$PATH:/usr/local/apache2/bin" > /etc/profile.d/httpd.sh
source /etc/profile.d/httpd.sh
vi /etc/systemd/system/httpd.service
systemctl daemon-reload
systemctl start httpd
systemctl status httpd
systemctl stop firewalld.service  


# cat /etc/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target
 
[Service]
Type=forking
ExecStart=/usr/local/apache2/bin/apachectl start
ExecStop=/usr/local/apache2/bin/apachectl stop
ExecReload=/usr/local/apache2/bin/apachectl graceful
 
[Install]
WantedBy=multi-user.target

这里想要了解每部分作用的可以参考:Linux:http服务(Apache 2.4.57)源码编译——配置网站 || 入门到入土_apache 源码-CSDN博客

但执行make出现爆红时可以执行补救命令(检查一下依赖下好没有)

yum install redhat-rpm-config
yum groupinstall "Development Tools"
./configure


原文地址:https://blog.csdn.net/2302_77625887/article/details/145232801

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!