11.6 MariaDB安装

准备工作

方法1: 因为MariaDB的二进制包镜像源在国外地址,所以预先下载了该包到本地物理机,使用lrzsz工具将该包上传至虚拟机/usr/local/src目录进行安装。

先安装lrzsz工具: [root@centos-01 src]# yum install -y lrzsz

上传本地包到虚拟终端:

[root@centos-01 ~]# cd /usr/local/src [root@centos-01 src]# ls mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz [root@centos-01 src]# rz

[root@centos-01 src]# ls mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

方法2:

通过百度网盘下载到WIN7系统下,再安装一个XFTP 5 [root@centos-01 ~]# cd /usr/local/src 再点上传图标,把软件传到linux的/usr/local/src下

安装MariaDB

解压包

[root@centos-01 src]# tar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz [root@centos-01 src]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb [root@centos-01 src]# cd /usr/local/mariadb

初始化

[root@centos-01 mariadb]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mariadb

配置MariaDB

[root@centos-01 mariadb]# cp support-files/my-small.cnf /usr/local/mariadb/my.cnf

[root@centos-01 mariadb]# cp support-files/mysql.server /etc/init.d/mariadb

配置启动脚本

[root@centos-01 mariadb]# vim /etc/init.d/mariadb basedir=/usr/local/mariadb datadir=/data/mariadb conf=$basedir/my.cnf

启动mariadb服务

检测mysql服务是否在运行:

[root@centos-01 mariadb]# ps aux |grep mysql root 1326 0.0 0.0 115376 612 ? S 16:42 0:00 /bin/sh /usr/local/mysql/b mysql 1848 0.1 44.9 981244 453044 ? Sl 16:42 0:19 /usr/local/mysql/bin/mysqlysql --log-error=/data/mysql/centos-01.err --pid-file=/data/mysql/centos-01.pid --socket=/t root 2780 0.0 0.0 112664 972 pts/1 R+ 21:48 0:00 grep --color=auto mysql

因mysql和Mariadb监听同一端口,为避免冲突,所以需要先关掉mysql服务:

[root@centos-01 mariadb]# systemctl stop mysql

启动mariadb服务:

[root@centos-01 mariadb]# /etc/init.d/mariadb start Reloading systemd: [ 确定 ] Starting mariadb (via systemctl): [ 确定 ]

注: 如果系统中只安装mysql和mariadb其中一种服务,可以直接把启动脚本放在/etc/文件中设置开机启动。

11.7-11.9 Apache安装

Apache是一个基金会的名字,httpd才是我们要安装的软件包,早期它的名字就叫apache。httpd使用一个通用函数库Apr和apr-util,它让httpd可以不关心底层的操作系统平台,可以很方便地移植(从linux移植到windows)。 Apache官网 www.apache.org 。

httpd2.2和httpd2.4所所使用的Apr库不同,而且centos7系统自带的Apr与之不匹配,所以需要使用yum安装Apr库文件。

准备工作

下载所需要的包

Apache包: [root@centos-01 src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz

Apr包: [root@centos-01 src]# wget http://mirrors.hust.edu.cn/apache/apr/apr-1.6.3.tar.gz

Apr-util包: [root@centos-01 src]# wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.6.1.tar.gz

解压包

[root@centos-01 src]# tar zxvf httpd-2.4.29.tar.gz

[root@centos-01 src]# tar zxvf apr-1.6.3.tar.gz

[root@centos-01 src]# tar zxvf apr-util-1.6.1.tar.gz

安装Apr包

[root@centos-01 src]# cd apr-1.6.3 配置: [root@centos-01 apr-1.6.3]# ./configure --prefix=/usr/local/apr

报错: configure: error: in /usr/local/src/apr-1.6.3': configure: error: no acceptable C compiler found in $PATH Seeconfig.log' for more details 说明:缺少C语言相关的编译器。

解决办法: [root@centos-01 apr-1.6.3]# yum install -y gcc* 安装gcc编译器。

[root@centos-01 apr-1.6.3]# ./configure --prefix=/usr/local/apr 配置成功!

编译和安装:

[root@centos-01 apr-1.6.3]# make && make install [root@centos-01 apr-1.6.3]# echo $? 0完成!

安装Apr-util包

[root@centos-01 src]# cd apr-util-1.6.1 配置: [root@centos-01 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr [root@centos-01 apr-util-1.6.1]# echo $?

编译和安装: [root@centos-01 apr-util-1.5.4]# make && make install

报错:
xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录 #include <expat.h> ^ 编译中断。 make[1]: *** [xml/apr_xml.lo] 错误 1 make[1]: 离开目录“/usr/local/src/apr-util-1.6.0” make: *** [all-recursive] 错误 1 解决办法: [root@adailinux apr-util-1.6.0]# yum -y install expat-devel 完成!

安装httpd

[root@centos-01 src]# cd httpd-2.4.29 配置

[root@centos-01 httpd-2.4.29]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most

报错: configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
说明:需要安装库文件pcre

** 解决办法**: ##查看相关的包 [root@centos-01 httpd-2.4.29]# yum list |grep pcre (结果不展示)

根据搜索的结果安装下面的包: [root@centos-01 httpd-2.4.29]# yum install -y pcre-devel

[root@centos-01 httpd-2.4.29]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most [root@centos-01 httpd-2.4.29]# echo $? 0配置完成! 编译和安装

[root@centos-01 httpd-2.4.29]# make 此过程 时间较长!

[root@centos-01 httpd-2.4.29]# make install [root@centos-01 httpd-2.4.29]# echo $? 0安装完成! 启动服务

切换至Apache2.4目录:

[root@centos-01 httpd-2.4.29]# cd /usr/local/apache2.4 [root@centos-01 apache2.4]# ls bin build cgi-bin conf error htdocs icons include logs man manual modules 注:较常用目录bin(可执行文件存放目录)、conf(配置文件所在目录)、htdocs(存放一个访问页)、logs(日志文件存放目录)、modules(存放扩展模块)。

查看Apache所加载的模块: [root@centos-01 apache2.4]# /usr/local/apache2.4/bin/httpd -M 或者 [root@centos-01 apache2.4]# /usr/local/apache2.4/bin/apachectl -M

启动:

[root@centos-01 apache2.4]# /usr/local/apache2.4/bin/apachectl start AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::65d2:adc:20d3:8c74. Set the 'ServerName' directive globally to suppress this message #此处错误提示没影响。

检测状态: [root@centos-01 apache2.4]# ps aux |grep httpd root 51085 0.0 0.2 95476 2532 ? Ss 04:00 0:00 /usr/local/apache2.4/binhttpd -k start daemon 51086 0.0 0.4 382304 4424 ? Sl 04:00 0:00 /usr/local/apache2.4/binhttpd -k start daemon 51087 0.0 0.4 382304 4428 ? Sl 04:00 0:00 /usr/local/apache2.4/binhttpd -k start daemon 51088 0.1 0.4 382304 4432 ? Sl 04:00 0:00 /usr/local/apache2.4/binhttpd -k start root 51185 0.0 0.0 112668 972 pts/2 S+ 04:02 0:00 grep --color=auto httpd [root@centos-01 apache2.4]# netstat -lntp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 836/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1975/master
tcp6 0 0 :::3306 :::* LISTEN 20596/mysqld
tcp6 0 0 :::80 :::* LISTEN 51085/httpd
tcp6 0 0 :::22 :::* LISTEN 836/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1975/master