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] t a r − x v f a p r − 1.4.6. t a r . g z [ r o o t @ m a s t e r / s o f t / l a m p / L A M P u t i l / a p r − 1.4.6 ] tar -xvf 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] . / c o n f i g u r e − − p r e f i x = / u s r / l o c a l / a p r [ r o o t @ m a s t e r / s o f t / l a m p / L A M P u t i l / a p r − 1.4.6 ] ./configure --prefix=/usr/local/apr [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] m a k e − j 4 ( 4 个 内 核 同 时 进 行 编 译 ) [ r o o t @ m a s t e r / s o f t / l a m p / L A M P u t i l / a p r − 1.4.6 ] make -j 4 (4个内核同时进行编译) [root@master ~/soft/lamp/LAMPutil/apr-1.4.6] make−j4(4个内核同时进行编译)[root@master /soft/lamp/LAMPutil/apr−1.4.6]echo ? 0 安 装 a p r − u t i l − 1.4.1. t a r . g z [ r o o t @ m a s t e r / s o f t / l a m p / L A M P u t i l ] ? 0 安装apr-util-1.4.1.tar.gz [root@master ~/soft/lamp/LAMPutil] ?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] . / c o n f i g u r e − − p r e f i x = / u s r / l o c a l / p c r e [ r o o t @ m a s t e r / s o f t / l a m p / L A M P u t i l / p c r e − 8.34 ] ./configure --prefix=/usr/local/pcre [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] t a r − x v f h t t p d − 2.4.7. t a r . g z [ r o o t @ m a s t e r / s o f t / l a m p / L A M P u t i l ] tar -xvf httpd-2.4.7.tar.gz [root@master ~/soft/lamp/LAMPutil] 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] l s A B O U T A P A C H E a p . d C H A N G E S d o c s I N S T A L L M a k e f i l e . i n o s s e r v e r a c i n c l u d e . m 4 b u i l d C M a k e L i s t s . t x t e m a c s − s t y l e I n s t a l l B i n . d s p M a k e f i l e . w i n R E A D M E s r c l i b A p a c h e − a p r 2. d s w B u i l d A l l . d s p c o n f i g . l a y o u t h t t p d . d s p L A Y O U T m o d u l e s R E A D M E . c m a k e s u p p o r t A p a c h e . d s w B u i l d B i n . d s p c o n f i g u r e h t t p d . s p e c l i b h t t p d . d s p N O T I C E R E A D M E . p l a t f o r m s t e s t a p a c h e p r o b e s . d b u i l d c o n f c o n f i g u r e . i n i n c l u d e L I C E N S E N W G N U m a k e f i l e R O A D M A P V E R S I O N I N G [ r o o t @ m a s t e r / s o f t / l a m p / L A M P u t i l / h t t p d − 2.4.7 ] ls ABOUT_APACHE ap.d CHANGES docs INSTALL Makefile.in os server acinclude.m4 build CMakeLists.txt emacs-style InstallBin.dsp Makefile.win README srclib Apache-apr2.dsw BuildAll.dsp config.layout httpd.dsp LAYOUT modules README.cmake support Apache.dsw BuildBin.dsp configure httpd.spec libhttpd.dsp NOTICE README.platforms test apache_probes.d buildconf configure.in include LICENSE NWGNUmakefile ROADMAP VERSIONING [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] . / c o n f i g u r e − − p r e f i x = / u s r / l o c a l / a p a c h e 2 / − − e n a b l e − s o − − e n a b l e − r e w r i t e − − e n a b l e − s s l − − w i t h − a p r = / u s r / l o c a l / a p r − − w i t h − a p r − u t i l = / u s r / l o c a l / a p r − u t i l / − − w i t h − p c r e = / u s r / l o c a l / p c r e / [ r o o t @ m a s t e r / s o f t / l a m p / L A M P u t i l / h t t p d − 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] ./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 配 置 文 件 [ r o o t @ m a s t e r / s o f t / l a m p / L A M P u t i l / h t t p d − 2.4.7 ] ? 0 配置文件 [root@master ~/soft/lamp/LAMPutil/httpd-2.4.7] ?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] l s / u s r / l o c a l / a p a c h e 2 / h t d o c s / i n d e x . h t m l 生 成 启 动 脚 本 [ r o o t @ m a s t e r / s o f t / l a m p / L A M P u t i l / h t t p d − 2.4.7 ] ls /usr/local/apache2/htdocs/ index.html 生成启动脚本 [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] c h m o d + x / e t c / i n i t . d / a p a c h e c t l [ r o o t @ m a s t e r / s o f t / l a m p / L A M P u t i l / h t t p d − 2.4.7 ] chmod +x /etc/init.d/apachectl [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
将服务添加到系统启动列表中 [root@master ~] c h k c o n f i g − − a d d a p a c h e c t l [ r o o t @ m a s t e r ] chkconfig --add apachectl [root@master ~] chkconfig−−addapachectl[root@master ]chkconfig apachectl on [root@master ~] c h k c o n f i g − − l i s t a p a c h e c t l a p a c h e c t l 0 : o f f 1 : o f f 2 : o n 3 : o n 4 : o n 5 : o n 6 : o f f 启 动 服 务 [ r o o t @ m a s t e r ] chkconfig --list apachectl apachectl 0:off 1:off 2:on 3:on 4:on 5:on 6:off 启动服务 [root@master ~] chkconfig−−listapachectlapachectl0:off1:off2:on3:on4:on5:on6:off启动服务[root@master ]service apachectl start
