MariaDB和Apache安装

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

 

安装mariadb

  • 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
  • vi /usr/local/mariadb/my.cnf //定义basedir和datadir
  • cp support-files/mysql.server /etc/init.d/mariadb
  • vim /etc/init.d/mariadb //定义basedir、datadir、conf以及启动参数
  • /etc/init.d/mariadb start

安装过程

  • mariadb和mysql安装过程相似
  • 首先切换到/usr/local/src目录下
[root@hf-01 ~]# cd /usr/local/src
[root@hf-01 src]#
[root@yong-01 src]# ls mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz 
mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
  • 再使用 tar命令 进行解压
[root@yong-01 src]# tar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
  • 解压完,会生成mariadb-10.2.6-linux-glibc_214-x86_64这个目录,将解压的包移动到/usr/local下,并更名叫mariadb——>这里的更名,是为了以前安装mysql的名字有所区分
[root@yong-01 src]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb
  • 而后进入到/usr/local/mariadb 目录下去
[root@yong-01 src]# cd /usr/local/mariadb/
[root@yong-01 mariadb]# ls
bin                 docs               mariadb-10.2.6-linux-glibc_214-x86_64  share
COPYING             EXCEPTIONS-CLIENT  my.cnf                                 sql-bench
COPYING.thirdparty  include            mysql-test                             support-files
CREDITS             INSTALL-BINARY     README.md
data                lib                README-wsrep
DESTINATION         man                scripts
  • 建立mysql用户和建立data,已经有了就不用建立这个用户,
  • 初始化,./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb/ --datadir=/data/mariadb
    • 定义basedir=/usr/local/mariadb/ 若不定义 ,就会去找mysql了
[root@yong-01 mariadb]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb/ --datadir=/data/mariadb
  • 查看是否初始化成功,看 echo $? 执行结果是否为0,如果 0 ,则表示初始化成功
[root@yong-01 mariadb]# echo $?
0
  • 或者查看/data/mariadb/目录下,是否生成了一些目录——>和/data/mysql/ 相似
[root@yong-01 mariadb]# ls /data/mariadb/
aria_log.00000001  ib_buffer_pool  ib_logfile0  mysql               test
aria_log_control   ibdata1         ib_logfile1  performance_schema
  • 拷贝配置文件,定义启动脚本
    • 配置文件存放在/usr/local/mariadb/suport/files/目录下,会看到有不少配置文件
[root@yong-01 mariadb]# cd /usr/local/mariadb/
[root@yong-01 mariadb]# ls support-files/
binary-configure  my-innodb-heavy-4G.cnf  my-small.cnf         mysql.server  wsrep_notify
magic             my-large.cnf            mysqld_multi.server  policy
my-huge.cnf       my-medium.cnf           mysql-log-rotate     wsrep.cnf
  • 打开support-files/my-small.cnf 文件
  • my-small.cnf、my-medium.cnf、my-large.cnf这三个配置文件区别在于 缓存的数值大小不一样
  • 根据内存大小的不一样,它能够给你指定合适的缓存,这样可以让你的mysql达到更高效的性能
[root@hf-01 mariadb]# vim support-files/my-small.cnf

