九周第五次课

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了九周第五次课相关的知识,希望对你有一定的参考价值。

11.6 MariaDB安装

1、下载mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz二进制源码包

[[email protected] ~]# cd /usr/local/src
[[email protected] ~]# axel --output=mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz https://downloads.mariadb.com/MariaDB/mariadb-10.2.6/bintar-linux-glibc_214-x86_64/mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz

或者使用wget下载

[[email protected] ~]# wget https://downloads.mariadb.com/MariaDB/mariadb-10.2.6/bintar-linux-glibc_214-x86_64/mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz

2、解压缩

[[email protected] ~]# tar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz

3、移动到安装目录

[[email protected] src]# mv mariadb-10.2.12-linux-glibc_214-x86_64 /usr/local/mariadb
[[email protected] src]# cd !$
cd /usr/local/mariadb

4、初始化

[[email protected] src]# mkdir /data/mariadb  //创建数据库存放目录
[[email protected] src]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb/ --datadir=/data/mariadb //初始化
[[email protected] mariadb]# ll /data/mariadb/  //查看初始化目录
total 110620
-rw-rw---- 1 mysql mysql    16384 Mar  2 02:01 aria_log.00000001
-rw-rw---- 1 mysql mysql       52 Mar  2 02:01 aria_log_control
-rw-rw---- 1 mysql mysql     2789 Mar  2 02:01 ib_buffer_pool
-rw-rw---- 1 mysql mysql 12582912 Mar  2 02:01 ibdata1
-rw-rw---- 1 mysql mysql 50331648 Mar  2 02:01 ib_logfile0
-rw-rw---- 1 mysql mysql 50331648 Mar  2 02:01 ib_logfile1
drwx------ 2 mysql root      4096 Mar  2 02:01 mysql
drwx------ 2 mysql mysql       20 Mar  2 02:01 performance_schema
drwx------ 2 mysql root         6 Mar  2 02:01 test

[[email protected] src]# cp support-files/my-small.cnf /usr/local/mariadb/my.cnf //复制配置文件

5、编辑mariadb配置文件

[[email protected] src]# vim /usr/local/mariadb/my.cnf //定义basedir和datadir

---

[mysqld]
basedir=/usr/local/mariadb //basedir定义安装目录
datadir=/data/mariadb //定义数据存储目录

---
[[email protected] src]# cp support-files/mysql.server /etc/init.d/mariadb
[[email protected] src]# vim /etc/init.d/mariadb //定义basedir、datadir、conf以及启动参数

---

basedir=/usr/local/mariadb
datadir=/data/mariadb
conf=$basedir/my.cnf
$bindir/mysqld_safe --defaults-file="$conf" --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "[email protected]" &

---

6、启动mariadb

/etc/init.d/mariadb start

加入自启动

chmod +x /etc/init.d/mariadb
chkconfig --add mariadb
chkconfig mariadb on

11.7/11.8/11.9 Apache安装

1、安装需要的模块

安装axel多线程下载工具

yum -y install axel 

下载需要编译到apache的功能模块

cd /usr/local/src   
axel http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz
axel https://archive.apache.org/dist/apr/apr-1.6.3.tar.bz2
axel https://archive.apache.org/dist/apr/apr-util-1.6.1.tar.bz2
axel http://mirror.bit.edu.cn/apache/apr/apr-iconv-1.2.2.tar.bz2
axel http://ftp.exim.llorien.org/pcre/pcre-8.41.tar.bz2
axel https://ftp.pcre.org/pub/pcre/pcre2-10.31.tar.gz

安装需要使用的编译工具

yum -y install binutils compat-libcap1  compat-libstdc++-33 compat-libstdc++-33*.i686 elfutils-libelf-devel gcc gcc-c++ libc glibc-devel libgcc libstdc++ libstdc++-devel libaio libaio-devel make sysstat unixODBC unixODBC-devel libXp binutils compat-libstdc++ compat-libstdc++-33elfutils-libelf-devel gcc gcc-c++ glibc-devel glibc-headers ksh libaio-devellibstdc++-devel make sysstat unixODBC-devel binutils-* compat-libstdc++* elfutils-libelf* glibc* gcc-* libaio* libgcc* libstdc++* make* sysstat*unixODBC* wget unzip libtool gdbm openssll crypto crypto-utils cryptopp-devel cryptopp expat-devel axel epel-release openssl-*

安装apr模块

tar -jxvf apr-1.6.3.tar.bz2 

cd apr-1.6.3/

./configure --prefix=/usr/local/apr 
make && make install

安装apache时 apr可能报错 rm: cannot remove `libtoolT‘: No such file or directory

解决
在configure里面 RM=‘$RM -f‘ ,把RM=‘$RM‘改为RM=‘$RM -f‘

安装apr-util

tar -jxvf apr-util-1.6.1.tar.bz2

cd apr-util-1.6.1/

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config -with-gdbm --with-openssl --with-commoncrypto
tar -jxvf apr-iconv-1.2.2.tar.bz2
cd apr-iconv-1.2.2/
./configure

tar -jxvf pcre-8.41.tar.bz2

tar -zxf pcre2-10.30.tar.gz 
cd pcre2-10.30/
./configure --prefix=/usr/local/pcre2
make && make install
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 --with-pcre2=/usr/local/pcre2 --sysconfdir=/etc/httpd24 --enable-ssl --enable-cgi --enable-rewrite --with-zlib=/usr/local/zlib.1.2.11 --enable-modules=most --enable-mpms-shared=all --with-mpm=event --enable-headers=shared --with-pcre2=/usr/local/pcre2/bin/pcre2-config

make && make install

遇到的问题:


collect2: error: ld returned 1 exit status
make[1]: *** [httpd] Error 1
make[1]: Leaving directory `/usr/local/src/httpd-2.4.29‘
make: *** [all-recursive] Error 1
[[email protected] httpd-2.4.29]# mv /usr/lib/libm.a /usr/lib/libm.a.bak
mv: cannot stat ‘/usr/lib/libm.a’: No such file or directory

解决方法:

1、下载zlib源码包

wget http://www.zlib.net/zlib-1.2.11.tar.gz
  1. 执行以下相关命令
[[email protected] ~]# tar -zxvf zlib-1.2.3.tar.gz
[[email protected] ~]# cd zlib-1.2.3
[[email protected] ~]# ./configure --prefix=path //path为自定义安装路径
[[email protected] ~]# vim Makefile
 找到 CFLAGS=-O3 -DUSE_MMAP
 在后面加入-fPIC,即变成CFLAGS=-O3 -DUSE_MMAP -fPIC
[[email protected] ~]# make && make install
  1. 安装apache,添加 --with-zlib-1.2.3=zlib-path 参数
[[email protected] ~]#  ./configure --prefix=/usr/local/httpd-2.4.29 --with-zlib-1.2.11=/usr/local/zlib.1.2.11  --enable-so  //把path修改成各自的安装路径即可
vim /etc/httpd24/httpd.conf
#(在AddType application/x-zip .gz .tgz) 下面添加如下一条:
AddType application/x-httpd-php .php .phtml

<IfModule dir_module>
    DirectoryIndex index.php index.html
</IfModule>

DirectoryIndex index.php index.html //此处注意,php文件必须放前面,优先读取
apachectl -t   //检查配置错误

解决httpd: Could not reliably determine the server‘s fully qualified domain name

vim /etc/httpd/conf/httpd.conf   
加入一句  ServerName  localhost:80

apachectl graceful //加载配置,不重启服务

/usr/local/apache/bin/apachectl start //启动Apache

添加自启动

cp /usr/local/apache2.4/bin/apachectl /etc/init.d/httpd
vim /etc/init.d/httpd
在第一行#!/bin/sh下增加两行文字
# chkconfig: 35 70 30
# description: Apache
chmod +x /etc/init.d/httpd
chkconfig --add httpd
chkconfig httpd on

防火墙允许http

firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-all

扩展

apache dso https://yq.aliyun.com/articles/6298
apache apxs http://man.chinaunix.net/newsoft/ApacheMenual_CN_2.2new/programs/apxs.html
apache工作模式 http://www.cnblogs.com/fnng/archive/2012/11/20/2779977.html

以上是关于九周第五次课的主要内容,如果未能解决你的问题,请参考以下文章

一周第五次课(12月15日)

一周第五次课(12月15日)

一周第五次课(12月15日)

六周第五次课(1月19日)

二周第五次课(12月22日)

五周第五次课(1月12日)