美文网首页我爱编程
MariaDB安装、Apache安装

MariaDB安装、Apache安装

作者: 强出头 | 来源:发表于2018-04-11 15:45 被阅读0次

    MariaDB安装

    MariaDB安装
    [root@wsl-001 src]# tar zxvf mariadb-10.2.14-linux-glibc_214-x86_64.tar.gz 
    [root@wsl-001 src]# mv mariadb-10.2.14-linux-glibc_214-x86_64 /usr/local/mariadb
    [root@wsl-001 src]# cd /usr/local/mariadb/
    [root@wsl-001 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 wsl-001 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@wsl-001 mariadb]# echo $?
    0
    [root@wsl-001 mariadb]# ls support-files/   (各种模板根据内存大小使用)
    binary-configure        my-large.cnf         mysql-log-rotate  wsrep_notify
    magic                   my-medium.cnf        mysql.server
    my-huge.cnf             my-small.cnf         policy
    my-innodb-heavy-4G.cnf  mysqld_multi.server  wsrep.cnf
    [root@wsl-001 mariadb]# cp support-files/my-small.cnf /usr/local/mariadb/my.cnf (为了区分不放在/etc/my.cnf下)
    [root@wsl-001 mariadb]# cp support-files/mysql.server /etc/init.d/mariadb
    [root@wsl-001 mariadb]# vim /usr/local/mariadb/my.cnf(基本不用改)
    [root@wsl-001 mariadb]# vim /etc/init.d/mariadb 
    
    /etc/init.d/mariadb
    /etc/init.d/mariadb
    [root@wsl-001 mariadb]# ps aux |grep mysql
    root       5698  0.0  0.0 112676   984 pts/0    S+   17:17   0:00 grep --color=auto mysql
    [root@wsl-001 mariadb]# /etc/init.d/mariadb start
    Reloading systemd:                                         [  确定  ]
    Starting mariadb (via systemctl):                          [  确定  ]
    [root@wsl-001 mariadb]# ps aux |grep mysql
    root       5739  0.0  0.0 115388  1720 ?        S    17:17   0:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir=/data/mysql --pid-file=/data/mysql/wsl-001.pid
    mysql      5848  0.8  3.5 1585784 65880 ?       Sl   17:17   0:00 /usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/mariadb/my.cnf --basedir=/usr/local/mariadb --datadir=/data/mysql --plugin-dir=/usr/local/mariadb/lib/plugin --user=mysql --log-error=/data/mysql/wsl-001.err --pid-file=/data/mysql/wsl-001.pid --socket=/tmp/mysql.sock --port=3306
    root       5883  0.0  0.0 112676   980 pts/0    R+   17:18   0:00 grep --color=auto mysql
    [root@wsl-001 mariadb]# netstat -ltnp
    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      874/sshd            
    tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1093/master         
    tcp        0      0 172.16.79.140:8730      0.0.0.0:*               LISTEN      1655/rsync          
    tcp6       0      0 :::3306                 :::*                    LISTEN      5848/mysqld         
    tcp6       0      0 :::22                   :::*                    LISTEN      874/sshd            
    tcp6       0      0 ::1:25                  :::*                    LISTEN      1093/master         
    [root@wsl-001 mariadb]# vim /usr/local/mariadb/my.cnf 
    

    这时候没有指定datadir,所以会在/etc/my.cnf里面找,此时须在配置文件中加上


    /usr/local/mariadb/my.cnf

    重新启动就发现datadir发生了改变

    [root@wsl-001 mariadb]# /etc/init.d/mariadb stop
    Stopping mariadb (via systemctl):                          [  确定  ]
    [root@wsl-001 mariadb]# /etc/init.d/mariadb start
    Starting mariadb (via systemctl):                          [  确定  ]
    [root@wsl-001 mariadb]# !ps
    ps aux |grep mysql
    root       6222  0.0  0.0 115388  1724 ?        S    17:50   0:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir=/data/mariadb --pid-file=/data/mariadb/wsl-001.pid
    mysql      6334  5.2  2.6 1585716 49740 ?       Sl   17:50   0:00 /usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/mariadb/my.cnf --basedir=/usr/local/mariadb --datadir=/data/mariadb --plugin-dir=/usr/local/mariadb/lib/plugin --user=mysql --log-error=/data/mariadb/wsl-001.err --pid-file=/data/mariadb/wsl-001.pid --socket=/tmp/mysql.sock --port=3306
    root       6369  0.0  0.0 112676   980 pts/0    S+   17:51   0:00 grep --color=auto mysql
    

    Apache安装

    Apache安装
    [root@wsl-001 apr-1.6.3]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.33.tar.gz
    [root@wsl-001 apr-1.6.3]# wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz
    [root@wsl-001 apr-1.6.3]# wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz
    [root@wsl-001 apr-1.6.3]# tar zxvf httpd-2.4.33.tar.gz 
    [root@wsl-001 apr-1.6.3]# tar zxvf apr-1.6.3.tar.gz 
    [root@wsl-001 apr-1.6.3]# tar -zxvf apr-util-1.6.1.tar.gz 
    [root@wsl-001 apr-1.6.3]# cd apr-1.6.3/
    [root@wsl-001 apr-1.6.3]# ./configure --prefix=/usr/local/apr
    [root@wsl-001 apr-1.6.3]# echo $?
    0
    [root@wsl-001 apr-1.6.3]# make && make install
    [root@wsl-001 apr-1.6.1]# ls /usr/local/apr/
    bin  build-1  include  lib
    
    Apache安装
    [root@wsl-001 apr-util-1.6.1]# cd /usr/local/src/apr-util-1.6.1/
    [root@wsl-001 apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
    [root@wsl-001 apr-util-1.6.1]# make && make install
    
    如果遇到错误
    yum install expat-devel
    
    或者
    解决办法:
    
    # cd /usr/local/src/
    
    # cp -r apr-1.5.2 /usr/local/src/httpd-2.4.7/srclib/apr
    
    # cp -r apr-util-1.5.4 /usr/local/src/httpd-2.4.7/srclib/apr-util
    
    [root@wsl-001 apr-util-1.6.1]# ls /usr/local/apr-util/
    bin  include  lib
    
    
    [root@wsl-001 apr-util-1.6.1]# cd /usr/local/src/httpd-2.4.33/
    [root@wsl-001 httpd-2.4.33]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
    
    出现错误,缺少pcre正则包
    configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
    
    [root@wsl-001 httpd-2.4.33]# yum list |grep pcre  (安装库包一般后缀带lib或者devel)
    [root@wsl-001 httpd-2.4.33]# yum install -y pcre-devel
    [root@wsl-001 httpd-2.4.33]# ./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@wsl-001 httpd-2.4.33]# echo $?
    0
    [root@wsl-001 httpd-2.4.33]# make && make install
    

    编译过程中都正常,但是make&&make install 的时候出现了如下错误

    /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/httpd-2.4.26/support'
    make[1]: *** [all-recursive] Error 1
    make[1]: Leaving directory `/usr/local/httpd-2.4.26/support'
    make: *** [all-recursive] Error 1
    

    安装libxml2-devel

    [root@test_01 ~]# yum install -y libxml2-devel
    

    删除apr-util目录并且重新编译安装

    [root@test_01 ~]#rm -rf /usr/local/apr-util
    [root@test_01 ~]# cd /usr/local/src/apr-util-1.6.1/
    [root@test_01 apr-util-1.6.1]# make clean
    [root@test_01 apr-util-1.6.1]#./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr 
    [root@test_01 apr-util-1.6.1]#make && make install
    

    再重新编译安装httpd

    [root@wsl-001 httpd-2.4.33]# ./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@wsl-001 httpd-2.4.33]# echo $?
    0
    [root@wsl-001 httpd-2.4.33]# make && make install
    [root@wsl-001 httpd-2.4.33]# echo $?
    0
    
    [root@wsl-001 httpd-2.4.33]# cd /usr/local/apache2.4/
    [root@wsl-001 apache2.4]# ls
    bin(里面的httpd文件为核心二进制文件)    cgi-bin  error   icons    logs(日志)  manual
    build  conf(配置文件)     htdocs(默认访问页)  include  man   modules(扩展模块)
    [root@wsl-001 apache2.4]# /usr/local/apache2.4/bin/apachectl -M(查看模块)
    
    [root@wsl-001 apache2.4]# /usr/local/apache2.4/bin/apachectl start
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::20c:29ff:fe45:ec93. Set the 'ServerName' directive globally to suppress this message
    httpd (pid 48973) already running  (可配置不提示错误信息)
    [root@wsl-001 apache2.4]# ps aux|grep httpd
    root      48973  0.0  0.1  95536  2516 ?        Ss   21:56   0:00 /usr/local/apache2.4/bin/httpd
    daemon    48974  0.0  0.1 382364  2380 ?        Sl   21:56   0:00 /usr/local/apache2.4/bin/httpd
    daemon    48975  0.0  0.1 382364  2380 ?        Sl   21:56   0:00 /usr/local/apache2.4/bin/httpd
    daemon    48977  0.0  0.2 382364  4416 ?        Sl   21:56   0:00 /usr/local/apache2.4/bin/httpd
    root      49085  0.0  0.0 112676   984 pts/0    S+   22:07   0:00 grep --color=auto httpd
    [root@wsl-001 apache2.4]# netstat -lntp
    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      874/sshd            
    tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      1093/master         
    tcp        0      0 172.16.79.140:8730      0.0.0.0:*               LISTEN      1655/rsync          
    tcp6       0      0 :::3306                 :::*                    LISTEN      6334/mysqld         
    tcp6       0      0 :::80                   :::*                    LISTEN      48973/httpd         
    tcp6       0      0 :::22                   :::*                    LISTEN      874/sshd            
    tcp6       0      0 ::1:25                  :::*                    LISTEN      1093/master 
    

    扩展
    apache dso https://yq.aliyun.com/articles/6298
    apache apxs http://man.chinaunix.net/newsoft/ApacheMenual_CN_2.2new/programs/apxs.html
    apache工作模式 http://www.cnblogs.com/fnng/archive/2012/11/20/2779977.html

    相关文章

      网友评论

        本文标题:MariaDB安装、Apache安装

        本文链接:https://www.haomeiwen.com/subject/hqhnhftx.html