Mariadb二進制包安裝,Apache安裝

安裝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)mysql

  • 下載相關的安裝包並解壓
[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
相關文章
相關標籤/搜索