本次,让我们先来完成Apache网站服务器的搭建,作为LAMP架构的前端,Apache是一款功能强大、稳定性好的Web服务器程序,该服务器直接面向用户提供网络访问,发送网页,图片等文件内容。
本次安装需要用到的编译安装包:百度网盘密码:2r7m
- 首先,我们可以把安装包挂载到opt目录下新建的lamp目录中并把http、apr(支持Apache上层应用跨平台,提供底层接口库)、apr-util三个压缩包解压到opt目录中:
mount.cifs //192.168.x.x/LAMP /opt/lamptar xzvf http-2.4.2.tar.gz -C /opttar xzvf apr-1.4.6.tar.gz -C /opttar xzvf apr-util-1.4.1.tar.gz -C /opt
- 移动到opt目录中,并把apr、apr-util递归复制httpd中srclib目录中,并分别为他们新建目录方便识别:
cp -R apr-1.4.6/ /opt/httpd-2.4.2/srclib/aprcp -R apr-util-1.4.1/ /opt/httpd-2.4.2/srclib/apr-util
- 使用yum仓库安装 gcc 、 gcc-c++ ?、 make ?、 pcre、pcre-devel 四个软件包
(pcre : 一个Perl库,支持正则表达式): yum install gcc gcc-c++ make pcre pcre-devel -y
- 移动到httpd主目录,并用configure进行配置:
cd /opt/httpd-2.4.2./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-mods-shared=most --with-mpm=worker --disable-cgid --disable-cgi
- 目录不变,执行命令make make install编译安装:
make && make install
- 过滤掉脚本文件中的注释行(#)并重定向到etc目录中,编辑文件,并在文件最前面插入下面的行用以执行:
grep -v "#" /usr/local/apache/bin/apachectl > /etc/init.d/httpd
vim /etc/init.d/httpd
#在文件开头插入下面的行
#!/bin/shchkconfig:2345 85 15
# description:Apache is a World Wide Web server.
- 此时,我们可以设置httpd服务在init3、init5中开机启动,并建立软连接便于管理:
chkconfig --level 35 httpd onln -s /usr/local/apache/conf/httpd.conf /etc/httpd.conf
- 编辑httpd.conf文件,并修改配置:
vim /etc/httpd.confListen:IPV4 ???#这里我们可以监听本机地址ServerName: ???#分别为主机名.域名
现在我们就可以开启服务了!
-
Redhat6.5中服务开启关闭命令service httpd startservice httpd stop如在Redhat7.0以上版本,即为以下命令systemctl start httpd.servicesystemctl stop httpd.servicenetstat -tnl ??//查看监听端口主页存放路径为 ?/usr/local/apache/htdocs/index.html
我们可以在局域网中用同一网段的另一台机器去访问主页,但要注意先关闭服务器的防火墙。
service iptables stopsetenforce 0
使用另一台主机访问主页:
搭建LAMP架构— ?1、手工编译安装Apache
原文地址:http://blog.51cto.com/13625676/2117427