安装mariadb
- 下载二进制包并解压
[root@test-a 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
[root@test-a src]# tar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
- 移动目录到/usr/local/目录下并重命名为mariadb,进入该目录
[root@test-a src]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb
[root@test-a src]# cd /usr/local/mariadb
- 初始化数据库
[root@test-a mariadb]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mariadb
WARNING: The host 'test-a' could not be looked up with resolveip.
This probably means that your libc libraries are not 100 % compatible
with this binary MariaDB version. The MariaDB daemon, mysqld, should work
normally with the exception that host name resolving will not work.
This means that you should use IP addresses instead of hostnames
when specifying MariaDB privileges !
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 test-a 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@test-a mariadb]# cp support-files/my-small.cnf my.cnf # 上一篇安装MySQL使用的默认配置文件,这里正好可以试试非默认配置文件的安装
[root@test-a mariadb]# cp support-files/mysql.server /etc/init.d/mariadb
[root@test-a mariadb]# vim /etc/init.d/mariadb
# 找到位置'basedir=',然后更改如下
basedir=/usr/local/mariadb
datadir=/data/mariadb
conf=/usr/local/mariadb/my.cnf
# 再往下找到 $bindir/mysqld_safe,添加启动配置项--defaults-file="$conf"
$bindir/mysqld_safe --defaults-file="$conf" --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" &
- 启动maraidb
[root@test-a mariadb]# /etc/init.d/mariadb start
Starting mariadb (via systemctl): Warning: Unit file of mariadb.service changed on disk, 'systemctl daemon-reload' recommended.
[ OK ]
[root@test-a mariadb]# echo $?
0
[root@test-a mariadb]# netstat -antp
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1947/master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1110/sshd
tcp 0 64 192.168.77.134:22 192.168.77.1:11679 ESTABLISHED 2354/sshd: root@pts
tcp 0 0 192.168.77.134:22 192.168.77.1:11716 ESTABLISHED 2515/sshd: root@pts
tcp6 0 0 ::1:25 :::* LISTEN 1947/master
tcp6 0 0 :::3306 :::* LISTEN 4388/mysqld
tcp6 0 0 :::22 :::* LISTEN 1110/sshd
安装Apache
Apache是一个基金会的名字,httpd才是要安装的软件包,早期它的名字就叫apache
Apache官网 www.apache.org
apr和apr-util是一个通用的函数库,它让httpd可以不关心底层的操作系统平台,可以很方便地移植(从Linux移植到Windows)
- 下载相关的安装包并解压
[root@test-a src]# wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.37.tar.gz
[root@test-a src]# wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.5.tar.gz
[root@test-a src]# wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz
[root@test-a src]# tar -zxvf apr-1.6.5.tar.gz
[root@test-a src]# tar zvxf apr-util-1.6.1.tar.gz
[root@test-a src]# tar zxvf httpd-2.4.37.tar.gz
- 编译安装
# 安装apr
[root@test-a src]# cd apr-1.6.5/
[root@test-a apr-1.6.5]# ./configure
[root@test-a apr-1.6.5]# make && make install
# 安装apr-util
[root@test-a apr-1.6.5]# cd ../apr-util-1.6.1/
[root@test-a apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@test-a apr-1.6.5]# make && make install
...
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
#include <expat.h>
^
compilation terminated.
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory `/usr/local/src/apr-util-1.6.1'
make: *** [all-recursive] Error 1
# 出现错误,yum install expat-devel 解决
[root@test-a apr-util-1.6.1]# yum install expat-devel
[root@test-a apr-1.6.5]# make && make install
# 安装apache
[root@test-a httpd-2.4.37]# cd ../httpd-2.4.37/
[root@test-a httpd-2.4.37]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
...
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
# 报错,也是缺少库,搜索安装解决
[root@test-a httpd-2.4.37]# yum list | grep pcre
pcre.x86_64 8.32-12.el7 @anaconda
ghc-pcre-light.x86_64 0.4-13.el7 epel
ghc-pcre-light-devel.x86_64 0.4-13.el7 epel
mingw32-pcre.noarch 8.38-1.el7 epel
mingw32-pcre-static.noarch 8.38-1.el7 epel
mingw64-pcre.noarch 8.38-1.el7 epel
mingw64-pcre-static.noarch 8.38-1.el7 epel
pcre.i686 8.32-17.el7 base
pcre.x86_64 8.32-17.el7 base
pcre-devel.i686 8.32-17.el7 base
pcre-devel.x86_64 8.32-17.el7 base
pcre-static.i686 8.32-17.el7 base
pcre-static.x86_64 8.32-17.el7 base
pcre-tools.x86_64 8.32-17.el7 base
pcre2.i686 10.23-2.el7 base
pcre2.x86_64 10.23-2.el7 base
pcre2-devel.i686 10.23-2.el7 base
pcre2-devel.x86_64 10.23-2.el7 base
pcre2-static.i686 10.23-2.el7 base
pcre2-static.x86_64 10.23-2.el7 base
pcre2-tools.x86_64 10.23-2.el7 base
pcre2-utf16.i686 10.23-2.el7 base
pcre2-utf16.x86_64 10.23-2.el7 base
pcre2-utf32.i686 10.23-2.el7 base
pcre2-utf32.x86_64 10.23-2.el7 base
[root@test-a httpd-2.4.37]# yum install -y pcre-devel
[root@test-a httpd-2.4.37]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
...
/usr/local/apr/build-1/libtool --silent --mode=link gcc -std=gnu99 -g -O2 -pthread -o htpasswd htpasswd.lo passwd_common.lo /usr/local/apr-util/lib/libaprutil-1.la /usr/local/apr/lib/libapr-1.la -lrt -lcrypt -lpthread -ldl -lcrypt
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserCreate'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetCharacterDataHandler'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ParserFree'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetUserData'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_StopParser'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_Parse'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_ErrorString'
/usr/local/apr-util/lib/libaprutil-1.so: undefined reference to `XML_SetElementHandler'
collect2: error: ld returned 1 exit status
make[2]: *** [htpasswd] Error 1
make[2]: Leaving directory `/usr/local/src/httpd-2.4.37/support'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/local/src/httpd-2.4.37/support'
make: *** [all-recursive] Error 1
# 又报错。上网找资料“缺少了xml相关的库,需要安装libxml2-devel包。直接安装并不能解决问题,因为httpd调用的apr-util已经安装好了,但是apr-util并没有libxml2-devel包支持。” (来源: https://my.oschina.net/LuCastiel/blog/1590706)
[root@test-a httpd-2.4.37]# cd ../apr-util-1.6.1/
[root@test-a apr-util-1.6.1]# make clean
[root@test-a apr-util-1.6.1]# yum install -y libxml2-devel
[root@test-a apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@test-a apr-util-1.6.1]# make && make install
[root@test-a apr-util-1.6.1]# cd ../httpd-2.4.37
[root@test-a httpd-2.4.37]# make clean
[root@test-a httpd-2.4.37]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
[root@test-a httpd-2.4.37]# make
[root@test-a httpd-2.4.37]# make install
- 查看apache已经加载的模块
[root@test-a httpd-2.4.37]# /usr/local/apache2.4/bin/httpd -M
AH00557: httpd: apr_sockaddr_info_get() failed for test-a
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.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)
- 启动
[root@test-a httpd-2.4.37]# /usr/local/apache2.4/bin/apachectl start
[root@test-a httpd-2.4.37]# ps -aux|grep httpd
root 48045 0.4 0.2 75792 2388 ? Ss 12:36 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 48046 0.2 0.4 364756 4260 ? Sl 12:36 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 48065 0.7 0.4 364756 4260 ? Sl 12:36 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 48087 0.5 0.4 364756 4264 ? Sl 12:36 0:00 /usr/local/apache2.4/bin/httpd -k start
root 48136 0.0 0.0 112704 972 pts/0 S+ 12:37 0:00 grep --color=auto httpd
[root@test-a httpd-2.4.37]# netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1947/master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1110/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1947/master
tcp6 0 0 :::3306 :::* LISTEN 4627/mysqld
tcp6 0 0 :::80 :::* LISTEN 48045/httpd
tcp6 0 0 :::22 :::* LISTEN 1110/sshd
来源:oschina
链接:https://my.oschina.net/u/996931/blog/2875273