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.youkuaiyun.com/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@localhost mariadb]# tar -zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
[root@localhost mariadb]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb
[root@localhost src]# cd ..
[root@localhost local]# ls
apache2 apr apr-util bin etc games include lib lib64 libexec mariadb mysql sbin share src
[root@localhost local]# cd mariadb/
[root@localhost mariadb]# mkdir /data/mariadb
[root@localhost mariadb]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mariadb
[root@localhost mariadb]# echo $?
0
[root@localhost mariadb]# cd support-files/
[root@localhost 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@localhost support-files]# cp my-small.cnf /usr/local/mariadb/my.cnf
[root@localhost axinlinux-01 support-files]# cp mysql.server /etc/init.d/mariadb
[root@localhost support-files]# vim /usr/local/mariadb/my.cnf 需要更改data
[mysqld] 在mysqld里加
datadir = /data/mariadb 加上这一行,定义一下datadir
port = 3306
socket = /tmp/mysql.sock
[root@localhost 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@localhost support-files]# ps aux | grep mariadb
[root@localhost 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@localhost src]#
wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.39.tar.gz
[root@localhost src]#
wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.5.tar.gz
[root@localhost src]#
wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz
[root@localhost src]# tar -zxvf httpd-2.4.39.tar.gz
[root@localhost src]# tar -zxvf apr-1.6.5.tar.gz
[root@localhost src]# tar -zxvf apr-util-1.6.1.tar.gz
准备工作完成
[root@localhost apr-1.6.5]# cd apr-1.6.5/ 首先先安装apr,cd进去
[root@localhost apr-1.6.5]# ./configure --prefix=/usr/local/apr 安装方法就是configure,并指定路径
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
Configuring APR library
Platform: x86_64-pc-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.6.5
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/apr-1.6.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
# See if we are running on zsh, and set the options that allow our
# commands through without removal of \ escapes INIT.
if test -n "\${ZSH_VERSION+set}"; then
setopt NO_GLOB_SUBST
fi
PACKAGE='$PACKAGE'
VERSION='$VERSION'
RM='$RM -f' 修改此处,增加-f
ofile='$ofile'
# Commands run at the beginning of config.status:
APR_SAVE_HEADERS="include/apr.h include/arch/unix/apr_private.h"
APR_MAJOR_VERSION=$APR_MAJOR_VERSION
APR_PLATFORM=$host
for apri in \${APR_SAVE_HEADERS}; do
test -r \${apri} && mv \${apri} \${apri}.save
done
_ACEOF
上例为出现这个报错时修改配置文件rm: cannot remove 'libtoolT': No such file or directory
config.status: executing default commands
编译成功
setting EXTRA_INCLUDES to ""
configure: creating ./config.status
config.status: creating Makefile
config.status: WARNING: 'Makefile.in' seems to ignore the --datarootdir setting
config.status: creating include/apr.h
config.status: creating build/apr_rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating apr-1-config
config.status: creating apr.pc
config.status: creating test/Makefile
config.status: creating test/internal/Makefile
config.status: creating include/arch/unix/apr_private.h
config.status: executing libtool commands
config.status: executing default commands
config.status: include/apr.h is unchanged
config.status: include/arch/unix/apr_private.h is unchanged
[root@localhost apr-1.6.5]# echo $? 有报错,echo $?一下。没关系的
0
[root@localhost apr-1.6.5]# make && make install
以上apr安装完成
[root@localhost apr-1.6.5]# ls /usr/local/apr 看一下我们安装的apr
bin build-1 include lib
[root@localhost apr-1.6.5]# ls /usr/local/
apr bin etc games include lib lib64 libexec mysql sbin share src
bin build-1 include lib
[root@localhost apr-1.6.5]# cd ../apr-util-1.6.1/ 返回apr-util,准备安装apr-util
[root@localhost apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr 指定他的路径同时,还要指定他所依赖的apr (--with-apr=/usr/local/apr)
[root@localhost 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@localhost apr-util-1.6.1]# yum install -y expat-devel 安装expat-devel库
[root@localhost apr-util-1.6.1]# make && make install 继续安装
Libraries have been installed in:
/usr/local/apr-util/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr-util/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr-util/bin/apu-1-config
[root@localhost 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@localhost src]# cd httpd-2.4.39 开始安装httpd
[root@localhost 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 指定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@localhost httpd-2.4.39]# echo $? 以上报错,缺少pcre库。一般是缺少什么什么库
1 非0即错
[root@localhost httpd-2.4.39]# yum install -y pcre-devel 安装该库
[root@localhost 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 继续安装
config.status: creating docs/conf/extra/httpd-languages.conf
config.status: creating docs/conf/extra/httpd-manual.conf
config.status: creating docs/conf/extra/httpd-mpm.conf
config.status: creating docs/conf/extra/httpd-multilang-errordoc.conf
config.status: creating docs/conf/extra/httpd-ssl.conf
config.status: creating docs/conf/extra/httpd-userdir.conf
config.status: creating docs/conf/extra/httpd-vhosts.conf
config.status: creating docs/conf/extra/proxy-html.conf
config.status: creating include/ap_config_layout.h
config.status: creating support/apxs
config.status: creating support/apachectl
config.status: creating support/dbmmanage
config.status: creating support/envvars-std
config.status: creating support/log_server_status
config.status: creating support/logresolve.pl
config.status: creating support/phf_abuse_log.cgi
config.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:
Server Version: 2.4.39
Install prefix: /usr/local/apache2.4
C compiler: gcc -std=gnu99
CFLAGS: -g -O2 -pthread
CPPFLAGS: -DLINUX -D_REENTRANT -D_GNU_SOURCE
LDFLAGS:
LIBS:
C preprocessor: gcc -E
[root@localhost httpd-2.4.39]# echo $?
0
[root@localhost httpd-2.4.39]# make && make install 报错,安装了libxml2.devel
以上httpd安装完成
Installing configuration files
mkdir /usr/local/apache2.4/conf
mkdir /usr/local/apache2.4/conf/extra
mkdir /usr/local/apache2.4/conf/original
mkdir /usr/local/apache2.4/conf/original/extra
Installing HTML documents
mkdir /usr/local/apache2.4/htdocs
Installing error documents
mkdir /usr/local/apache2.4/error
Installing icons
mkdir /usr/local/apache2.4/icons
mkdir /usr/local/apache2.4/logs
Installing CGIs
mkdir /usr/local/apache2.4/cgi-bin
Installing header files
mkdir /usr/local/apache2.4/include
Installing build system files
mkdir /usr/local/apache2.4/build
Installing man pages and online manual
mkdir /usr/local/apache2.4/man
mkdir /usr/local/apache2.4/man/man1
mkdir /usr/local/apache2.4/man/man8
mkdir /usr/local/apache2.4/manual
make[1]: 离开目录“/usr/local/src/httpd-2.4.39”
[root@localhost httpd-2.4.39]# ls /usr/local/apache2.4/
bin build cgi-bin conf error htdocs icons include logs man manual modules
[root@localhost httpd-2.4.39]# /usr/local/apache2.4/bin/apachectl -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::1. Set the 'ServerName' directive globally to suppress this message
Loaded Modules:
core_module (static)
so_module (static)
http_module (static)
mpm_event_module (static)
authn_file_module (shared)
authn_core_module (shared)
authz_host_module (shared)
authz_groupfile_module (shared)
authz_user_module (shared)
authz_core_module (shared)
access_compat_module (shared)
auth_basic_module (shared)
reqtimeout_module (shared)
filter_module (shared)
mime_module (shared)
log_config_module (shared)
env_module (shared)
headers_module (shared)
setenvif_module (shared)
version_module (shared)
unixd_module (shared)
status_module (shared)
autoindex_module (shared)
dir_module (shared)
alias_module (shared)