码迷,mamicode.com
首页 > 数据库 > 详细

安装mariadb和apache服务

时间:2018-07-31 00:25:08      阅读:251      评论:0      收藏:0      [点我收藏+]

标签:OWIN   安装apache   nal   vhost   mit   文件目录   conf   保存数据   local   

安装mariadb数据库

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

[root@localhost ]# useradd mysql
[root@localhost ]# mkdir -p /data/mariadb/

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

[root@localhost src]# tar zxf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz -C .
[root@localhost src]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb

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

[root@localhost 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/
[root@localhost mariadb]# echo $?
0                      <----初始化成功

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

[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

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

[root@localhost 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" "$@" &

启动mariadb服务

[root@localhost mariadb]# /etc/init.d/mariadb start
Reloading systemd: [ 确定 ]
Starting mariadb (via systemctl): [ 确定 ]
[root@localhost 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
[root@localhost 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间移植,文章中地址仅参考,请不要直接复制下载!

[root@localhost 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])
[root@localhost 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
[root@localhost 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])

[root@localhost src]# tar zxf apr-1.6.3.tar.gz -C .
[root@localhost src]# cd apr-1.6.3/
[root@localhost 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
[root@localhost apr-1.6.3]# echo $?
0
[root@localhost 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
[root@localhost apr-1.6.3]# echo $?
0

编译安装apr-util

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

[root@localhost src]# tar zxf apr-util-1.6.1.tar.gz -C .
[root@localhost src]# cd apr-util-1.6.1/
[root@localhost 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
[root@localhost apr-util-1.6.1]# echo $?
0
[root@localhost 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
[root@localhost 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 添加大部分需要用到的功能模块

[root@localhost 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

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

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

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

[root@localhost httpd]# ll -h bin/httpd 
-rwxr-xr-x 1 root root 2.3M 7月 29 00:32 bin/httpd            <------apache的启动文件
[root@localhost httpd]# ls conf/             
extra httpd.conf magic mime.types original       <-----配置文件所在目录
[root@localhost httpd]# ls htdocs/
index.html                                     <-----默认网站的根目录
[root@localhost httpd]# ls logs/             <---------日志文件目录
[root@localhost 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
[root@localhost 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编译安装的默认没有启动脚本,这里可以使用命令的方式来进行启动,启动后并查看相应进程及端口号

[root@localhost 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
[root@localhost 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
[root@localhost 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 

安装mariadb和apache服务

标签:OWIN   安装apache   nal   vhost   mit   文件目录   conf   保存数据   local   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!