38.Maria安裝 Apache安裝

11.6 MariaDB安裝html

11.7/11.8/11.9 Apache安裝mysql

擴展linux

apache dso https://yq.aliyun.com/articles/6298sql

apache apxs http://man.chinaunix.net/newsoft/ApacheMenual_CN_2.2new/programs/apxs.htmlapache

apache工做模式 http://www.javashuo.com/article/p-mfoutbze-em.htmlvim

 

 

 

11.6 MariaDB安裝:windows

 

基本相似於MySQL,同樣使用二進制的免編譯包centos

cd /usr/local/srcbash

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.gzapp

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 拷貝最小的配置文件模板就能夠,若是內存夠大能夠拷貝最大的huge

vi /usr/local/mariadb/my.cnf //定義basedir和datadir

cp support-files/mysql.conf /usr/local/mariadb/my.cnf 拷貝配置文件模板

vim /usr/local/mariadb/my.cnf 定義datadir = /data/mariadb

cp support-files/mysql.server /etc/init.d/mariadb 拷貝運行腳本

vim /etc/init.d/mariadb //定義basedir、datadir、conf以及啓動參數

/etc/init.d/mariadb start

 

 

 

實例:

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

[root@localhost  mariadb]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb

[root@localhost  src]# cd ..

[root@localhost  local]# ls

apache2 apr apr-util bin etc games include lib lib64 libexec mariadb mysql sbin share src

[root@localhost  local]# cd mariadb/

[root@localhost  mariadb]# mkdir /data/mariadb

[root@localhost  mariadb]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mariadb

[root@localhost  mariadb]# echo $?

0

[root@localhost  mariadb]# cd support-files/

[root@localhost  support-files]# ls

binary-configure my-huge.cnf my-large.cnf my-small.cnf mysql-log-rotate policy wsrep_notify

magic my-innodb-heavy-4G.cnf my-medium.cnf mysqld_multi.server mysql.server wsrep.cnf

[root@localhost  support-files]# cp my-small.cnf /usr/local/mariadb/my.cnf

[root@localhost axinlinux-01 support-files]# cp mysql.server /etc/init.d/mariadb

[root@localhost  support-files]# vim /usr/local/mariadb/my.cnf 須要更改data

[mysqld] 在mysqld里加

datadir = /data/mariadb 加上這一行,定義一下datadir

port = 3306

socket = /tmp/mysql.sock

 

[root@localhost  support-files]# vim //etc/init.d/mariadb 須要改啓動腳本

basedir=/usr/local/mariadb

datadir=/data/mariadb

conf=$basedir/my.cnf

能夠搜一下srart.修改啓動命令參數

'start')

# Start daemon

 

# Safeguard (relative paths, core dumps..)

cd $basedir

 

echo $echo_n "Starting MySQL"

if test -x $bindir/mysqld_safe

then

# Give extra arguments to mysqld with the my.cnf file. This script

# may be overwritten at next upgrade.

$bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" &

在這一行,前面加上 --defaults-file="$conf"

$bindir/mysqld_safe --defaults-file="$conf" --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" &

[root@axinlinux-01 support-files]# /etc/init.d/mariadb start

Reloading systemd: [ 肯定 ]

Starting mariadb (via systemctl):

[ 肯定 ]

[root@localhost  support-files]# ps aux | grep mariadb

[root@localhost  support-files]# 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 997/sshd

tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1338/master

tcp6 0 0 :::80 :::* LISTEN 50236/httpd

tcp6 0 0 :::22 :::* LISTEN 997/sshd

tcp6 0 0 ::1:25 :::* LISTEN 1338/master

tcp6 0 0 :::3306 :::* LISTEN 52640/mysqld

----------------------------------------------------------------------------------------------------------------------------------------------------

 

 

11.7/11.8/11.9 Apache安裝

 

 

Apache是一個基金會的名字,httpd纔是咱們要安裝的軟件包,早期它的名字就叫apache

Apache官網www.apache.org 2.0之後得版本就叫httpd了,如今主流版本是2.4,此次安裝的也是2.4

apr和apr-util是一個通用的函數庫,它讓httpd能夠不關心底層的操做系統平臺,能夠很方便地移植(從linux移植到windows) 2.2和2.4安裝不太同樣,就是由於apr(依賴的軟件)。centos自帶的也就是咱們yum安裝的apr和這個2.4是不同的並不匹配,不能使用yum安裝的apr,因此要編譯。要編譯這面這兩個包(apr和apr-util)

 

2.4源碼包:

wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.39.tar.gz

apr:

http://mirrors.cnnic.cn/apache/apr/apr-1.6.5.tar.gz

