CentOS 6 LAMP搭建,编译安装
搭建准备工作:[*]CentOS 6.6
[*]服务器IP:192.168.230.202
[*]软件包位置/tmp/httpd
[*]wget http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.25.tar.gz##httpd2.4.25
[*]wget https://www.openssl.org/source/openssl-1.0.1u.tar.gz ##openssl
[*]https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.5.2.tar.gz##aprapr-util
[*]
[*]wget http://mirrors.163.com/.help/CentOS6-Base-163.repo ##centos6 yum源
[*]rpm -Uvh http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm ##epel
[*]包组:yum groupinstall "Compatibility libraries" "Development tools"
[*]软件包 yum install gcc
[*]软件包 yum install pcre-devel pcre -y
真佩服我们做了这么多准备,老天不会欺负这么勤快的孩子的
开始上主菜了
1、安装apr、apr-util
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# tar -xf apr-1.5.2.tar.gz
##解压解压
# tar -xf apr-util-1.5.4.tar.gz
##解压解压
cd /tmp/httpd/apr-1.5.2
./configure --prefix=/usr/local/apr1.5
##--prefix指定安装位置
make && make install
##编译,安装
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr1.5
##这个是apr的工具集,它依赖于上面的那个apr, 所以加上--with来指定我们安装apr的目录。
make && make install
##编译,安装
2、安装openssl
1
2
3
4
5
# tar xf openssl-1.0.1u.tar.gz
# cd openssl-1.0.1u
# ./config --prefix=/usr/local/opensslu -fPIC
##-fPIC 经过多次测试,如果不加,在装HTTPD2.4的时候,会出现报错
# make && make install
1
2
3
4
5
6
7
##导出库文件,新建/etc/ld.so.conf.d/openssl1u.conf文件。 https会用到新版本的库文件。
##添加/usr/local/openssl1j/lib
ldconfig
ldconfig是一个动态链接库管理命令,为了让动态链接库为系统所共享,还需运行动态链接库的管理命令--ldconfig。 ldconfig 命令的用途,主要是在默认搜寻目录(/lib和/usr/lib)以及动态库配置文件/etc/ld.so.conf内所列的目录下,搜索出可共享的动态 链接库(格式如前介绍,lib*.so*),进而创建出动态装入程序(ld.so)所需的连接和缓存文件.缓存文件默认为 /etc/ld.so.cache,此文件保存已排好序的动态链接库名字列表.
往/lib和/usr/lib里面加东西,是不用修改/etc/ld.so.conf的,但是完了之后要调一下ldconfig,不然这个library会找不到
三、安装httpd2.4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# tar xf httpd-2.4.25.tar.gz
# cd httpd-2.4.25
#./configure --prefix=/usr/local/httpd2.4 --sysconfdir=/etc/httpd2.4 --enable-so --enable-ssl --enable-rewrite --enable-cgi --with-zlib --with-pcre --with-apr=/usr/local/apr1.5/ --with-apr-util=/usr/local/apr-util/ --with-ssl=/usr/local/openssl1u/ --enable-modules=most --enable-mpms-shared=all --with-mpm=event
make && make install
--sysconfdir 配置文件目录
-enable-so 开启DSO动态装卸shared模块
--enable-ssl https的功能
--enable-rewrite 地址重写
--enable-cgi CGI脚本功能
--with-zlib 压缩功能的函数库
--with-pcreperl库 刚才安装的软件的目录
--enable-modules=most 编译常用的模块
--enable-mpms-shared=all 所有的动态模块后面这个默认挂载MPM模块event.
杂项
(1)去httpd的安装目录看一下结果。一切OK的话就可以下面的了。
(2 ) 把httpd的头文件符号链接到/usr/include #不是必须的,怕以后有软件会用。
# ln -s /usr/local/httpd2.4/include/ /usr/include/httpd2.4
( 3 ) 新建/etc/profile.d/httpd2.4.sh文件,添加进PATH变量。
1
2
3
4
5
6
7
vim /etc/profile.d/httpd2.4.sh
#写入文件内容,执行一个source
export PATH=/usr/local/httpd2.4/bin:$PATH
source /etc/profile.d/httpd2.4.sh
##文件内容
echo $PATH
( 4 )编辑/etc/httpd2.4/httpd.conf
# grep rex /etc/httpd2.4/httpd.conf
ServerName www.rex.com:80
##ServerName 把原本的#ServerName www.example.com:80改成自己想要的域名并删掉#
# /usr/local/httpd2.4/bin/apachectl start
# curl 127.0.0.1
<html><body><h1>It works!</h1></body></html>
It works!
(5) 来个服务脚本,可以用service来启动关闭。
为了避免麻烦,直接把原来的httpd的服务脚本复制一下,改吧改吧。
# cp /etc/init.d/httpd /etc/init.d/httpd24
# vim /etc/init.d/httpd24
##表示区别,我们服务名叫httpd24
41行开始
1
2
3
4
5
6
7
apachectl=/usr/local/httpd2.4/bin/apachectl
httpd=${HTTPD-/usr/local/httpd2.4/bin/httpd}
prog=httpd
pidfile=${PIDFILE-/var/run/httpd2.4/httpd2.4.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd2.4}
RETVAL=0
STOP_TIMEOUT=${STOP_TIMEOUT-10}
把原来的目录改成我们编译安装后的目录
pid待会要去创建
# mkdir /var/run/httpd2.4
# chmod 700 /var/run/httpd2.4
创建进程文件夹并修改权限
# vim /etc/httpd2.4/httpd.conf
32行里面加入:
pidFile "/var/run/httpd2.4/httpd2.4.pid"
图上已经能这能正常使用service XXX start了
并且有对应的pid号
最后,我们再编译个开机启动
# chkconfig --add httpd24
# chkconfig httpd24 on
##httpd24开机自启动
# chkconfig --list httpd24
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
页:
[1]