MariaDB安装
1.将下载的源码包放到这个目录下:
[[email protected] ~]# cd /usr/local/src
2.下载源码包:
[[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 //这个是国外服务器,下载要四五十分钟,最后是下载后直接放到指定目录上。
3.将压缩包解压:
[[email protected] ~]# tar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
4.把目录移动到/usr/local/下并改名为mariadb:
[[email protected] src]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb
5.进入目录查看:
[[email protected] src]# cd /usr/local/mariadb
6.初始化指定用户mysql和路径:
[[email protected] mariadb]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb/ --datadir=/data/mariadb
[[email protected] mariadb]# ls /data/mariadb
aria_log.00000001 aria_log_control ib_buffer_pool ibdata1 ib_logfile0 ib_logfile1 mysql performance_schema test
7.复制配置文件:
[[email protected] mariadb]# cp support-files/my-small.cnf /usr/local/mariadb/my.cnf 为了与mysql区分,重新换一个文件路径
8.编辑配置文件:
#vi /usr/local/mariadb/my.cnf 定义basedir和datadir
如果没有修改/usr/local/mariadb/my.cnf配置文件,没有在mysqld中加一行 datadir=/data/mariadb,那么它就会调用/etc/my.cnf中的datadir,就会出现如图下的情况。
那如果修改了/usr/local/mariadb/my.cnf配置文件,在mysqld中加一行 datadir=/data/mariadb,如下:
然后重新启动mariadb服务,查看服务后如下:
9.复制启动脚本:
[[email protected] mariadb]# cp support-files/mysql.server /etc/init.d/mariadb
10.编辑启动脚本:
命令:vim /etc/init.d/mariadb
//定义basedir、datadir、conf以及启动参数
basedir=/usr/local/mariadb
datadir=/data/mariadb
conf=$basedir/my.cnf
示例如下:
[[email protected] mariadb]# vim /usr/local/mariadb/my.cnf 配置脚本一般情况下不用更改。
[[email protected] mariadb]# vim /etc/init.d/mariadb 按下图配置修改启动脚本,修改完成保存退出。
备注:此启动脚本由于mariadb与mysql装在一台机器上,为了区分开来,需要定义conf与变量,如果只装mariadb的话就不需要定义。
11.启动MariaDB,启动之前看看有没有mysqld的服务在启动,如果有它们是会冲突的,因为它们的监听端口是一样的:
[[email protected] mariadb]# ps aux |grep mysql 先查看mysql的服务有没启动
root 818 0.0 0.0 115376 504 ? S 15:56 0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/gary-tao.pid
mysql 1189 0.0 45.1 1038844 451316 ? Sl 15:56 0:03 /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/gary-tao.err --pid-file=/data/mysql/gary-tao.pid --socket=/tmp/mysql.sock
root 4853 0.0 0.0 112664 972 pts/0 R+ 17:36 0:00 grep --color=auto mysql
[[email protected] mariadb]# service mysqld stop 关闭mysql服务
Shutting down MySQL.. SUCCESS!
[[email protected] mariadb]# service mariadb start //etc/init.d/mariadb start 两种启动服务方式
Starting mariadb (via systemctl): [ 确定 ]
[[email protected] mariadb]# ps aux |grep mariadb 服务启动成功
root 5198 0.0 0.1 115380 1732 ? S 17:42 0:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir=/data/mysql --pid-file=/data/mysql/gary-tao.pid
mysql 5314 10.8 5.4 1125120 54544 ? Sl 17:42 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/gary-tao.err --pid-file=/data/mysql/gary-tao.pid --socket=/tmp/mysql.sock --port=3306
root 5353 0.0 0.0 112664 972 pts/0 S+ 17:42 0:00 grep --color=auto mariadb
[[email protected] 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 800/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1230/master
tcp6 0 0 :::3306 :::* LISTEN 5314/mysqld
tcp6 0 0 :::22 :::* LISTEN 800/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1230/master
Apache安装
Apache是一个基金会的名字,httpd才是我们要安装的软件包,早期它的名字就叫apache。
1.Apache官网地址 www.apache.org
2.wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.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.gz
apr和apr-util是一个通用的函数库,它让httpd可以不关心底层的操作系统平台,可以很方便地移植(从linux移植到windows)
3.下载安装包到指定目录:
[[email protected] ~]# cd /usr/local/src
4.将压缩包解压:
[[email protected] src]# tar zxvf httpd-2.4.29.tar.gz
[[email protected] src]# tar zxvf apr-1.6.3.tar.gz
[[email protected] src]# tar zxvf apr-util-1.6.1.tar.gz
5.首先安装apr,进入apr目录,然后安装apr:
[[email protected] src]# cd /usr/local/src/apr-1.6.3
[[email protected] apr-1.6.3]# ./configure --prefix=/usr/local/apr
[[email protected] apr-1.6.3]# echo $?
0
[[email protected] apr-1.6.3]# make && make install
[[email protected] apr-1.6.3]# ls /usr/local/apr/
bin build-1 include lib
安装时报错问题解决:
示例如下:
[[email protected] 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
[[email protected] src]# yum install -y gcc 装gcc编译
6.进入apr-util目录,安装apr-util,apr-util要指定apr,因为它依赖apr:
[[email protected] apr-1.6.3]# cd ../apr-util-1.6.1/
[[email protected] apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[[email protected] apr-util-1.6.1]# make && make install
[[email protected] apr-util-1.6.1]# ls /usr/local/apr-util/
bin include lib
在编译安装的时候可能会遇到图下的情况,缺少expat的开发库,所以需要安装包:yum install expat-devel,安装完成之后再编译安装make && make install:
7.进入http目录,安装httpd方法:
[[email protected] src]# cd httpd-2.4.29
[[email protected] 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
[[email protected] httpd-2.4.29]# echo $?
0
安装时报错:
如果没有安装pcre这个包,就会出现下图的错误,我们可以使用 yum list |grep 关键字,查找关联的安装包。这里需要安装包:yum install -y pcre-devel.x86_64
make编译的时候可能会出现下图的情况,把httpd,apr-util的源码包删除掉,然后在重新解压源码包,再重新把apr-util,httpd编译安装一遍
8.进入apache2.4目录下的查看文件:
[[email protected] httpd-2.4.29]# cd /usr/local/apache2.4/
[[email protected] apache2.4]# ls
bin build cgi-bin conf error htdocs icons include logs man manual modules
针对目录文件说明:
bin:bin下的文件是可执行的二进制文件或命令,是核心的二进制文件,如httpd;
conf:配置文件所在的目录;
htdocs:存放了一个访问网页,默认的网站会放到这个目录下;
logs:日志相关的目录,错误日志,访问日志等;
man:帮助文档;
modules:扩展模块,模块都放在这个目录下,每一个模块都代表一个功能;
9.查看加载的模块:
命令:
/usr/local/apache2.4/bin/httpd -M
/usr/local/apache2.4/bin/apachectl -M shell文件,去调用了二进制httpd文件,-M就是把模块例出来。
[[email protected] apache2.4]# /usr/local/apache2.4/bin/httpd -M 下面AHOO558不是一个错误,只是一个警告,可以在配置文件中定义ServerName使其消失。
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 218.93.250.18. 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:静态,是直接把模块编译进了二进制文件httpd里。有static说明是httpd里的,静态模块是直接跟主程序(/usr/local/apache2.4/bin/httpd)绑定在一起,它们是一个整体。httpd是核心文件。
shared:说明是扩展的模块,这个模块是一个文件(文件是在modules目录下面的.so文件)。
10.启动httpd(Apache监听端口是80端口):
[[email protected] apache2.4]# /usr/local/apache2.4/bin/apachectl start 执行启动命令
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 218.93.250.18. Set the 'ServerName' directive globally to suppress this message
[[email protected] apache2.4]# ps aux |grep httpd
root 46077 0.0 0.2 95536 2604 ? Ss 21:24 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 46078 0.0 0.4 382364 4452 ? Sl 21:24 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 46079 0.0 0.4 382364 4452 ? Sl 21:24 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 46080 0.0 0.4 382364 4452 ? Sl 21:24 0:00 /usr/local/apache2.4/bin/httpd -k start
root 46165 0.0 0.0 112680 972 pts/0 R+ 21:24 0:00 grep --color=auto httpd
[[email protected] 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 800/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1230/master
tcp6 0 0 :::3306 :::* LISTEN 6043/mysqld
tcp6 0 0 :::80 :::* LISTEN 46077/httpd
tcp6 0 0 :::22 :::* LISTEN 800/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1230/master
原文地址:http://blog.51cto.com/ccj168/2073693