1 架構
2 安裝
3 配置文件的位置
4 服務啓動關閉腳本,查看端口
5 此服務的使用方法
6 修改配置文件
7 排錯(從下到上,從內到外)
源碼編譯搭建LAMP架構
LAMP=Linux + Apache + MySQL + PHP
源碼安裝和RPM安裝對比
rpm:安裝、部署、管理比較方便,運行穩定;版本較低,功能和性能較差
源碼:安裝、部署、管理比較麻煩,運行相對不穩定;版本較新,功能和性能較高
需要源碼編譯安裝的軟件包
httpd-2.4.7.tar.gz apache主程序包
apr-1.4.6.tar.gz apache依賴包
apr-util-1.4.1.tar.gz apache依賴包
pcre-8.34.tar.gz apache依賴包
首先下載最新的源碼包
安裝之前請先安裝make 、gcc、openssl(安全認證)等編譯工具和開發包
wget -O /etc/yum,repos,d/centOS-Base.repo http://mirrors.aliyun.com/Centos-7.repo
sed -i 's/$releasever/7/g /etc/yum.repos.d/CentOS-Base.repo
yum clean all
yum list
http://httpd.apache.org/
http://apache.fayea.com//httpd/httpd-2.4.18.tar.gz
http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz
http://iweb.dl.sourceforge.net/project/pcre/pcre/8.38/pcre-8.38.zip
yum -y install make gcc openssl
安裝apr-1.4.6.tar.gz
[root@master ~/soft/lamp/LAMPutil/apr-1.4.6]tar−xvfapr−1.4.6.tar.gz[root@master /soft/lamp/LAMPutil/apr−1.4.6]cd apr-1.4.6/
[root@master ~/soft/lamp/LAMPutil/apr-1.4.6]./configure−−prefix=/usr/local/apr[root@master /soft/lamp/LAMPutil/apr−1.4.6]make && make install
[root@master ~/soft/lamp/LAMPutil/apr-1.4.6]make−j4(4個內核同時進行編譯)[root@master /soft/lamp/LAMPutil/apr−1.4.6]echo ?0安裝apr−util−1.4.1.tar.gz[root@master /soft/lamp/LAMPutil]cd apr-util-1.4.1/
[root@master ~/soft/lamp/LAMPutil/apr-util-1.4.1]$./configure --prefix=/usr/local/apr-util/ \
–with-apr=/usr/local/apr/bin/apr-1-config
[root@master ~/soft/lamp/LAMPutil/apr-util-1.4.1]$make && make install
安裝pcre-8.34.tar.gz
unzip pcre-8.34.zip
[root@master ~/soft/lamp/LAMPutil/pcre-8.34]./configure−−prefix=/usr/local/pcre[root@master /soft/lamp/LAMPutil/pcre−8.34]make && make install
[root@master ~/soft/lamp/LAMPutil/pcre-8.34]$echo $?
0
[root@master ~/soft/lamp/LAMPutil/httpd-2.4.7]tar−xvfhttpd−2.4.7.tar.gz[root@master /soft/lamp/LAMPutil]cd httpd-2.4.7/
[root@master ~/soft/lamp/LAMPutil/httpd-2.4.7]lsABOUTAPACHEap.dCHANGESdocsINSTALLMakefile.inosserveracinclude.m4buildCMakeLists.txtemacs−styleInstallBin.dspMakefile.winREADMEsrclibApache−apr2.dswBuildAll.dspconfig.layouthttpd.dspLAYOUTmodulesREADME.cmakesupportApache.dswBuildBin.dspconfigurehttpd.speclibhttpd.dspNOTICEREADME.platformstestapacheprobes.dbuildconfconfigure.inincludeLICENSENWGNUmakefileROADMAPVERSIONING[root@master /soft/lamp/LAMPutil/httpd−2.4.7]configure
[root@master ~/soft/lamp/LAMPutil/httpd-2.4.7]$./configure --prefix=/usr/local/apache2/ \
–enable-so \ (開啓動態加載模塊)
–enable-rewrite \(支持網站地址重寫)
–enable-ssl \(支持ssl加密)
–with-apr=/usr/local/apr \(關聯)
–with-apr-util=/usr/local/apr-util/ \(關聯)
–with-pcre=/usr/local/pcre/(關聯)
[root@master ~/soft/lamp/LAMPutil/httpd-2.4.7]./configure−−prefix=/usr/local/apache2/−−enable−so−−enable−rewrite−−enable−ssl−−with−apr=/usr/local/apr−−with−apr−util=/usr/local/apr−util/−−with−pcre=/usr/local/pcre/[root@master /soft/lamp/LAMPutil/httpd−2.4.7]echo ?0配置文件[root@master /soft/lamp/LAMPutil/httpd−2.4.7]ls /usr/local/apache2/conf/httpd.conf
/usr/local/apache2/conf/httpd.conf
網站根目錄
[root@master ~/soft/lamp/LAMPutil/httpd-2.4.7]ls/usr/local/apache2/htdocs/index.html生成啓動腳本[root@master /soft/lamp/LAMPutil/httpd−2.4.7]cp /usr/local/apache2/bin/apachectl /etc/init.d/
[root@master ~/soft/lamp/LAMPutil/httpd-2.4.7]chmod+x/etc/init.d/apachectl[root@master /soft/lamp/LAMPutil/httpd−2.4.7]vim /etc/init.d/apachectl
#!/bin/sh
chkconfig: 2345 64 36
description: rm apache server
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
將服務添加到系統啓動列表中
[root@master ~]chkconfig−−addapachectl[root@master ]chkconfig apachectl on
[root@master ~]chkconfig−−listapachectlapachectl0:off1:off2:on3:on4:on5:on6:off啓動服務[root@master ]service apachectl start