dongfangho 发表于 2018-11-18 06:34:14

MariaDB和 Apache安装

11.6 MariaDB安装
准备工作
  方法1:
因为MariaDB的二进制包镜像源在国外地址,所以预先下载了该包到本地物理机,使用lrzsz工具将该包上传至虚拟机/usr/local/src目录进行安装。
  先安装lrzsz工具:
# yum install -y lrzsz
  上传本地包到虚拟终端:
  # cd /usr/local/src
# ls
mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
# rz
  # ls
mariadb-10.2.6-linux-glibc_214-x86_64.tar.gzmysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
  方法2:
  通过百度网盘下载到WIN7系统下,再安装一个XFTP 5
# cd /usr/local/src
再点上传图标,把软件传到linux的/usr/local/src下

安装MariaDB
  解压包:
  # tar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb
# cd /usr/local/mariadb
  初始化:
  # ./scripts/mysql_install_db --user=mysql --datadir=/data/mariadb
  配置MariaDB
  # cp support-files/my-small.cnf /usr/local/mariadb/my.cnf
  # cp support-files/mysql.server /etc/init.d/mariadb
  配置启动脚本:
  # vim /etc/init.d/mariadb
basedir=/usr/local/mariadb
datadir=/data/mariadb
conf=$basedir/my.cnf
启动mariadb服务
  检测mysql服务是否在运行:
  # ps aux |grep mysql
root      13260.00.0 115376   612 ?      S    16:42   0:00 /bin/sh /usr/local/mysql/b
mysql   18480.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      27800.00.0 112664   972 pts/1    R+   21:48   0:00 grep --color=auto mysql
  因mysql和Mariadb监听同一端口,为避免冲突,所以需要先关掉mysql服务:
  # systemctl stop mysql
  启动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包:
#wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz
  Apr包:
#wget http://mirrors.hust.edu.cn/apache/apr/apr-1.6.3.tar.gz
  Apr-util包:
#wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
  解压包
  # tar zxvf httpd-2.4.29.tar.gz
  # tar zxvf apr-1.6.3.tar.gz
  # tar zxvf apr-util-1.6.1.tar.gz
安装Apr包
  # cd 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 $PATHSeeconfig.log' for more details
说明:缺少C语言相关的编译器。
  解决办法:
# yum install -y gcc*
安装gcc编译器。
  # ./configure --prefix=/usr/local/apr
配置成功!
  编译和安装:
  # make && make install
# echo $?
0
完成!
安装Apr-util包
  # cd apr-util-1.6.1
配置:
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# echo $?
0
  编译和安装:
# make && make install
  报错:
xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录
#include
^
编译中断。
make: 错误 1
make: 离开目录“/usr/local/src/apr-util-1.6.0”
make: 错误 1
解决办法:
# yum -y install expat-devel
完成!
安装httpd
  # cd 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
  解决办法:
##查看相关的包
# yum list |grep pcre
(结果不展示)
  根据搜索的结果安装下面的包:
# yum install -y pcre-devel
  # ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
# echo $?
0
配置完成!
编译和安装
  # make
此过程 时间较长!
  # make install
# echo $?
0
安装完成!
启动服务
  切换至Apache2.4目录:
  # cd /usr/local/apache2.4
# ls
binbuildcgi-binconferrorhtdocsiconsincludelogsmanmanualmodules
注:较常用目录bin(可执行文件存放目录)、conf(配置文件所在目录)、htdocs(存放一个访问页)、logs(日志文件存放目录)、modules(存放扩展模块)。
  查看Apache所加载的模块:
# /usr/local/apache2.4/bin/httpd -M
或者
# /usr/local/apache2.4/bin/apachectl -M
  启动:
  # /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
#此处错误提示没影响。
  检测状态:
# ps aux |grep httpd
root   510850.00.2954762532 ?      Ss   04:00   0:00 /usr/local/apache2.4/binhttpd -k start
daemon   510860.00.4 3823044424 ?      Sl   04:00   0:00 /usr/local/apache2.4/binhttpd -k start
daemon   510870.00.4 3823044428 ?      Sl   04:00   0:00 /usr/local/apache2.4/binhttpd -k start
daemon   510880.10.4 3823044432 ?      Sl   04:00   0:00 /usr/local/apache2.4/binhttpd -k start
root   511850.00.0 112668   972 pts/2    S+   04:02   0:00 grep --color=auto httpd
# 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



页: [1]
查看完整版本: MariaDB和 Apache安装