安装mariadb和apache服务

安装mariadb数据库

准备工作:
下载mariadb
官网:https://mariadb.com,选择download下载免编译安装的版本
创建mariadb运行用户,创建用户组,创建数据存储目录,在初始化时需要指定这些项

[[email protected] ]# useradd mysql
[[email protected] ]# mkdir -p /data/mariadb/

解压至当前目录,并移动到/usr/local/目录下重命名为mariadb,并进入mariadb目录下

[[email protected] src]# tar zxf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz -C .
[[email protected] src]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb

创建mariadb数据存储目录(如/data/mariadb),创建运行用户,运行用户和mysql使用同一个用户,并初始化mariadb数据库

[[email protected] mariadb]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb/ --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:
‘/usr/local/mariadb//bin/mysqladmin‘ -u root password ‘new-password‘
‘/usr/local/mariadb//bin/mysqladmin‘ -u root -h localhost password ‘new-password‘
Alternatively you can run:
‘/usr/local/mariadb//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 ‘/usr/local/mariadb/‘ ; /usr/local/mariadb//bin/mysqld_safe --datadir=‘/data/mariadb‘
You can test the MariaDB daemon with mysql-test-run.pl
cd ‘/usr/local/mariadb//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/
[[email protected] mariadb]# echo $?
0                      <----初始化成功

拷贝mariadb的配置文件和启动脚本

[[email protected] mariadb]# cp support-files/my-small.cnf /usr/local/mariadb/my.cnf
[[email protected] mariadb]# cp support-files/mysql.server /etc/init.d/mariadb

修改配置my.cnf配置文件,这里不对mariadb做更高级的功能,这里保持默认不进行更改

[[email protected] mariadb]# vim /usr/local/mariadb/my.cnf 

# Example MySQL config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it‘s important that the mysqld daemon
# doesn‘t use much resources.
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the "--help" option.

# The following options will be passed to all MySQL clients
[client]
#password = your_password
port = 3306
socket = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port = 3306
data   = /data/mariadb/            <-------指定保存数据的目录
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

更改启动脚本文件,指定安装目录、数据存储目录、配置文件路径信息,start下的--default-file=需要指定出mariadb的配置文件路径的变量,以便让服务正常启动并使用

# overwritten by settings in the MySQL configuration files.
basedir=/usr/local/mariadb
datadir=/data/mariadb
conf=$bashdir/my.cnf
--------------------------------------省略内容---------------------------------
 ‘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" "[email protected]" &

启动mariadb服务

[ro[email protected] mariadb]# /etc/init.d/mariadb start
Reloading systemd: [ 确定 ]
Starting mariadb (via systemctl): [ 确定 ]
[[email protected] mariadb]# ps -aux |grep mariadb
root 2090 0.0 0.0 112724 976 pts/1 R+ 02:39 0:00 grep --color=auto mariadb
mysql 23181 0.0 17.9 1112632 182888 ? Sl 7月28 0:06 /usr/local/mysql/bin/mysqld --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --plugin-dir=/usr/local/mysql//lib/plugin --user=mysql --log-error=/var/log/mariadb/mariadb.log --pid-file=/usr/local/mysql/data/localhost.pid --port=3306
[[email protected] mariadb]# netstat -ntlp |grep 3306
tcp6 0 0 :::3306 :::* LISTEN 23181/mysqld 

安装apache

apache是一个基金会的名字,httpd是服务需要安装的包,早期的名字叫做apache
apache官网:www .apache .org
这里下载的是2.4.33版本的安装包
httpd-2.4.33.tar.gz
安装apache还要安装底层的一个apr和apr-util的函数库,这里使用的版本如下
apr-1.6.3.tar.gz
apr-util-1.6.1.tar.gz

apr安装步骤

安装apr和apr-util的通用函数库,可以让httpd服务不关心底层系统平台,可方便的再linux和windows间移植,文章中地址仅参考,请不要直接复制下载!

