11.6 MariaDB安装 11.7/11.8/11.9 Apache安装 安装apr 安装 apr-util 安装 httpd

11.6 MariaDB安装

  • 进入规则下载目录
/usr/local/src
  • 解包
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
  • 进入mariadb目录
cd !$
  • 初始化目录,创建用户
[root@localhost mariadb]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mariadb
Installing MariaDB/MySQL system tables in '/data/mariadb' ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following commands:

'./bin/mysqladmin' -u root password 'new-password'
'./bin/mysqladmin' -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
'./bin/mysql_secure_installation'

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at http://mariadb.com/kb or the
MySQL manual for more instructions.

You can start the MariaDB daemon with:
cd '.' ; ./bin/mysqld_safe --datadir='/data/mariadb'

You can test the MariaDB daemon with mysql-test-run.pl
cd './mysql-test' ; perl mysql-test-run.pl

Please report any problems at http://mariadb.org/jira

The latest information about MariaDB is available at http://mariadb.org/.
You can find additional information about the MySQL part at:
http://dev.mysql.com
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/

查看命令是否出错

[root@localhost mariadb]# echo $?
0
[root@localhost mariadb]# ls /data/mariadb/
aria_log.00000001  ib_buffer_pool  ib_logfile0  mysql               test
aria_log_control   ibdata1         ib_logfile1  performance_schema
  • 拷贝配置文件

mariadb 有好几个配置模板
my-large.cnf、my-medium.cnf、my-small.cnf、my-huge.cnf他们的不同,在于缓存大小的不一样
缓存:

# The MySQL server
[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

模板的不同,在于,可以根据内存的大小,使mysql 达到一个更高校的工作性能
内存小,可以直接使用small,内存大的可以使用 huge

  • 拷贝配置文件
[root@localhost mariadb]# cp support-files/my-small.cnf /usr/local/mariadb/my.cnf
  • 拷贝启动脚本
[root@localhost mariadb]# cp support-files/mysql.server /etc/init.d/mariadb
  • 编辑配置文件
    [client] 和客户端有关系,不需要动,因为是服务端,改服务[mysqld] 这一个部分就行了的就行了。
#skip-networking            // 做主从架构的
server-id       = 1
[mysqldump]                 // 用做备份的
quick
max_allowed_packet = 16M

因为是学习用,配置文件,基本上都不需要改动

  • 编辑启动脚本
    定义这一项
basedir=/usr/local/mariadb
datadir=/data/mariadb
conf=$basedir/my.cnf

在启动项增加
因为,机器之前安装有个MySQL ,为了区分启动,才定义了一个启动项
300行的地方,或者直接搜索 start

case "$mode" in
  '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 --defaults-file="$conf" --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@"&
      wait_for_ready; return_value=$?

      # Make lock for RedHat / SuSE
      if test -w "$lockdir"
      then
        touch "$lock_file_path"
      fi

      exit $return_value
    else
      log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)"
    fi
    ;;

尝试开启服务
开启前,查看一下是否有mysql 的服务器在启动,两个服务是会冲突的\

ps aux |grep mysqld
[root@localhost mariadb]# ps aux |grep mysqld
root      1059  0.0  0.0 115376  1616 ?        S    21:15   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid
mysql     1504  0.1 24.1 973056 453528 ?       Sl   21:15   0:05 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/tmp/mysql.sock
root      2493  0.0  0.0 112664   968 pts/0    S+   22:36   0:00 grep --color=auto mysqld

发现有服务启动,关闭服务

[root@localhost mariadb]# /etc/init.d/mysqld stop
Shutting down MySQL.. SUCCESS!

尝试开启服务

[root@localhost mariadb]# /etc/init.d/mariadb start
Reloading systemd:                                         [  确定  ]
Starting mariadb (via systemctl):                          [  确定  ]

查看服务是否开启

[root@localhost mariadb]# ps aux |grep mariadb
root      2553  0.1  0.0 115380  1740 ?        S    22:37   0:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir=/data/mysql --pid-file=/data/mysql/localhost.localdomain.pid
mysql     2669  4.2  3.1 1125120 58600 ?       Sl   22:37   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/localhost.localdomain.err --pid-file=/data/mysql/localhost.localdomain.pid --socket=/tmp/mysql.sock --port=3306
root      2714  0.0  0.0 112664   972 pts/0    S+   22:37   0:00 grep --color=auto mariadb

grep 的时候,其实用mysqld 也是可以,因为mariadb是MySQL的一个分支,所有很多东西都保留了,原来的基础

查看端口

netstat -ltnp
[root@localhost mariadb]# 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      991/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1727/master
tcp6       0      0 :::3306                 :::*                    LISTEN      2669/mysqld
tcp6       0      0 :::22                   :::*                    LISTEN      991/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      1727/master

MySQL和mariadb 用法是相同的。

11.7/11.8/11.9 Apache安装

Apache是一个基金会的名字,因为Apache就是由httpd起家的,因为用的人很多,所有才由Apache命名,从2.0版本开始更名httpd
主流版本 1.3、2.0 、2.4
2.2和2.4的区别,安装方法不太一样,依赖软件区别apr版本不一样
apr和apr-util是一个通用的函数库,它让httpd可以不关心底层的操作系统平台,可以很方便地移植(从linux移植到windows)
2.4安装起来麻烦,就是因为需要手动编译 httpd2.4的包和 apr-util的包
因为更新太快,安装包的时候需要去网站上查看一下。。

