1.3 Apache安裝:

1.3 Apache安裝:

  • Apache是一個基金會的名字,httpd纔是咱們要安裝的軟件包,早期它的名字就叫apache
    Apache官網www.apache.org
    wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.27.tar.gz
    wget http://mirrors.hust.edu.cn/apache/apr/apr-1.5.2.tar.gz
    wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.5.4.tar.gz
  • apr和apr-util是一個通用的函數庫,它讓httpd能夠不關心底層的操做系統平臺,能夠很方便地移植(從linux移植到windows)
    tar zxvf httpd-2.4.26.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.25
    ./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 //查看加載的模塊

apr函數庫安裝:

[root@Dasoncheng ~]# cd /usr/local/src/
[root@Dasoncheng src]# tar -zxf apr-1.5.2.tar.gz 
[root@Dasoncheng src]# tar -zxf apr-util-1.5.4.tar.gz 
[root@Dasoncheng src]# tar -zxf httpd-2.4.27.tar.gz 
[root@Dasoncheng src]# ls
apr-1.5.2         apr-util-1.5.4.tar.gz  mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
apr-1.5.2.tar.gz  httpd-2.4.27           mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz
apr-util-1.5.4    httpd-2.4.27.tar.gz
[root@Dasoncheng src]# cd apr-1.5.2
[root@Dasoncheng apr-1.5.2]# ./configure --prefix=/usr/local/apr    ##編譯安裝,--prefix指定安裝目錄;
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
Configuring APR library
Platform: x86_64-unknown-linux-gnu
checking for working mkdir -p... yes
APR Version: 1.5.2
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.5.2':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
[root@Dasoncheng apr-1.5.2]# echo $?
1
[root@Dasoncheng apr-1.5.2]# cat config.log 
##報錯,查看報錯信息 再查看日誌,未安裝gcc庫;
[root@Dasoncheng apr-1.5.2]# yum install -y gcc
……
[root@Dasoncheng apr-1.5.2]# ./configure --prefix=/usr/local/apr/
……
[root@Dasoncheng apr-1.5.2]# echo $?
0
[root@Dasoncheng apr-1.5.2]# make && make install  ##安裝;
[root@Dasoncheng apr-1.5.2]# echo $?
0
##安裝成功;

apr-util函數庫安裝:

[root@Dasoncheng apr-1.5.2]# cd ../apr-util-1.5.4
[root@Dasoncheng apr-util-1.5.4]# 
[root@Dasoncheng apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
##編譯安裝,--prefix指定安裝路徑、--with-apr指定關聯文件目錄;
[root@Dasoncheng apr-util-1.5.4]# echo $?
0
[root@Dasoncheng apr-util-1.5.4]# make && make install  ##安裝;
[root@Dasoncheng apr-util-1.5.4]# echo $?
0
##安裝成功;

httpd安裝:

由於安裝httpd有依賴apr和apr-util(能夠理解爲一個通用的函數庫) ,因此提早安裝了。不安裝的話 httpd沒法正常工做!html

[root@Dasoncheng httpd-2.4.27]# ./configure \
> --prefix=/usr/local/apache2.4 \
> --with-apr=/usr/local/apr \
> --with-apr-util=/usr/local/apr-util/ \
> --enable-so \      ##這個表示支持啓用DSO,即支持動態拓展模塊;
> --enable-mods-shared=most      ##表示加載大部分動態模塊(故安裝有點慢);
……
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
##這裏報錯了,須要安裝一些庫文件;
[root@Dasoncheng httpd-2.4.27]# yum install -y pcre prce-devel
[root@Dasoncheng 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
#安裝庫文件以後,從新編譯:
……
……
[root@Dasoncheng httpd-2.4.27]# echo $?
0
[root@Dasoncheng httpd-2.4.27]# make && make install
……
……
[root@Dasoncheng httpd-2.4.27]# echo $?
0
##到這裏安裝就完成了;

httpd模塊查看:

[root@Dasoncheng ~]# ls /usr/local/apache2.4/    ##查看httpd目錄結構;
bin  build  cgi-bin  conf  error  htdocs  icons  include  logs  man  manual  modules
[root@Dasoncheng ~]# ls /usr/local/apache2.4/modules/    ##這個是動態模塊目錄;
httpd.exp               mod_dbd.so                  mod_proxy_http.so
mod_access_compat.so    mod_dir.so                  mod_proxy_scgi.so
mod_actions.so          mod_dumpio.so               mod_proxy.so
mod_alias.so            mod_env.so                  mod_proxy_wstunnel.so
mod_allowmethods.so     mod_expires.so              mod_ratelimit.so
mod_auth_basic.so       mod_ext_filter.so           mod_remoteip.so
……
[root@Dasoncheng ~]# /usr/local/apache2.4/bin/httpd -M    ##查看已加載的模塊;
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
##這上面不是報錯,而是讓你在配置文件設置servername哦!
Loaded Modules:
 core_module (static)    ##這個static表示靜態模塊,直接和httpd主程序綁定在一塊兒 是找不到這些模塊的目錄的哦!
 so_module (static)
 http_module (static)
 mpm_event_module (static)
 authn_file_module (shared)     ##這個shared表示動態模塊,在目錄modules下;
 authn_core_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_core_module (shared)
 access_compat_module (shared)
……
##其中:動態和靜態的區別在於   
##靜態模塊直接和主程序(/usr/local/apache2.4/bin/httpd)綁定在一塊兒,咱們看不到。  
##而動態的模塊都是一個個獨立存在的(modules)目錄下的.so文件;

啓動httpd:

[root@Dasoncheng ~]# /usr/local/apache2.4/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain. Set the 'ServerName' directive globally to suppress this message
[root@Dasoncheng ~]# ps aux |grep httpd
root      34165  0.0  0.2  70864  2200 ?        Ss   03:56   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon    34166  0.1  0.4 359828  4244 ?        Sl   03:56   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon    34167  0.1  0.4 359828  4244 ?        Sl   03:56   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon    34168  0.1  0.4 359828  4240 ?        Sl   03:56   0:00 /usr/local/apache2.4/bin/httpd -k start
root      34251  0.0  0.0 112664   968 pts/0    S+   03:56   0:00 grep --color=auto httpd
[root@Dasoncheng ~]# netstat -lntp |grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      34165/httpd

mark

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

相關文章
相關標籤/搜索