Mariadb二進位制包安裝,Apache安裝
阿新 • • 發佈:2018-11-25
安裝mariadb
- 下載二進位制包並解壓
[[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
[[email protected] src]# tar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
- 移動目錄到/usr/local/目錄下並重命名為mariadb,進入該目錄
[[email protected] src]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb
[[email protected] src]# cd /usr/local/mariadb
- 初始化資料庫
[[email protected] 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/
- 拷貝模板配置檔案,啟動指令碼,進行相應的修改
[[email protected] mariadb]# cp support-files/my-small.cnf my.cnf # 上一篇安裝MySQL使用的預設配置檔案,這裡正好可以試試非預設配置檔案的安裝
[[email protected] mariadb]# cp support-files/mysql.server /etc/init.d/mariadb
[[email protected] 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" " [email protected]" &
- 啟動maraidb
[[email protected] mariadb]# /etc/init.d/mariadb start
Starting mariadb (via systemctl): Warning: Unit file of mariadb.service changed on disk, 'systemctl daemon-reload' recommended.
[ OK ]
[[email protected] mariadb]# echo $?
0
[[email protected] 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: [email protected]
tcp 0 0 192.168.77.134:22 192.168.77.1:11716 ESTABLISHED 2515/sshd: [email protected]
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)
- 下載相關的安裝包並解壓
[[email protected] src]# wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.37.tar.gz
[[email protected] src]# wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.5.tar.gz
[[email protected] src]# wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz
[[email protected] src]# tar -zxvf apr-1.6.5.tar.gz
[[email protected] src]# tar zvxf apr-util-1.6.1.tar.gz
[[email protected] src]# tar zxvf httpd-2.4.37.tar.gz
- 編譯安裝
# 安裝apr
[[email protected] src]# cd apr-1.6.5/
[[email protected] apr-1.6.5]# ./configure
[[email protected] apr-1.6.5]# make && make install
# 安裝apr-util
[[email protected] apr-1.6.5]# 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-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 解決
[[email protected] apr-util-1.6.1]# yum install expat-devel
[[email protected] apr-1.6.5]# make && make install
# 安裝apache
[[email protected] httpd-2.4.37]# cd ../httpd-2.4.37/
[[email protected] 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/
# 報錯,也是缺少庫,搜尋安裝解決
[[email protected] 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
[[email protected] httpd-2.4.37]# yum install -y pcre-devel
[[email protected] 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)
[[email protected] httpd-2.4.37]# cd ../apr-util-1.6.1/
[[email protected] apr-util-1.6.1]# make clean
[[email protected] apr-util-1.6.1]# yum install -y libxml2-devel
[[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]# cd ../httpd-2.4.37
[[email protected] httpd-2.4.37]# make clean
[[email protected] 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
[[email protected] httpd-2.4.37]# make
[[email protected] httpd-2.4.37]# make install
- 檢視apache已經載入的模組
[[email protected] 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)
- 啟動
[[email protected] httpd-2.4.37]# /usr/local/apache2.4/bin/apachectl start
[[email protected] 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
[[email protected] 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