[root@localhost src]# ls
apr-1.5.2.tar.gz       httpd-2.4.25.tar.gz  mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
apr-util-1.5.4.tar.gz  httpd-2.4.27.tar.gz  mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz

把需要用到的包先下载好。
把下载好的包,解压

tar -zxvf httpd-2.4.27.tar.gz
tar zxvf apr-1.5.2.tar.gz
tar zxvf apr-util-1.5.4.tar.gz

安装apr

由于apr-util依赖于apr,所以需要先编译安装apr包
进入apr-1.5.2目录下

[root@localhost src]# cd apr-1.5.2/

安装apr

[root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
Configuring APR library
Platform: x86_64-unknown-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.5.2
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.5.2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

提示缺少gcc依赖包:

checking for gcc... no
checking for cc... no
checking for cl.exe... no
yum install -y gcc 

重新执行 ./configure --prefix=/usr/local/apr 检查依赖包并配置编译后的文件存放路径
检查结束以后,使用echo $? 查看命令运行情况\

config.status: executing libtool commands
rm: cannot remove 'libtoolT': No such file or directory
config.status: executing default commands
[root@localhost apr-1.5.2]# echo $?
0

发现没有错误

开始编译 apr

make 

编译后把编译好的文件放到指定目录

make install

运行结束以后 记得运行 echo $? 查看命令运行情况

安装 apr-util

检查依赖关系,并指定编译后的文件存放路径 这里需要多指定一个 --with-apr=/usr/local/apr/ 因为这个包,依赖于apr ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/ 开始编译 apr make 编译后把编译好的文件放到指定目录 make install

安装 httpd

  • 配置相关项 [root@localhost httpd-2.4.27]# ./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(most指的就是绝大多数的意思) Apache 、PHP 都支持以一个模块的形式存在,模块实际上就是一个 “ .so ” 为后缀名的文件 Apache本身是一个进程、一个服务,在这个进程里面,通过一些配置文件指定了模块的路径,那就可以去调用模块。 PHP模块是用来解析PHP的,执行PHP脚本的,所以就可以通过PHP脚本将PHP模块加载到进程里面去 当遇到PHP解析时,就会去调用这个模块 这些模块是一些独立的文件

运行的时候提示 configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/ 缺少这个 查找看看依赖包

yum list |grep pcre

因为一般缺少的都是库文件,所以包一般都是 以devel 名字结尾的包 缺少的是这个包

yum install -y pcre-devel.x86_64

安装以后,再次进行检查配置,没有提示出错,使用echo $? 检查一下

  • 开始编译httpd
make

把编译好的文件存放到指定好的目录

make install

以后接触Apache 一般都是

  1. bin 下的二进制执行文件
  2. conf目录 配置文件
  3. htdocs 访问页,默认的网站页面会存放到这里
  4. logs 日志目录
  5. man 帮助文档之类
  6. modules 模块目录,里面每一个模块都代表一个功能 查看在使用的模块,两条命令都可以
/usr/local/apache2.4/bin/httpd -M 
/usr/local/apache2.4/bin/apachectl -M
[root@localhost apache2.4]# /usr/local/apache2.4/bin/httpd -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. 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)

apachectl这个是一个shell文件,他去调用httpd二进制执行文件
静态模块和动态模块的区别
静态模块是直接把这个模块编译进主脚本或者是主二进制文件里面“httdp”他们是一个整体
static 表示这个模块是静态模块
shared 为扩展模块,是一个可以看见的文件,.so 后缀名 对文件 存在于/usr/local/apache2.4/modules 目录下
apache启动不需要定义启动脚本,也不需要放到/etc/目录下\

  • 启动服务

直接使用命令行启动

/usr/local/apache2.4/bin/apachectl start

会有提示可以不用理会\

AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message

更改配置文件可以不再提示\

  • 运行情况检查

查看 httpd 是否启动

ps aux |grep httpd
[root@localhost apache2.4]# ps aux |grep httpd
root     32804  0.0  0.1  70848  2232 ?        Ss   01:14   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon   32805  0.0  0.2 359812  4252 ?        Sl   01:14   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon   32806  0.0  0.2 359812  4252 ?        Sl   01:14   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon   32807  0.0  0.2 359812  4252 ?        Sl   01:14   0:00 /usr/local/apache2.4/bin/httpd -k start
root     32890  0.0  0.0 112664   976 pts/0    S+   01:14   0:00 grep --color=auto httpd

看看端口号

netstat -lntp
httpd 默认监听 80端口
[root@localhost apache2.4]# 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      991/sshd
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1727/master
tcp6       0      0 :::3306                 :::*                    LISTEN      2669/mysqld
tcp6       0      0 :::80                   :::*                    LISTEN      32804/httpd
tcp6       0      0 :::22                   :::*                    LISTEN      991/sshd
tcp6       0      0 ::1:25                  :::*                    LISTEN      1727/master

转载于:https://my.oschina.net/nova12315/blog/1661949

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值