MariaDB安裝 、Apache安裝

MariaDB安裝

  • cd /usr/local/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
  • tar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
  • mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb
  • cd /usr/local/mariadb
  • ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb/ --datadir=/data/mariadb
  • cp support-files/my-small.cnf /usr/local/mariadb/my.cnf
  • vi /usr/local/mariadb/my.cnf //定義basedir和datadir
  • cp support-files/mysql.server /etc/init.d/mariadb
  • vim /etc/init.d/mariadb //定義basedir、datadir、conf以及啓動參數
  • /etc/init.d/mariadb start

1.下載mariaDB

[root@linux-128 ~]# cd /usr/local/src/
[root@linux-128 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

2.解壓

[root@linux-128 src]# tar -zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz

3.將目錄重名命

[root@linux-128 src]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb
[root@linux-128 src]# cd /usr/local/mariadb/
[root@linux-128 mariadb]# ls
bin                 data               include         mysql-test    share
COPYING             DESTINATION        INSTALL-BINARY  README.md     sql-bench
COPYING.thirdparty  docs               lib             README-wsrep  support-files
CREDITS             EXCEPTIONS-CLIENT  man             scripts

4.建立mysql用戶

[root@linux-128 mysql]# useradd -s /sbin/nologin mysql

5.建立存放數據庫的目錄

[root@linux-128 mysql]# mkdir /data

6.初始化

[root@linux-128 mariadb]# ./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb/ --datadir=/data/mariadb    //--user=mysql定義mysql身份運行,--basedir=/usr/local/mariadb 定義mariadb的安裝目錄,這裏若是不定義mariadb的目錄有可能系統會去找以前安裝的mysql的目錄,--datadir=/data/mariadb定義存放數據庫的目錄

[root@linux-128 mariadb]# echo $?  //
0

7.配置文件

Mariadb的配置文件也在/user/local/mariadb/support-files/目錄下,和mysql有必定區別,這個目錄下有好幾個配置模板mysql

[root@linux-128 mariadb]# ls /usr/local/mariadb/support-files/
binary-configure  my-innodb-heavy-4G.cnf  my-small.cnf         mysql.server  wsrep_notify
magic             my-large.cnf            mysqld_multi.server  policy
my-huge.cnf       my-medium.cnf           mysql-log-rotate     wsrep.cnf

my-huge.cnf my-large.cnf my-medium.cnf my-small.cnf這些配置文件的區別就在於緩存數字的大小不同,這些值是根據內存的大小指定合適的緩存,這樣會讓mysql達到一個更高效的性能。咱們作實驗內存是1G 拷貝my-small.cnf就能夠,若是你的內存有幾十G,能夠拷貝my-huge.cnf,再根據實際狀況適當調整這些參數。linux

1.拷貝配置文件

[root@linux-128 mariadb]# cp support-files/my-small.cnf  /usr/local/mariadb/my.cnf  //爲了和以前mysql的配置文件區別,將配置文件路徑修改下。

2.修改配置文件

[root@linux-128 ~]# vim /usr/local/mariadb/my.cnf
添加basedir和datadir
[mysqld]
basedir = /usr/local/mariadb    //mariadb安裝目錄
datadir = /data/mariadb		   //存放數據庫目錄
port            = 3306      
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

8.拷貝啓動腳本

[root@linux-128 mariadb]# cp support-files/mysql.server /etc/init.d/mariadb

1.修改啓動腳本

[root@linux-128 ~]# vim /etc/init.d/mariadb
須要修改2個地方
basedir=/usr/local/mariadb     //存放mariadb的目錄
datadir=/data/mariadb			//存放數據庫的目錄
conf=$basedir/my.cnf			//指定配置文件的路徑

而且在開始啓動腳本中添加上面修改的配置文件路徑

輸入圖片說明

2.啓動腳本

[root@linux-128 ~]# /etc/init.d/mariadb start
Starting mariadb (via systemctl):                          [  肯定  ]

這裏要注意:以前安裝過mysql,因此在安裝mariadb的時候,要先關閉mysqld服務,在啓動腳本中指定了配置文件路徑conf,並將添加到啓動腳本中,若是以前沒有裝過mysql,能夠直接將配置文件拷貝到/etc/my.cnf,啓動腳本中也不用指定配置文件路徑。sql


Apache

  • Apache是一個基金會的名字,httpd纔是咱們要安裝的軟件包,早期它的名字就叫apache
  • Apache官網www.apache.org
  • Apache wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz
  • apr: wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz
  • apr-util:wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.bz2
  • apr和apr-util是一個通用的函數庫,它讓httpd能夠不關心底層的操做系統平臺,能夠很方便地移植(從linux移植到windows)
  • tar zxvf httpd-2.4.27.tar.gz
  • tar zxvf apr-util-1.5.4.tar.gz
  • tar zxvf apr-1.5.2.tar.gz
  • cd /usr/local/src/apr-1.5.2
  • ./configure --prefix=/usr/local/apr
  • make && make install
  • cd /usr/local/src/apr-util-1.5.4
  • ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
  • make && make install
  • cd /usr/local/src/httpd-2.4.27
  • ./configure \ //這裏的反斜槓是脫義字符,加上它咱們能夠把一行命令寫成多行
  • --prefix=/usr/local/apache2.4 \
  • --with-apr=/usr/local/apr \
  • --with-apr-util=/usr/local/apr-util \
  • --enable-so \
  • --enable-mods-shared=most
  • make && make install
  • ls /usr/local/apache2.4/modules
  • /usr/local/apache2.4/bin/httpd -M //查看加載的模塊

1.下載apache和apr、apr-util

[root@linux-128 apr-1.6.3]# http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.29.tar.gz
[root@linux-128 apr-1.6.3]# wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.3.tar.gz
[root@linux-128 apr-1.6.3]# wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.bz2

2.解壓

[root@linux-128 apr-1.6.3]# tar zxvf apr-1.6.3.tar.gz
[root@linux-128 src]# tar -jxvf apr-util-1.6.1.tar.bz2
[root@linux-128 src]# tar -zxvf httpd-2.4.29.tar.gz

3.安裝apr

[root@linux-128 src]# cd apr-1.6.3/
初始化
[root@linux-128 apr-1.6.3]# ./configure --prefix=/usr/local/apr
…
[root@linux-128 apr-1.6.3]# echo $?    //檢查初始化是否正確
0

編譯make
[root@linux-128 apr-1.6.3]# make
[root@linux-128 apr-1.6.3]# echo $?    //檢查編譯是否正確
0

編譯安裝 make install
[root@linux-128 apr-1.6.3]# make install
…
[root@linux-128 apr-1.6.3]# echo $?    //檢查編譯安裝是否正確
0
[root@linux-128 apr-1.6.3]# ls /usr/local/apr
bin  build-1  include  lib

4.安裝apr-util

[root@linux-128 apr-1.6.3]# cd /usr/local/src/apr-util-1.6.1/
初始化
[root@linux-128 apr-util-1.6.1]#  ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@linux-128 apr-util-1.6.1]# echo $?
0
編譯make
[root@linux-128 apr-util-1.6.1]# make
…
xml/apr_xml.c:35:19: 致命錯誤:expat.h:沒有那個文件或目錄
 #include <expat.h>
                  ^
編譯中斷。
make[1]: *** [xml/apr_xml.lo] 錯誤 1
make[1]: 離開目錄「/usr/local/src/apr-util-1.6.1」
make: *** [all-recursive] 錯誤 1
編譯報錯,須要安裝expat-devel包
[root@linux-128 apr-util-1.6.1]# yum install -y expat-devel

而後從新編譯 make
…
[root@linux-128 apr-util-1.6.1]# echo $?
0

編譯安裝 make install
[root@linux-128 apr-util-1.6.1]# make install
[root@linux-128 apr-util-1.6.1]# echo $?
0
apr/      bin/      games/    lib/      libexec/  mysql/    share/
[root@linux-128 apr-util-1.6.1]# ls /usr/local/apr-util/
bin  include  lib

5.安裝apache

1.初始化

[root@linux-128 apr-util-1.6.1]# cd /usr/local/src/httpd-2.4.29/
[root@linux-128 httpd-2.4.29]# ./configure \   //這裏的反斜槓是脫義字符,加上它咱們能夠把一行命令寫成多行
--prefix=/usr/local/apache2.4 \     //指定安裝路徑
--with-apr=/usr/local/apr \			//指定apr
--with-apr-util=/usr/local/apr-util \	//指定apr-util
--enable-so \		//支持動態模塊 ;表示啓用DSO,意思是把某些功能以模塊的形式展示出來,一個功能模塊就是一個.so文件,編譯完會看到這些文件。
--enable-mods-shared=most   //指定模塊most;most絕大多數功能模塊

這裏出現一個錯誤:
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
能夠用yum list來查找缺乏那個包數據庫

[root@linux-128 httpd-2.4.29]# yum list |grep pcre
pcre.x86_64                               8.32-15.el7_2.1              @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@linux-128 httpd-2.4.29]# yum install -y pcre-devel