其中下面的配置文件
[mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 240K
  • 由于咱们作实验,内存原本就不大,可使用最小的一个my-small.cnf ,拷贝过去
  • 如果内存有几十个G,可使用my-huge.cnf拷贝过去,而后根据实际的运行状况 ,去适当的调整参数
  • 拷贝文件到/usr/local/mariadb/my.cnf
  • mariadb这里就不放到/etc/my.cnf下了,由于这是mysql用的,这里为了区分到/usr/local/mariadb/my.cnf
[root@yong-01 mariadb]# cp support-files/my-small.cnf /usr/local/mariadb/my.cnf
cp:是否覆盖"/usr/local/mariadb/my.cnf"? y
  • 编辑配置文件 /usr/local/mariadb/my.cnf——>这里面配置不用修改
[root@hf-01 mariadb]# vim /usr/local/mariadb/my.cnf

配置参数在[mysqld]这一块

server-id       = 1   //这是作主从复制的
  • 拷贝启动脚本到 /etc/init.d/mariadb
[root@hf-01 mariadb]# cp support-files/mysql.server /etc/init.d/mariadb
[root@hf-01 mariadb]#
  • 编辑启动脚本
[root@yong-01 mariadb]# vim /etc/init.d/mariadb

定义 basedir=/usr/local/mariadb
定义 datadir=/data/mariadb
自定义参数 conf=$basedir/my.cnf

在定义conf后,还须要在 启动命令下面指定下——>在通常模式下,搜索 /start 启动命令
在 $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" "$@" &

并保存退出
  • 在启动前,先查看是否有mysql服务在启动,若是启动须要关闭它
[root@yong-01 mariadb]# ps aux |grep mysql
root      3190  0.0  0.0 112676   984 pts/1    R+   22:14   0:00 grep --color=auto mysql
  • 启动mariadb服务,并去查看是否启动
    • 查看是否启动,用ps aux |grep mysql 也能够,启动的服务进程是mysqld,由于mariadb是mysql的一个分支
[root@yong-01 mariadb]# /etc/init.d/mariadb start
Reloading systemd:                                         [  肯定  ]
Starting mariadb (via systemctl):                          [  肯定  ]
[root@yong-01 mariadb]# ps aux |grep mariadb
root      4197  0.0  0.0 115388  1748 ?        S    22:39   0:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir=/data/mysql --pid-file=/data/mysql/yong-01.pid
mysql     4313  1.5  3.0 1125056 57848 ?       Sl   22:39   0:00 /usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/mariadb/my.cnf --basedir=/usr/local/mariadb --datadir=/data/mysql --plugin-dir=/usr/local/mariadb/lib/plugin --user=mysql --log-error=/data/mysql/yong-01.err --pid-file=/data/mysql/yong-01.pid --socket=/tmp/mysql.sock --port=3306
root      4349  0.0  0.0 112676   980 pts/1    R+   22:39   0:00 grep --color=auto mariadb
[root@yong-01 mariadb]# 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      1124/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1467/master         
tcp6       0      0 :::22                   :::*                    LISTEN      1124/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1467/master         
tcp6       0      0 :::3306                 :::*                    LISTEN      4747/mysqld
  • 如果在服务器上只安装了mariadb,没有mysql,那彻底能够把my.cnf放在/etc目录下,那启动脚本就不须要conf变量了

机器装了mysql和mariadb

  • 一台机器上装了mysql,又装了mariadb (这种既装了mysql和mariadb的几率很低),由于有多个配置文件在/etc/my.cnf,不管是在初始化的时候,仍是启动多个mysql服务的时候,它都会影响正常的结果,因此要么不把 my.cnf 放在etc目录下,一旦放了,颇有可能受到影响。
  • 问题:
  • 用ps aux |grep mysql会发现其中的--datadir=/data/mysql,并非咱们预期的--datadir=/data/mariadb
  • 这是由于调用了/etc/my.cnf中的配置,有人可能会问,不是已经指定了--defaults-file=/usr/local/mariadb/my.cnf 配置文件,为何还要去加载/etc/my.cnf中的配置呢,是由于--defaults-file=/usr/local/mariadb/my.cnf文件中,并无去定义dataidr 这个选项,而后去调用的时候,没有在配置文件中找到这个参数,而后在/etc/my.cnf中调用
  • 解决方法:
  • 须要去编辑指定的配置文件,在 /usr/local/mariadb/my.cnf 文件中的 [mysqld] 下加入datadir= /data/mariadb (如果datadir加在其余地方是无效的)
  • 固然不是只能拥有一个数据库,只要将各个参数配置完善,一个机器上能够跑多个mysql服务
  • 在修改完配置文件后,启动/etc/init.d/mariadb start (第一次启动mariadb服务)——>如果mariadb服务已经启动了,则/etc/init.d/mariadb restart ,但显示的结果还未正常,那咱们就直接killall mysqld服务,而后再ps aux |grep mysql查看下服务是否杀死
  • 最后再来 /etc/init.d/mariadb restart 开启mariadb服务,会看到显示正常。
[root@yong-01 mariadb]# ps aux |grep mysql
root      4631  0.0  0.0 115388  1740 ?        S    22:40   0:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir=/data/mysql --pid-file=/data/mysql/yong-01.pid
mysql     4747  0.1  3.5 1125056 66980 ?       Sl   22:40   0:00 /usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/mariadb/my.cnf --basedir=/usr/local/mariadb --datadir=/data/mysql --plugin-dir=/usr/local/mariadb/lib/plugin --user=mysql --log-error=/data/mysql/yong-01.err --pid-file=/data/mysql/yong-01.pid --socket=/tmp/mysql.sock --port=3306
root      4830  0.0  0.0 112676   984 pts/1    R+   22:46   0:00 grep --color=auto mysql

 

安装Apache

  • Apache是一个基金会的名字,httpd才是咱们要安装的软件包,早期它的名字就叫apache
  • Apache官网www.apache.org
  • wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.33.tar.gz
  • wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz
  • wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.bz2
  • apr和apr-util是一个通用的函数库,它让httpd能够不关心底层的操做系统平台,能够很方便地移植(从linux移植到windows)
  • tar zxvf httpd-2.4.33.tar.gz
  • tar zxvf apr-util-1.6.1.tar.bz2
  • tar zxvf apr-1.6.3.tar.gz
  • cd /usr/local/src/apr-1.6.3
  • ./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.33
  • ./configure \ //这里的反斜杠是脱义字符,加上它咱们能够把一行命令写成多行 --prefix=/usr/local/apache2.4
    --with-apr=/usr/local/apr 
    --with-apr-util=/usr/local/apr-util 
    --enable-so 
    --enable-mods-shared=most
  • make && make install
  • ls /usr/local/apache2.4/modules
  • /usr/local/apache2.4/bin/httpd -M //查看加载的模块

Apache介绍

  • Apache是一个基金会的名字,它最先就是httpd起家的,由于httpd使用的人不少,很流行,因此当时就以基金会的名字来命名的web服务软件 ,在早期的时候,名字就叫作Apache,而不是叫httpd,后来在http的2.0版本开始,就更名叫httpd,可是不少人仍是习惯叫作Apache
  • Apache的主流版本,在以前是 1.3版本比较流行,后来出了2.0版本,2.2版本,2.4版本,如今主流版本是 2.4版本

Apache(2.4版本)

  • 2.2版本和2.4版本的区别
    • 安装的方法不一样,涉及到一个安依赖软件apr版本不同
  • apr和apr-util是一个通用的函数库,它让httpd能够不关心底层的操做系统平台,能够很方便地进行移植(从linux移植到windows)
  • 2.2版本和2.4版本所依赖的apr版本是不一样的
    • 而centos系统,默认自带的apr,也就是yum安装的apr和2.4版本是不匹配的,因此没法使用yum安装的apr,因此须要本身去手动编译
  • Apache2.4版本编译起来麻烦,就是由于须要手动编译 apr 和 apr-util 这两个包

安装过程

  • 首先切换到/usr/local/src目录下
[root@yong-01 ~]# cd /usr/local/src
  • 下载Apache 2.4源码包、apr、apr-util这三个包
wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.33.tar.gz
wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz
wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.bz2
  • 在下载完成后,查看下下载的包
  • 用tar解压下载的包,并查看
[root@yong-01 src]# tar zxvf httpd-2.4.29.tar.gz

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

[root@yong-01 src]# tar xjvf apr-util-1.6.1.tar.bz2
[root@yong-01 src]# ls
apr-1.6.3         apr-util-1.6.1          httpd-2.4.33         mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz  php-5.6.30
apr-1.6.3.tar.gz  apr-util-1.6.1.tar.bz2  httpd-2.4.33.tar.gz  mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz     php-5.6.30.tar.gz
  • 在解压完成后,首先安装apr
  • 切换到/usr/local/src/apr-1.6.3,并安装apr
[root@yong-01 src]# cd apr-1.6.3
[root@yong-01 apr-1.6.3]# ./configure --prefix=/usr/local/apr
  • 在安装的时候,有时会出现如下状况
  • 只须要安装gcc包便可——>yum install -y gcc
[root@yong-01 apr-1.6.3]# ./configure --prefix=/usr/local/apr
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.3
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.3':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[root@yong-01 apr-1.6.3]# yum install -y gcc
  • 在安装完成后,能够用 echo $? 检查是否安装成功
[root@yong-01 apr-1.6.3]# echo $?
0
  • 执行make && make install 命令
[root@yong-01 apr-1.6.3]# make && make install
  • 查看下apr,会看到有四个目录
[root@yong-01 apr-1.6.3]# ls /usr/local/apr/
bin  build-1  include  lib
  • 安装apr-util-1.6.1,首先切换到/usr/local/src/apr-util-1.6.1目录下
[root@yong-01 apr-1.6.3]# cd /usr/local/src/apr-util-1.6.1
  • 安装apr-util
[root@yong-01 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
  • 而后使用echo $?检查是否安装成功
[root@yong-01 apr-util-1.6.1]# echo $?
0
  • 而后make && make install
[root@yong-01 apr-util-1.6.1]# make && make install
  • 问题
    • 可是在执行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.1”
make: *** [all-recursive] 错误 1
  • 解决方法
    • 是由于缺乏了xml解释器,只须要yum安装 expat-devel 包便可
[root@yong-01 apr-util-1.6.1]# yum -y install expat-devel
  • 这时再去执行make && make install 会正常执行
  1. --enable-so \ 表示支持动态扩展模块,Apache和PHP它们都会支持以一个模块的形式存在
  • PHP是Apache的一个模块,这个模块实际上就是一个文件,就是 .so 后缀名的文件,那他以Apache的一个模块形式存在,因此Apache自己是一个进程,是一个服务,在这个进程里面,经过一些配置文件指定一个模块的路径,那就能够去调用模块。
  • PHP模块是用来解析PHP的,执行PHP脚本的,因此就能够经过PHP脚本将PHP模块加载到进程里面去,加载到主进程里面去,
    • 当它遇到PHP解析的需求时,它就会去调用这个模块,去执行一些操做
    • 这些模块是一些独立的文件
  • 并且还能够指定有哪些动态扩展的模块,须要加载哪些,这里指定是most
    • --enable-mods-shared=most
      • most,就是绝大多数,大多数会用到的模块,都会加载进来
  • 查看/usr/local/apr-util/目录下,会看到生成三个子目录
[root@yong-01 apr-util-1.6.1]# ls /usr/local/apr-util/
bin  include  lib
  • 安装httpd-2.4.33,首先切换到httpd-2.4.33/
[root@yong-01 apr-util-1.6.1]# cd /usr/local/src/httpd-2.4.33/
  • 安装httpd-2.4.33
[root@yong-01 httpd-2.4.33]# ./configure --prefix=/usr/local/apache2 --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 查看,由于是缺乏库,因此只须要找带有 devel 或 lib 字符的,因此只须要安装pcre-devel包便可——>yum install -y pcre-devel
[root@yong-01 httpd-2.4.33]# yum list |grep pcre
pcre.x86_64                                 8.32-17.el7                @base    
pcre-devel.x86_64                           8.32-17.el7                @base    
pcre.i686                                   8.32-17.el7                base     
pcre-devel.i686                             8.32-17.el7                base     
pcre-static.i686                            8.32-17.el7                base     
pcre-static.x86_64                          8.32-17.el7                base     
pcre-tools.x86_64                           8.32-17.el7                base     
pcre2.i686                                  10.23-2.el7                base     
pcre2.x86_64                                10.23-2.el7                base     
pcre2-devel.i686                            10.23-2.el7                base     
pcre2-devel.x86_64                          10.23-2.el7                base     
pcre2-static.i686                           10.23-2.el7                base     
pcre2-static.x86_64                         10.23-2.el7                base     
pcre2-tools.x86_64                          10.23-2.el7                base     
pcre2-utf16.i686                            10.23-2.el7                base     
pcre2-utf16.x86_64                          10.23-2.el7                base     
pcre2-utf32.i686                            10.23-2.el7                base     
pcre2-utf32.x86_64                          10.23-2.el7                base
  • 下载pcre-devel包
[root@yong-01 httpd-2.4.33]# yum install -y pcre-devel
  1. 使用echo $?检查是否安装成功,这里会看到成功安装
[root@yong-01 httpd-2.4.33]# echo $?
0
  1. 执行make && make install
[root@yong-01 httpd-2.4.33]# make && make install
  • 错误:
collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] 错误 1
make[2]: 离开目录“/usr/local/src/httpd-2.4.29/support”
make[1]: *** [all-recursive] 错误 1
make[1]: 离开目录“/usr/local/src/httpd-2.4.29/support”
make: *** [all-recursive] 错误 1
  • 解决方法:安装libxml2-devel、libtool-ltdl-devel。
    • 进入到/usr/local/src 目录下,删除源码包
  • 接下来便会完成安装Apache

Apache安装完成后

  • 在安装完成后,进入到/usr/local/apache2/目录下,并 ls 查看有哪些目录
[root@yong-01 httpd-2.4.33]# cd /usr/local/apache2/
[root@yong-01 apache2.4]# ls
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
  1. 在之后会接触到的目录就是 bin目录,conf目录,htdocs目录
  • /bin目录下,是可执行文件。也就是说,要启动一个服务,它就是在bin/httpd下面有一个文件或者命令,bin/httpd也是核心的二进制文件
[root@yong-01 apache2]# ls bin/httpd 
bin/httpd
[root@yong-01 apache2]# ls -l bin/httpd 
-rwxr-xr-x 1 root root 2348432 5月  24 23:05 bin/httpd
[root@yong-01 apache2]# du -sh bin/httpd 
2.3M	bin/httpd
  • conf目录,是配置文件所在目录
[root@yong-01 apache2]# ls conf/
extra  httpd.conf  magic  mime.types  original
  • htdocs目录,是存放了一个访问页。启动完httpd服务后,去访问网站,默认的网站会放到 htdocs/目录下
[root@yong-01 apache2]# ls htdocs/
index.html
  • logs目录,就是日志相关的目录
    • 包含:错误日志,访问日志
  • man目录,就是一些帮助文档
  • modules扩展模块目录,全部模块都放到了modules目录下

每个模块都表明着一个功能php

[root@yong-01 apache2]# ls modules
httpd.exp               mod_dbd.so                  mod_proxy_http.so
mod_access_compat.so    mod_dir.so                  mod_proxy_scgi.so
mod_actions.so          mod_dumpio.so               mod_proxy.so
mod_alias.so            mod_env.so                  mod_proxy_wstunnel.so
mod_allowmethods.so     mod_expires.so              mod_ratelimit.so
mod_auth_basic.so       mod_ext_filter.so           mod_remoteip.so
mod_auth_digest.so      mod_file_cache.so           mod_reqtimeout.so
mod_auth_form.so        mod_filter.so               mod_request.so
mod_authn_anon.so       mod_headers.so              mod_rewrite.so
mod_authn_core.so       mod_include.so              mod_sed.so
mod_authn_dbd.so        mod_info.so                 mod_session_cookie.so
mod_authn_dbm.so        mod_lbmethod_bybusyness.so  mod_session_dbd.so
mod_authn_file.so       mod_lbmethod_byrequests.so  mod_session.so
mod_authn_socache.so    mod_lbmethod_bytraffic.so   mod_setenvif.so
mod_authz_core.so       mod_lbmethod_heartbeat.so   mod_slotmem_shm.so
mod_authz_dbd.so        mod_log_config.so           mod_socache_dbm.so
mod_authz_dbm.so        mod_log_debug.so            mod_socache_memcache.so
mod_authz_groupfile.so  mod_logio.so                mod_socache_shmcb.so
mod_authz_host.so       mod_macro.so                mod_speling.so
mod_authz_owner.so      mod_mime.so                 mod_status.so
mod_authz_user.so       mod_negotiation.so          mod_substitute.so
mod_autoindex.so        mod_proxy_ajp.so            mod_unique_id.so
mod_buffer.so           mod_proxy_balancer.so       mod_unixd.so
mod_cache_disk.so       mod_proxy_connect.so        mod_userdir.so
mod_cache.so            mod_proxy_express.so        mod_version.so
mod_cache_socache.so    mod_proxy_fcgi.so           mod_vhost_alias.so
mod_cgid.so             mod_proxy_fdpass.so         mod_watchdog.so
mod_dav_fs.so           mod_proxy_ftp.so
mod_dav.so              mod_proxy_hcheck.so
[root@yong-02 apache2]# du -sh modules/
6.3M	modules/
  • 查看Apache加载了哪些模块
  • /usr/local/apache2/bin/httpd -M //查看加载的模块
    • -M 把全部的模块列出来 等于
  • /usr/local/apache2/bin/apachectl -M //查看加载的模块——>这是一个shell文件,它调用了二进制的httpd
[root@yong-01 apache2]# /usr/local/apache2/bin/httpd -M
AH00557: httpd: apr_sockaddr_info_get() failed for yong-01
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message    //这里仅仅是一个提示,提示你要去定义ServerName——>不用去管
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)

