41°

38.Maria安装 Apache安装

11.6 MariaDB安装

11.7/11.8/11.9 Apache安装

扩展

apache dso https://yq.aliyun.com/articles/6298

apache apxs http://man.chinaunix.net/newsoft/ApacheMenual_CN_2.2new/programs/apxs.html

apache工作模式 https://blog.csdn.net/STFPHP/article/details/52954303

 

 

 

11.6 MariaDB安装:

 

基本类似于MySQL,一样使用二进制的免编译包

cd /usr/local/src

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

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 --basedir=/usr/local/mariadb/ --datadir=/data/mariadb

cp support-files/my-small.cnf /usr/local/mariadb/my.cnf 拷贝最小的配置文件模板就可以,如果内存够大可以拷贝最大的huge

vi /usr/local/mariadb/my.cnf //定义basedir和datadir

cp support-files/mysql.conf /usr/local/mariadb/my.cnf 拷贝配置文件模板

vim /usr/local/mariadb/my.cnf 定义datadir = /data/mariadb

cp support-files/mysql.server /etc/init.d/mariadb 拷贝运行脚本

vim /etc/init.d/mariadb //定义basedir、datadir、conf以及启动参数

/etc/init.d/mariadb start

 

 

 

实例:

[root@axinlinux-01 mariadb]# tar -zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz

[root@axinlinux-01 mariadb]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb

[root@axinlinux-01 src]# cd ..

[root@axinlinux-01 local]# ls

apache2 apr apr-util bin etc games include lib lib64 libexec mariadb mysql sbin share src

[root@axinlinux-01 local]# cd mariadb/

[root@axinlinux-01 mariadb]# mkdir /data/mariadb

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

[root@axinlinux-01 mariadb]# echo $?

0

[root@axinlinux-01 mariadb]# cd support-files/

[root@axinlinux-01 support-files]# ls

binary-configure my-huge.cnf my-large.cnf my-small.cnf mysql-log-rotate policy wsrep_notify

magic my-innodb-heavy-4G.cnf my-medium.cnf mysqld_multi.server mysql.server wsrep.cnf

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

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

[root@axinlinux-01 support-files]# vim /usr/local/mariadb/my.cnf 需要更改data

[mysqld] 在mysqld里加

datadir = /data/mariadb 加上这一行,定义一下datadir

port = 3306

socket = /tmp/mysql.sock

 

[root@axinlinux-01 support-files]# vim //etc/init.d/mariadb 需要改启动脚本

basedir=/usr/local/mariadb

datadir=/data/mariadb

conf=$basedir/my.cnf

可以搜一下srart.修改启动命令参数

'start')

# Start daemon

 

# Safeguard (relative paths, core dumps..)

cd $basedir

 

echo $echo_n "Starting MySQL"

if test -x $bindir/mysqld_safe

then

# Give extra arguments to mysqld with the my.cnf file. This script

# may be overwritten at next upgrade.

$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" &

在这一行,前面加上 --defaults-file="$conf"

$bindir/mysqld_safe --defaults-file="$conf" --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" &

[root@axinlinux-01 support-files]# /etc/init.d/mariadb start

Reloading systemd: [ 确定 ]

Starting mariadb (via systemctl):

[ 确定 ]

[root@axinlinux-01 support-files]# ps aux | grep mariadb

[root@axinlinux-01 support-files]# netstat -ltnp

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 997/sshd

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1338/master

tcp6 0 0 :::80 :::* LISTEN 50236/httpd

tcp6 0 0 :::22 :::* LISTEN 997/sshd

tcp6 0 0 ::1:25 :::* LISTEN 1338/master

tcp6 0 0 :::3306 :::* LISTEN 52640/mysqld

----------------------------------------------------------------------------------------------------------------------------------------------------

 

 

11.7/11.8/11.9 Apache安装

 

 

Apache是一个基金会的名字,httpd才是我们要安装的软件包,早期它的名字就叫apache

Apache官网www.apache.org 2.0以后得版本就叫httpd了,现在主流版本是2.4,这次安装的也是2.4

apr和apr-util是一个通用的函数库,它让httpd可以不关心底层的操作系统平台,可以很方便地移植(从linux移植到windows) 2.2和2.4安装不太一样,就是因为apr(依赖的软件)。centos自带的也就是我们yum安装的apr和这个2.4是不一样的并不匹配,不能使用yum安装的apr,所以要编译。要编译这面这两个包(apr和apr-util)

 

2.4源码包:

wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.39.tar.gz

apr:

http://mirrors.cnnic.cn/apache/apr/apr-1.6.5.tar.gz

apr-util:

http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz

 

tar zxvf httpd-2.4.39.tar.gz

tar zxvf apr-util-1.6.1.tar.gz

tar zxvf apr-1.6.5.tar.gz

cd /usr/local/src/apr-1.6.5

./configure --prefix=/usr/local/apr

make && make install

 

cd /usr/local/src/apr-util-1.6.1.

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

make && make install

 

cd /usr/local/src/httpd-2.4.39

./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 \ //这里的反斜杠是脱义字符,加上它我们可以把一行命令写成多行

--prefix=/usr/local/apache2.4 \

--with-apr=/usr/local/apr \

--with-apr-util=/usr/local/apr-util \

--enable-so \ 让他支持动态扩展

--enable-mods-shared=most 指定哪些扩展的模块。为most(绝大多数)

make && make install

 

/usr/local/apache2/bin/apachectl start 命令直接启动。不需要命令脚本

netstat -lntp 默认监听80端口

 

./bin/httpd为核心

./conf/会经常打交道

./htdocs/访问页

./log/日志

ls /usr/local/apache2.4/modules 模块

/usr/local/apache2.4/bin/httpd -M //查看加载的模块

静态(static)表示这个模块被编译进了主脚本里面

动态(shared)表示扩展的模块,是一个文件是可以看到的

 

 

实例:

[root@axinlinux-01 src]# 

 wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.39.tar.gz

[root@axinlinux-01 src]#

wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.5.tar.gz

[root@axinlinux-01 src]#

wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz

 

[root@axinlinux-01 src]# tar -zxvf httpd-2.4.39.tar.gz

[root@axinlinux-01 src]# tar -zxvf apr-1.6.5.tar.gz

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

准备工作完成

[root@axinlinux-01 apr-1.6.5]# cd apr-1.6.5/ 首先先安装apr,cd进去

[root@axinlinux-01 apr-1.6.5]# ./configure --prefix=/usr/local/apr 安装方法就是configure,并指定路径

[root@axinlinux-01 apr-1.6.5]# echo $? 有报错,echo $?一下。没关系的

0

[root@axinlinux-01 apr-1.6.5]# make && make install

以上apr安装完成

[root@axinlinux-01 apr-1.6.5]# ls /usr/local/apr 看一下我们安装的apr

[root@localhost apr-1.6.5]#  ls /usr/local/
ap  apr  bin  etc  games  include  lib  lib64  libexec  mysql  sbin  share  src

bin build-1 include lib

[root@axinlinux-01 apr-1.6.5]# cd ../apr-util-1.6.1/ 返回apr-util,准备安装apr-util

[root@axinlinux-01 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr 指定他的路径同时,还要指定他所依赖的apr (--with-apr=/usr/local/apr)

[root@axinlinux-01 apr-util-1.6.1]# make && make install 阿鑫到这有报错

xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录 果断百度一下。缺少 expat库。yum install -y expat-devel

#include <expat.h>

^

编译中断。

make[1]: *** [xml/apr_xml.lo] 错误 1

make[1]: 离开目录“/usr/local/src/apr-util-1.6.1”

make: *** [all-recursive] 错误 1

[root@axinlinux-01 apr-util-1.6.1]# yum install -y expat-devel 安装expat-devel库

[root@axinlinux-01 apr-util-1.6.1]# make && make install 继续安装

[root@axinlinux-01 apr-util-1.6.1]# ls /usr/local/apr-util/

[root@localhost apr-util-1.6.1]# ls /usr/local/apr-util/
bin  include  lib

以上apr-util安装完成

[root@axinlinux-01 src]# cd httpd-2.4.34 开始安装httpd

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

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

[root@axinlinux-01 httpd-2.4.34]# echo $? 以上报错,缺少pcre库。一般是缺少什么什么库

1 非0即错

[root@axinlinux-01 httpd-2.4.34]# yum install -y pcre-devel 安装该库

[root@axinlinux-01 httpd-2.4.34]# ./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@axinlinux-01 httpd-2.4.34]# echo $?

0

[root@axinlinux-01 httpd-2.4.34]# make && make install 报错,安装了libxml2.devel

以上httpd安装完成

ls /usr/local/apache2.4.39/

本文由【oschina130111】发布于开源中国,原文链接:https://my.oschina.net/u/3866192/blog/3072981

全部评论: 0

    我有话说: