MariaDB、Apache(httpd)安装

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

时间: 2024-08-01 03:27:46

MariaDB、Apache(httpd)安装的相关文章

LAMP(2)Apache(httpd)安装

                        Apache(httpd)安装 Apache是一个基金会的名字,httpd才是我们要安装的软件包,早期它的名字就叫apache Apache官网www.apache.org 1.下载版本2.4(此时会的版本是依赖apr包)  三个包都得下载(下载到/usr/local/src) wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz wget  http://mirrors.cnn

Apache Httpd安装与配置

1.1 简介 Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器,可以在大多数计算机操作系统中运行,由于其多平台和安全性[1]被广泛使用,是最流行的Web服务器端软件之一.它快速.可靠并且可通过简单的API扩展,将Perl/Python等解释器编译到服务器中. 功能包括目录索引.目录别名.内容协商.可配置的HTTP错误报告.CGI程序的SetUID执行.子进程资源管理.服务器端图像映射.重写URL.URL拼写检查以及联机手册等. Apach

CentOS6.5_X64 下Apache Httpd安装配置

一.下载  1.登录http://httpd.apache.org.  2.下载2.4.7版本. #cd /opt #wget http://mirror.esocc.com/apache//httpd/httpd-2.4.7.tar.gz 二.安装  1.安装apr.apr-util.pcre 登录http://www.apache.org,下载apr-1.5.0.apr-util-1.5.3 #tar zxvfv apr-1.5.0 #cd apr-1.5.0 #./configure --

apache/httpd 安装

cd /usr/local/src/      进入到下载apache目录 tar zxvf httpd-包名       解压apache cd httpd解压的目录名     进入到解压的目录 安装apache ./configure --prefix=/usr/local/apache2  --enable-mods-shared=most  --enable-so 安装apache过程中如果安装了apr和apr-util 使用这条命令 ./configure --prefix=/usr/

centos7 apache httpd安装和配置django项目

一.安装httpd服务 apache在centos7中是Apache HTTP server.如下对httpd的解释就是Apache HTTP Server.所以想安装apache其实是要安装httpd. httpd.x86_64 : Apache HTTP Server 安装: # yum install httpd 设置httpd服务开机启动 [[email protected] httpd]# /sbin/chkconfig httpd on Note: Forwarding reques

11.6 -11.9 MariaDB,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工作模式 http://www.cnblogs.com/fnng/archive/2012/11/20/2779

Linux学习总结(三十一)lamp之mariadb apache 安装

一 mariadb 介绍 ?MySQL是一个关系型数据库,由mysql ab公司开发,mysql在2008年被sun公司收购(10亿刀),2009年sun公司被oracle公司收购(74亿刀)? MySQL官网https://www.mysql.com 最新版本5.7GA/8.0DMR? MySQL5.6变化比较大,5.7性能上有很大提升? Mariadb为MySQL的一个分支,官网https://mariadb.com/最新版本10.2? MariaDB主要由SkySQL公司(现更名为Mari

CentOS7安装apache httpd服务

虚拟机:192.168.2.21     [停止防火墙]   sudo systemctl stop firewalld.service      --停止防火墙   sudo systemctl disable firewalld.service   --开机关闭防火墙    [安装apache httpd服务]   cat /etc/yum.repos.d/CentOS-Media.repo   -----查看镜像配置   yum --disablerepo=\* --enablerepo=

Linux(CentOS)系统下安装好apache(httpd)服务后,其他电脑无法访问的原因

原文:Linux(CentOS)系统下安装好apache(httpd)服务后,其他电脑无法访问的原因 今天试了下在虚拟机上利用CentOS系统的yum命令安装好了httpd(apache2.4.6),然后在windows系统下访问此虚拟机的ip地址,却访问不了. 因为前段时间有知道过iptable的限制,所以在想是不是因为iptable限制了80端口呢! 所以在网上找了下iptable的命令,并且把tcp的80端口设置成允许任何IP都可以访问: iptables -I INPUT -p TCP