apr-util:

http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz

 

tar zxvf httpd-2.4.39.tar.gz

tar zxvf apr-util-1.6.1.tar.gz

tar zxvf apr-1.6.5.tar.gz

cd /usr/local/src/apr-1.6.5

./configure --prefix=/usr/local/apr

make && make install

 

cd /usr/local/src/apr-util-1.6.1.

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

make && make install

 

cd /usr/local/src/httpd-2.4.39

./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 \ //這裏的反斜槓是脫義字符,加上它咱們能夠把一行命令寫成多行

--prefix=/usr/local/apache2.4 \

--with-apr=/usr/local/apr \

--with-apr-util=/usr/local/apr-util \

--enable-so \ 讓他支持動態擴展

--enable-mods-shared=most 指定哪些擴展的模塊。爲most(絕大多數)

make && make install

 

/usr/local/apache2/bin/apachectl start 命令直接啓動。不須要命令腳本

netstat -lntp 默認監聽80端口

 

./bin/httpd爲核心

./conf/會常常打交道

./htdocs/訪問頁

./log/日誌

ls /usr/local/apache2.4/modules 模塊

/usr/local/apache2.4/bin/httpd -M //查看加載的模塊

靜態(static)表示這個模塊被編譯進了主腳本里面

動態(shared)表示擴展的模塊,是一個文件是能夠看到的

 

 

實例:

[root@localhost  src]# 

wget https://mirrors.tuna.tsinghua.edu.cn/apache/httpd/httpd-2.4.39.tar.gz

[root@localhost  src]#

wget http://mirrors.cnnic.cn/apache/apr/apr-1.6.5.tar.gz

[root@localhost  src]#

wget http://mirrors.cnnic.cn/apache/apr/apr-util-1.6.1.tar.gz

 

[root@localhost src]# tar -zxvf httpd-2.4.39.tar.gz

[root@localhost  src]# tar -zxvf apr-1.6.5.tar.gz

[root@localhost  src]# tar -zxvf apr-util-1.6.1.tar.gz

準備工做完成

[root@localhost  apr-1.6.5]# cd apr-1.6.5/ 首先先安裝apr,cd進去

[root@localhost  apr-1.6.5]# ./configure --prefix=/usr/local/apr 安裝方法就是configure,並指定路徑

checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
Configuring APR library
Platform: x86_64-pc-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.6.5
checking for chosen layout... apr
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/usr/local/src/apr-1.6.5':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
# See if we are running on zsh, and set the options that allow our
# commands through without removal of \ escapes INIT.
if test -n "\${ZSH_VERSION+set}"; then
   setopt NO_GLOB_SUBST
fi


    PACKAGE='$PACKAGE'
    VERSION='$VERSION'
    RM='$RM -f'    修改此處,增長-f
    ofile='$ofile'





# Commands run at the beginning of config.status:
APR_SAVE_HEADERS="include/apr.h include/arch/unix/apr_private.h"
APR_MAJOR_VERSION=$APR_MAJOR_VERSION
APR_PLATFORM=$host

for apri in \${APR_SAVE_HEADERS}; do
  test -r \${apri} && mv \${apri} \${apri}.save
done


_ACEOF

上例爲出現這個報錯時修改配置文件rm: cannot remove 'libtoolT': No such file or directory
config.status: executing default commands
編譯成功

setting EXTRA_INCLUDES to ""
configure: creating ./config.status
config.status: creating Makefile
config.status: WARNING:  'Makefile.in' seems to ignore the --datarootdir setting
config.status: creating include/apr.h
config.status: creating build/apr_rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating apr-1-config
config.status: creating apr.pc
config.status: creating test/Makefile
config.status: creating test/internal/Makefile
config.status: creating include/arch/unix/apr_private.h
config.status: executing libtool commands
config.status: executing default commands
config.status: include/apr.h is unchanged
config.status: include/arch/unix/apr_private.h is unchanged

[root@localhost  apr-1.6.5]# echo $? 有報錯,echo $?一下。不要緊的

0

[root@localhost  apr-1.6.5]# make && make install

以上apr安裝完成

[root@localhost  apr-1.6.5]# ls /usr/local/apr 看一下咱們安裝的apr

bin  build-1  include  lib
[root@localhost apr-1.6.5]#  ls /usr/local/
apr  bin  etc  games  include  lib  lib64  libexec  mysql  sbin  share  src

 

bin build-1 include lib

[root@localhost  apr-1.6.5]# cd ../apr-util-1.6.1/ 返回apr-util,準備安裝apr-util