[[email protected] src]# wget http://mirrors.hust.edu.cn/apache/apr/apr-1.6.3.tar.gz
--2018-07-28 23:45:55-- http://mirrors.hust.edu.cn/apache/apr/apr-1.6.3.tar.gz
正在解析主机 mirrors.hust.edu.cn (mirrors.hust.edu.cn)... 202.114.18.160
正在连接 mirrors.hust.edu.cn (mirrors.hust.edu.cn)|202.114.18.160|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1072661 (1.0M) [application/octet-stream]
正在保存至: “apr-1.6.3.tar.gz”

100%[======================================================>] 1,072,661 130KB/s 用时 8.8s
2018-07-28 23:46:04 (119 KB/s) - 已保存 “apr-1.6.3.tar.gz” [1072661/1072661])
[[email protected] src]# ls
apr-1.6.3.tar.gz httpd-2.4.33.tar.gz mariadb-10.0.16-linux-glibc_214-x86_64.tar.gz pip-10.0.1 Python-3.7.0.tgz tmp
cmake-3.12.0.tar.gz jiaoben mysql-5.7.22 pip-10.0.1.tar.gz setuptools-39.2.0 user
httpd-2.4.33 jisuan.py mysql-5.7.22.tar.gz Python-3.7.0 setuptools-39.2.0.zip
[[email protected] src]# wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
--2018-07-28 23:46:17-- http://mirrors.hust.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
正在解析主机 mirrors.hust.edu.cn (mirrors.hust.edu.cn)... 202.114.18.160
正在连接 mirrors.hust.edu.cn (mirrors.hust.edu.cn)|202.114.18.160|:80... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:554301 (541K) [application/octet-stream]
正在保存至: “apr-util-1.6.1.tar.gz”

100%[==================================================>] 554,301 110KB/s 用时 5.5s   

2018-07-28 23:46:23 (98.4 KB/s) - 已保存 “apr-util-1.6.1.tar.gz” [554301/554301])

