centos7服务器环境搭建—服务运行环境(全:cmake,nginx,mysql8,java8,python3...)

安装gcc
yum install -y epel-release
yum install -y centos-release-scl scl-utils-build
yum install -y devtoolset-8-gcc.x86_64 devtoolset-8-gcc-c++.x86_64 devtoolset-8-gcc-plugin-devel.x86_64
ln -sf /opt/rh/devtoolset-8/root/usr/bin/* /usr/bin/
gcc -v  #查看安装版本
安装perl
wget https://www.cpan.org/src/5.0/perl-5.28.0.tar.gz 
tar -xvzf perl-5.28.0.tar.gz
mv perl-5.28.0 /usr/local/perl
./Configure -des -Dprefix=/usr/local/perl   #检查编译,检查编译将在perl目录下生成Makefile文件
make && make install    #编译&安装
perl -version  #查看安装版本
#安装完清理临时的安装文件
make clean

centos7服务器环境搭建—服务运行环境(全:cmake,nginx,mysql8,java8,python3...)_第1张图片

安装openssl
openssl verison  #默认安装了,需要升级
wget https://www.openssl.org/source/openssl-1.1.1i.tar.gz
tar -xvzf openssl-1.1.1i.tar.gz
cd openssl-1.1.1i
./config shared --prefix=/usr/local/openssl --openssldir=/usr/local/openssl   #openssl源码中提供的config命令默认没有生成 .so,解决办法执行 ./config 时增加参数 shared
make && make install
make clean

which openssl           #查看旧版本openssl命令在哪里
ln -sf /usr/local/openssl/bin/openssl /usr/bin/openssl  #软链接
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf
ldconfig

centos7服务器环境搭建—服务运行环境(全:cmake,nginx,mysql8,java8,python3...)_第2张图片
在这里插入图片描述

安装pcre-deve
yum -y install pcre-devel

centos7服务器环境搭建—服务运行环境(全:cmake,nginx,mysql8,java8,python3...)_第3张图片

安装nginx

先安装zlib zlib-devel

yum install zlib zlib-devel

centos7服务器环境搭建—服务运行环境(全:cmake,nginx,mysql8,java8,python3...)_第4张图片
安装nginx

wget  http://nginx.org/download/nginx-1.18.0.tar.gz
tar -xvzf nginx-1.18.0.tar.gz
cd nginx-1.18.0
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-openssl=/usr/local/openssl
make && make install

编译安装时给了个惊喜,报了错: [/usr/local/openssl/.openssl/include/openssl/ssl.h] 错误 127
centos7服务器环境搭建—服务运行环境(全:cmake,nginx,mysql8,java8,python3...)_第5张图片
根据报错信息我们知道,出错是因为Nginx在编译时并不能在/usr/local/openssl/.openssl/这个目录找到对应的文件,其实我们打开/usr/local/openssl/这个目录可以发现这个目录下是没有.openssl目录的,因此我们修改Nginx编译时对openssl的路径选择就可以解决这个问题了。
解决方案:
打开nginx源文件下的nginx-1.18.0/auto/lib/openssl/conf文件,把路径中的.openssl/去掉,保存文件,然后重新编译安装即可。
centos7服务器环境搭建—服务运行环境(全:cmake,nginx,mysql8,java8,python3...)_第6张图片

安装cmake
tar zxvf cmake-3.19.7-Linux-x86_64.tar.gz 
cd cmake-3.19.7-Linux-x86_64/  #解压即可用
vim ~/.bashrc  #添加配置
#cmake
export cmake=/usr/local/cmake-3.19.7-Linux-x86_64
export PATH=$cmake/bin:$PATH
source ~/.bashrc
cmake --verison

centos7服务器环境搭建—服务运行环境(全:cmake,nginx,mysql8,java8,python3...)_第7张图片

安装patchelf
# 先提前安装
yum install -y autoconf libtool automake
tar zxvf patchelf-0.12.tar.gz
cd patchelf-0.12
./bootstrap.sh
./configure
make && make install
patchelf --version
cmake编译安装mysql8

1、卸载mariadb ,这个是centos集成的伪mysql,一般初始都带这个家伙,现在要装mysql必须把它干掉,同理如果你之前曾经安装过mysql,也要进行卸载。

rpm -qa | grep mariadb
rpm -e --nodeps mariadb-libs-5.5.56-2.el7.x86_64

centos7服务器环境搭建—服务运行环境(全:cmake,nginx,mysql8,java8,python3...)_第8张图片
2、查看是否有mysql依赖,如果有则卸载,没有忽略。

rpm -qa | grep mysql

3、开始mysql安装

tar zxvf mysql-boost-8.0.23.tar.gz
cd mysql-8.0.23

#添加用户组及用户
groupadd mysql
useradd -r -g mysql -s /sbin/nologin mysql

mkdir -p /usr/local/mysql
chown -R mysql.mysql /usr/local/mysql/	
mkdir -p /home/mysql
chown -R mysql.mysql /home/mysql/
chmod -R 755 /usr/local/mysql/
chmod -R 755 /home/mysql/

cmake . \
-DWITH_BOOST=/home/devops/mysql-8.0.23/boost \
-DFORCE_INSOURCE_BUILD=1 \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/home/mysql \
-DDEFAULT_CHARSET=utf8mb4 \
-DWITH_SSL=/usr/local/openssl \
-DDEFAULT_COLLATION=utf8mb4_unicode_ci

执行到cmake又出现惊喜,报以下错误:

CMake Error at cmake/readline.cmake:83 (MESSAGE):
  Curses library not found.  Please install appropriate package,
 
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.

centos7服务器环境搭建—服务运行环境(全:cmake,nginx,mysql8,java8,python3...)_第9张图片
该报错原因是未安装ncurses-devel,解决方式:

#第一步:安装
yum -y install ncurses-devel
#第二步:删除CMakeCache.txt,通过find命令找到所有CMakeCache.txt文档的位置
find / -name CMakeCache.txt
rm -f CMakeCache.txt
#第三步:重新cmake不再出现这个问题
#第四步:开始编译安装
make && make install
#第五步:漫长的等待安装中。。。(一个多小时过去了)

安装好了,开始初始化和配置mysql

#初始化数据库
cd /usr/local/mysql/bin/
./mysqld --initialize-insecure --basedir=/usr/local/mysql --datadir=/home/mysql --user=mysql

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/
chmod a+x /etc/init.d/mysql.server
# 启动
/etc/init.d/mysql.server start

echo "export PATH=/usr/local/mysql/bin:$PATH:/usr/local/bin" >/etc/profile.d/mysql.sh
source /etc/profile.d/mysql.sh
#登录
mysql -uroot -p
#修改新密码
alter user 'root'@'localhost' identified with mysql_native_password BY '密码';
flush privileges;
yum安装Java8
yum install -y java-1.8.0-openjdk.x86_64   --安装jdk
yum install java-1.8.0-openjdk-devel.x86_64  --安装jps
安装python3
#提前安装 
	yum install kernel-headers
	yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel

	#开始安装
	xz -d Python-3.8.0.tar.xz
	tar xvf Python-3.8.0.tar
	cd Python-3.8.0
   	 ./configure --prefix=/usr/local/python3 --with-openssl=/usr/local/openssl
	make && make install
	ln -s  /usr/local/python3/bin/python3.8 /usr/bin/python3
	ln -s  /usr/local/python3/bin/pip3 /usr/bin/pip3
	python3 -V
	pip3 -V

你可能感兴趣的:(mysql,环境搭建,环境搭建,mysql,python,centos,nginx)