2.而後從新編譯參數

[root@linux-128 httpd-2.4.29]# ./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@linux-128 httpd-2.4.29]# echo $?
0

3.編譯make

[root@linux-128 httpd-2.4.29]# make
…

這裏出現一個錯誤
輸入圖片說明 緣由是apr-util的版本問題,1.6過高,從新下載1.5版本,從新編譯安裝apr-util1.5apache

[root@linux-128 httpd-2.4.29]# wget http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz
[root@linux-128 httpd-2.4.29]# tar -zxvf apr-util-1.5.2.tar.gz
[root@linux-128 httpd-2.4.29]# cd /usr/local/src/apr-util-1.5.2/
[root@linux-128 apr-util-1.5.2]# ./configure -prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@linux-128 apr-util-1.5.2]# make
[root@linux-128 apr-util-1.5.2]# make install

而後再從新編譯apachevim

[root@linux-128 apr-util-1.5.2]# cd /usr/local/apache2.4/
[root@linux-128 apache2.4]# ./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@linux-128 apache2.4]# make
[root@linux-128 apache2.4]# make install
[root@linux-128 apr-util-1.5.2]# cd /usr/local/apache2.4/
[root@linux-128 apache2.4]# ls
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules

這裏介紹一個進程用到的目錄
bin :可執行文件的目錄
conf:配置文件的目錄
htdocs:默認訪問網站的目錄
logs:日誌文件的目錄
modules:存放動態模塊的目錄;也就是.so文件,每個模塊就表明這一個功能

查看apache都加載了那些模塊windows

[root@linux-128 apache2.4]# /usr/local/apache2.4/bin/apachectl -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::fdb8:14ca:d41b:3dc8. Set the 'ServerName' directive globally to suppress this message
Loaded Modules:   	//這裏不用管它
 core_module (static)   //static 表示靜態模塊
 so_module (static)     
 http_module (static)
 mpm_event_module (static)
 authn_file_module (shared)    //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)

動態和靜態模塊的區別:靜態模塊直接和主程序(/usr/local/apache2.4/bin/httpd)綁定在一塊兒,動態模塊都是一個個獨立存在的文件(moudles目錄下面的.so文件)這些動態模塊不會所有加載,若是想用哪一個動態模塊,直接在配置文件裏面配置便可。緩存

相關文章
相關標籤/搜索