[[email protected] src]# tar zxf apr-1.6.3.tar.gz -C .
[[email protected] src]# cd apr-1.6.3/
[[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
----------------------省略过程-----------------------
config.status: executing libtool commands
rm: cannot remove ‘libtoolT‘: No such file or directory          <---有提示但并不是错误
config.status: executing default commands
[[email protected] apr-1.6.3]# echo $?
0
[[email protected] apr-1.6.3]# make;make install
------------------------过程省略
/usr/bin/install -c -m 644 build/apr_rules.out /usr/local/apr/build-1/apr_rules.mk
/usr/bin/install -c -m 644 /usr/local/src/apr-1.6.3/build/apr_common.m4 /usr/local/apr/build-1
/usr/bin/install -c -m 644 /usr/local/src/apr-1.6.3/build/find_apr.m4 /usr/local/apr/build-1
/usr/bin/install -c -m 755 apr-config.out /usr/local/apr/bin/apr-1-config
[[email protected] apr-1.6.3]# echo $?
0

编译安装apr-util

解压apr-util的打包文件,编译安装apr-util,编译apr-util函数库时需要指定apr的安装路径,这样才可以正确的编译

[[email protected] src]# tar zxf apr-util-1.6.1.tar.gz -C .
[[email protected] src]# cd apr-util-1.6.1/
[[email protected] apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
---------------------------过程省略------------------
config.status: executing default commands
[[email protected] apr-util-1.6.1]# echo $?
0
[[email protected] apr-util-1.6.1]# make;make install
make[1]: 进入目录“/usr/local/src/apr-util-1.6.1”
---------------------------过程省略------------------
/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
[[email protected] apr-util-1.6.1]# echo $?
0

编译安装apache

解压apache打包文件,并进入执行(这里反斜杠表示脱意,把一条命令写成多行输入)
./configure \
--prefix=/usr/local/httpd \
--with-apr=/usr/local/apr \
--with-apr-util=/usr/local/apr-util \
--enable-so \ 添加--enable-so支持动态扩展的模块
--enable-mods-shared=most 添加大部分需要用到的功能模块

[[email protected] httpd-2.4.33]# ./configure > --prefix=/usr/local/httpd > --with-apr=/usr/local/apr > --with-apr-util=/usr/local/apr-util > --enable-so > --enable-mods-shared=most
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
------------------------省略过程--------------------
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:
    Server Version: 2.4.33
    Install prefix: /usr/local/httpd
    C compiler:     gcc -std=gnu99
    CFLAGS:          -g -O2 -pthread
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE
    LDFLAGS:
    LIBS:
    C preprocessor: gcc -E

[[email protected] httpd-2.4.33]# echo $?
0
[[email protected] httpd-2.4.33]# make;make install
--------------------编译过程省略--------------------------
mkdir /usr/local/httpd/manual
make[1]: 离开目录“/usr/local/src/httpd-2.4.33”
[[email protected] httpd-2.4.33]# echo $?
0                                       <---------------编译结果无报错

编译过程中如果有报错不存在某个库,就根据报错的信息安装对应的包,库安装包一般是以level或devel字眼的软件包,使用yum list可以查找出对应的安装包

apache每个目录存储文件简单了解

[[email protected] httpd]# ll -h bin/httpd
-rwxr-xr-x 1 root root 2.3M 7月 29 00:32 bin/httpd            <------apache的启动文件
[[email protected] httpd]# ls conf/
extra httpd.conf magic mime.types original       <-----配置文件所在目录
[[email protected] httpd]# ls htdocs/
index.html                                     <-----默认网站的根目录
[[email protected] httpd]# ls logs/             <---------日志文件目录
[[email protected] httpd]# ls modules/          <--------已经加载的模块,static是静态模块,shared是动态加载的模块
httpd.exp mod_authz_dbd.so mod_deflate.so mod_log_config.so mod_proxy_scgi.so mod_socache_dbm.so
mod_access_compat.so mod_authz_dbm.so mod_dir.so mod_log_debug.so mod_proxy.so mod_socache_memcache.so
mod_actions.so mod_authz_groupfile.so mod_dumpio.so mod_logio.so mod_proxy_uwsgi.so mod_socache_shmcb.so
mod_alias.so mod_authz_host.so mod_env.so mod_macro.so mod_proxy_wstunnel.so mod_speling.so
mod_allowmethods.so mod_authz_owner.so mod_expires.so mod_mime.so mod_ratelimit.so mod_ssl.so
mod_auth_basic.so mod_authz_user.so mod_ext_filter.so mod_negotiation.so mod_remoteip.so mod_status.so
mod_auth_digest.so mod_autoindex.so mod_file_cache.so mod_proxy_ajp.so mod_reqtimeout.so mod_substitute.so
mod_auth_form.so mod_buffer.so mod_filter.so mod_proxy_balancer.so mod_request.so mod_unique_id.so
mod_authn_anon.so mod_cache_disk.so mod_headers.so mod_proxy_connect.so mod_rewrite.so mod_unixd.so
mod_authn_core.so mod_cache.so mod_include.so mod_proxy_express.so mod_sed.so mod_userdir.so
mod_authn_dbd.so mod_cache_socache.so mod_info.so mod_proxy_fcgi.so mod_session_cookie.so mod_version.so
mod_authn_dbm.so mod_cgid.so mod_lbmethod_bybusyness.so mod_proxy_fdpass.so mod_session_dbd.so mod_vhost_alias.so
mod_authn_file.so mod_dav_fs.so mod_lbmethod_byrequests.so mod_proxy_ftp.so mod_session.so mod_watchdog.so
mod_authn_socache.so mod_dav.so mod_lbmethod_bytraffic.so mod_proxy_hcheck.so mod_setenvif.so
mod_authz_core.so mod_dbd.so mod_lbmethod_heartbeat.so mod_proxy_http.so mod_slotmem_shm.so
[[email protected] httpd]# /usr/local/httpd/bin/httpd -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)

启动apache编译安装的默认没有启动脚本,这里可以使用命令的方式来进行启动,启动后并查看相应进程及端口号

[[email protected] httpd]# /usr/local/httpd/bin/apachectl start
AH00558: httpd: Could not reliably determine the server‘s fully qualified domain name, using ::1. Set the ‘ServerName‘ directive globally to suppress this message
[[email protected] httpd]# ps -axu |grep httpd
root 873 0.0 0.2 70952 2252 ? Ss 01:19 0:00 /usr/local/httpd/bin/httpd -k start
daemon 874 0.0 0.2 359916 2220 ? Sl 01:19 0:00 /usr/local/httpd/bin/httpd -k start
daemon 875 0.0 0.2 359916 2220 ? Sl 01:19 0:00 /usr/local/httpd/bin/httpd -k start
daemon 876 0.0 0.2 359916 2220 ? Sl 01:19 0:00 /usr/local/httpd/bin/httpd -k start
root 959 0.0 0.0 112724 976 pts/2 R+ 01:19 0:00 grep --color=auto httpd
[[email protected] httpd]# netstat -nltp
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 1085/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1388/master
tcp6 0 0 :::3306 :::* LISTEN 23181/mysqld
tcp6 0 0 :::80 :::* LISTEN 873/httpd
tcp6 0 0 :::22 :::* LISTEN 1085/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1388/master 

原文地址:http://blog.51cto.com/8844414/2152309

时间: 2024-10-26 01:34:53

安装mariadb和apache服务的相关文章

如何在Windows平台下安装或卸载Apache服务

安装 下载资源包 在下载链接(<–点这里)处下载: 然后,选择你要下载的版本,我选择的是最新版:2.4.16,点击该链接: 因为我的是Windows平台,所以我选择:Files for Microsoft Windows,继续点击: 此处,有5处下载源,我选择的是:ApacheHaus,继续点击: 到了这里就要注意了!针对自己系统的版本,选择合适的版本!我的是64位系统,所以,我选择的是下方的:Apache 2.4.16 x64 ,然后,点击Download Locations下方的那个小国旗,

linux平台下apache的源码安装和将apache服务配置成系统服务

安装apache服务 下载apache源码包 # tar -zxvf http-2.2.29.tar.gz # cd http-2.2.29 #   ./configure --prefix=/usr/local/apache  --enable-so --enable-cgi #   make #   make install 配置成系统服务: #  cp /usr/local/apache/bin/apachectl /etc/init.d/httpd #  cp /usr/local/ap

安装MariaDB和Apache

11.6 安装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_

windows安装mariaDB失败,服务不能启动

过年了,在老家闲余时间想敲敲代码,发现在安装mariaDb的时候一直报错错误信息:Service 'MySQL' (MySQL) Faild to start,Verify that you have suffcient privileges to start system services.服务的MySQL(MySQL)启动错误,确认你有权限启动系统服务.记得多年前在使用sql server 数据库的时候也遇到过同样的问题.1.首先不能关闭安装窗口,然后在计算机管理的服务右键MySQL,点击属

20180227安装mariadb,apache

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.gztar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gzmv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/l

RHEL7使用国内yum源,安装Mariadb 10.2.25, 并配置字符集为utf8mb4

目前阿里, 清华,163等镜像站的Mariadb都是5.5的,有些项目需要用到更新的版本,所以顺便安装一下10版本的,并记录过程 添加中科大的Mariadb 10.2.25 yum源,并yum安装 [mariadb] name = MariaDB baseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64 gpgkey = https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-

mariadb和apache安装

二进制免编译包 官网地址downloads.mariadb解压tar zvxf mariadb-10.2.6移动并修改名称初始化 用户还是mysql 数据库是mariadb查看是否正确配置文件 根据内存大小不同 分配缓存拷贝配置文件并改名拷贝启动脚本编辑配置文件编辑启动脚本定义conf之后启动命令行再定义启动服务查看ps -ef|grep mariadb监听端口默认配置文件没有定义datadir 自动去/etc/mysql里面找可以修改配置文件在配置文件里面定义Apache 安装apr 是一个通

2018-2-27 9周5次课MariaDB、Apache安装

11.6 MariaDB安装 mariadb是mysql的一个分支 ·下载MariaDB二进制安装包: [[email protected] local]# cd src/ [[email protected] 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 (下载过程

MariaDB和 Apache安装

11.6 MariaDB安装 准备工作 因为MariaDB的二进制包镜像源在国外地址,所以预先下载了该包到本地物理机,使用lrzsz工具将该包上传至虚拟机/usr/local/src目录进行安装. 先安装lrzsz工具:[[email protected] src]# yum install -y lrzsz 上传本地包到虚拟终端:[[email protected] ~]# cd /usr/local/src[[email protected] src]# lsmysql-5.6.35-lin