[root@localhost  apr-util-1.6.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr 指定他的路徑同時,還要指定他所依賴的apr (--with-apr=/usr/local/apr)

[root@localhost  apr-util-1.6.1]# make && make install 阿鑫到這有報錯

xml/apr_xml.c:35:19: 致命錯誤:expat.h:沒有那個文件或目錄 果斷百度一下。缺乏 expat庫。yum install -y expat-devel

#include <expat.h>

^

編譯中斷。

make[1]: *** [xml/apr_xml.lo] 錯誤 1

make[1]: 離開目錄「/usr/local/src/apr-util-1.6.1」

make: *** [all-recursive] 錯誤 1

[root@localhost  apr-util-1.6.1]# yum install -y expat-devel 安裝expat-devel庫

[root@localhost apr-util-1.6.1]# make && make install 繼續安裝

Libraries have been installed in:
   /usr/local/apr-util/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the 'LD_RUN_PATH' environment variable
     during linking
   - use the '-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to '/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
/usr/bin/install -c -m 644 aprutil.exp /usr/local/apr-util/lib
/usr/bin/install -c -m 755 apu-config.out /usr/local/apr-util/bin/apu-1-config

[root@localhost  apr-util-1.6.1]# ls /usr/local/apr-util/

[root@localhost apr-util-1.6.1]# ls /usr/local/apr-util/
bin  include  lib

以上apr-util安裝完成

[root@localhost  src]# cd httpd-2.4.39 開始安裝httpd

[root@localhost httpd-2.4.39]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most 指定httpd 指定apr 指定apr-util 指定enable 指定--enable-mods-shared

configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

[root@localhost  httpd-2.4.39]# echo $? 以上報錯,缺乏pcre庫。通常是缺乏什麼什麼庫

1 非0即錯

[root@localhost httpd-2.4.39]# yum install -y pcre-devel 安裝該庫

[root@localhost  httpd-2.4.39]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most 繼續安裝

config.status: creating docs/conf/extra/httpd-languages.conf
config.status: creating docs/conf/extra/httpd-manual.conf
config.status: creating docs/conf/extra/httpd-mpm.conf
config.status: creating docs/conf/extra/httpd-multilang-errordoc.conf
config.status: creating docs/conf/extra/httpd-ssl.conf
config.status: creating docs/conf/extra/httpd-userdir.conf
config.status: creating docs/conf/extra/httpd-vhosts.conf
config.status: creating docs/conf/extra/proxy-html.conf
config.status: creating include/ap_config_layout.h
config.status: creating support/apxs
config.status: creating support/apachectl
config.status: creating support/dbmmanage
config.status: creating support/envvars-std
config.status: creating support/log_server_status
config.status: creating support/logresolve.pl
config.status: creating support/phf_abuse_log.cgi
config.status: creating support/split-logfile
config.status: creating build/rules.mk
config.status: creating build/pkg/pkginfo
config.status: creating build/config_vars.sh
config.status: creating include/ap_config_auto.h
config.status: executing default commands
configure: summary of build options:

    Server Version: 2.4.39
    Install prefix: /usr/local/apache2.4
    C compiler:     gcc -std=gnu99
    CFLAGS:          -g -O2 -pthread  
    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  
    LDFLAGS:           
    LIBS:             
    C preprocessor: gcc -E

[root@localhost  httpd-2.4.39]# echo $?

0

[root@localhost  httpd-2.4.39]# make && make install 報錯,安裝了libxml2.devel

以上httpd安裝完成

Installing configuration files
mkdir /usr/local/apache2.4/conf
mkdir /usr/local/apache2.4/conf/extra
mkdir /usr/local/apache2.4/conf/original
mkdir /usr/local/apache2.4/conf/original/extra
Installing HTML documents
mkdir /usr/local/apache2.4/htdocs
Installing error documents
mkdir /usr/local/apache2.4/error
Installing icons
mkdir /usr/local/apache2.4/icons
mkdir /usr/local/apache2.4/logs
Installing CGIs
mkdir /usr/local/apache2.4/cgi-bin
Installing header files
mkdir /usr/local/apache2.4/include
Installing build system files
mkdir /usr/local/apache2.4/build
Installing man pages and online manual
mkdir /usr/local/apache2.4/man
mkdir /usr/local/apache2.4/man/man1
mkdir /usr/local/apache2.4/man/man8
mkdir /usr/local/apache2.4/manual
make[1]: 離開目錄「/usr/local/src/httpd-2.4.39」
[root@localhost httpd-2.4.39]# ls /usr/local/apache2.4/
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
[root@localhost httpd-2.4.39]# /usr/local/apache2.4/bin/apachectl -M
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using ::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)
相關文章
相關標籤/搜索