声明:此安装版本为2.2.17,与新版本编译安装有区别,博客还会持续更新
源码编译及安装
1.解包
tar zxf httpd-*.tar.gz -C /usr/src
cd /usr/src/httpd-*
注:*代表版本号
2 . 配置
./configure --prefix=/usr/local/httpd 安装路径
--enable-so 启动动态加载模块支持,使httpd具备进一步扩展功能的能力
--enable-rewrite 启用网页地址重写功能,用于网站优化及目录迁移维护
--enable-charset-lite 启动字符集支持,以便支持使用各种字符集编码的网页
--enable-cgi 启用CGI脚本程序支持,便于扩展网站的应用访问能力
要获取更多配置选项可执行“./configure –help”
3.编译及安装
make && make install
4.优化执行路径
ln -s /usr/local/httpd/bin/* /usr/local/bin
作用:可以在命令行补全命令
5.添加httpd系统服务
cp /usr/local/httpd/bin/apachectl /etc/init.d/httpd
chkconfig --add httpd
chkconfig httpd on
httpd服务器的基本配置
1.配置httpd服务
vim /usr/local/httpd/conf/httpd.conf
......//省略部分内容
ServerName www.leoblog.com
......//省略部分内容
修改完后可以用以下命令检查配置文件语法是否正确
httpd -t 或者
/usr/local/httpd/bin/apachectl -t
2.启动httpd服务
/etc/init.d/httpd start 或者
service httpd start
httpd编译安装默认网站根目录为/user/local/httpd/htdocs
查看web站点的访问情况:
tail /usr/local/httpd/logs/access_log 访问正确日志文件
tail /usr/local/httpd/logs/error_log 访问错误日志文件