[root@yong-01 apache2]# /usr/local/apache2/bin/apachectl -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 192.168.0.104. 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)
  • 在模块的右侧有小括号,里面是 static 或 shared ,static是静态
  • 静态和动态的区别
    • 静态是直接把模块编译进了主脚本或主二进制文件里面
  • http是一个核心文件,这个文件加载了哪些模块
  • 若是是static,那也就意味这个模块在httpd里面,和它绑定在了一块儿,它们是一个总体
  • 若是是shared,说明它是一个扩展的模块,这个模块是一个文件,咱们能够看到的 .so 文件,文件的目录是在/usr/local/apache2.4/module目录下

启动Apache2.4

  1. 在安装完成Apache2.4后,Apache启动不须要定义启动脚本,也不须要放到/etc/init.d下去,直接使用命令行启动就行
  • /usr/local/apache2/bin/apachectl start //命令行启动Apache脚本
  • 启动脚本后,虽然出现提示,但不表示启动失败
  • 若不想要出现提示,只须要编辑配置文件便可
[root@yong-01 apache2]# /usr/local/apache2/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::8004:45b5:96c5:3ca5. Set the 'ServerName' directive globally to suppress this message
  • 查看Apache是否启动,看httpd进程是否存在
[root@yong-01 apache2]# ps aux |grep httpd
root     56203  0.0  0.1  95536  2520 ?        Ss   23:38   0:00 /usr/local/apache2/bin/httpd -k start
daemon   56204  0.0  0.2 382364  4424 ?        Sl   23:38   0:00 /usr/local/apache2/bin/httpd -k start
daemon   56205  0.0  0.2 382364  4424 ?        Sl   23:38   0:00 /usr/local/apache2/bin/httpd -k start
daemon   56206  0.0  0.2 382364  4424 ?        Sl   23:38   0:00 /usr/local/apache2/bin/httpd -k start
root     56291  0.0  0.0 112676   980 pts/0    R+   23:38   0:00 grep --color=auto httpd
  • 查看端口号——>httpd默认监听端口为80,mysqld默认监听端口为3306,25端口是发邮件的,22端口是远程登陆的
[root@yong-01 apache2]# 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      1124/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1467/master         
tcp6       0      0 :::80                   :::*                    LISTEN      56203/httpd         
tcp6       0      0 :::22                   :::*                    LISTEN      1124/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      1467/master         
tcp6       0      0 :::3306                 :::*                    LISTEN      4747/mysqld
相关文章
相关标签/搜索