apache----httpd服务安装--网站服务器
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了apache----httpd服务安装--网站服务器相关的知识,希望对你有一定的参考价值。
网站服务器有两种安装方式
源码安装------yum 安装
第一种源码安装,去apache官方网站下载
http://httpd.apache.org/
-rw-r--r--. 1 root root 9177278 Jan 10 01:00 httpd-2.4.37.tar.gz
解压软件包---安装装解压工具
[[email protected] ~]# yum -y install unzip
[[email protected] ~]# yum -y install bzip2
解压软件包
[[email protected] ~]# tar -xf httpd-2.4.37.tar.gz
检查编译环境
[[email protected] httpd-2.4.37]# ./configure
检查编译环境报错
configure: error: APR not found. Please read the documentation.
apache依赖apr、apr-util和pcre包,先检查apr、apr-util和pcre是否存在
使用rpm -qa 查询依赖包是否安半
[[email protected] httpd-2.4.37]# rpm -qa apr
#下载apr包
wget http://mirror.bit.edu.cn/apache/apr/apr-1.6.5.tar.bz2
检查编译环境
./configure -- prefix=/usr/local/apr
编译安装
make && make install
查看安装目录
[[email protected] apr-util-1.6.1]# ll /usr/local/apr
total 0
drwxr-xr-x. 2 root root 26 Jan 10 01:15 bin
drwxr-xr-x. 2 root root 148 Jan 10 01:15 build-1
drwxr-xr-x. 3 root root 19 Jan 10 01:15 include
drwxr-xr-x. 3 root root 140 Jan 10 01:15 lib
rpm -qa apr-util
#下载apr-util包
wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.6.1.tar.bz2
yum install expat-devel -y #安装一个apr-util包需要的依赖
检查编译环境
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
编译安装
make && make install
安装时报错
xml/apr_xml.c:35:19: fatal error: expat.h: No such file or directory
少了expat库,yum install expat-devel安装该库,安装完再次编译,果然可以
查看安装目录
[[email protected] apr-util-1.6.1]# ll /usr/local/apr-util/
total 0
drwxr-xr-x. 2 root root 26 Jan 10 01:19 bin
drwxr-xr-x. 3 root root 19 Jan 10 01:19 include
drwxr-xr-x. 3 root root 164 Jan 10 01:19 lib
rpm -qa pcre
#下载pcre包
wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.bz2
解压
tar -xf pcre-8.42.tar.bz2
进入目录
cd pcre-8.42/
检查编译环境
./configure --prefix=/usr/local/pcre
编译安装
make && make install
yum #安装pcre-devel包
yum install pcre-devel -y
前面下载好
#安装httpd
cd ..
tar -xf httpd-2.4.37.tar.bz2
+++
cd httpd-2.4.37/
注意复制过去的文件夹要改名
[[email protected] ~]# cp -rf apr-1.6.5 httpd-2.4.37/srclib/apr
[[email protected] ~]# cp -rf apr-util-1.6.1 httpd-2.4.37/srclib/apr-util
检查编译环境
./configure --prefix=/usr/local/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-rewrite --enable-so --with-pcre=/usr/local/pcre1 --with-included-apr
编译安装
make && make install
查看安装目录
/usr/local/httpd
#进入到httpd/bin目录下 启动
./apachectl -k start
启动报错
[[email protected] bin]# ./apachectl -k start
AH00558: httpd: Could not reliably determine the server‘s fully qualified domain name, using fe80::734c:a1fd:fbba:d17c. Set the ‘ServerName‘ directive globally to suppress this message
修改/usr/local/httpd/conf/httpd.conf
#ServerName 10.1.3.231:80
netstat -antup | grep 80
./apachectl -k stop
systemctl stop firewalld
网页存储目录
/usr/local/httpd/htdocs/index.html
上传了一个测试网站,效果还不错。
第二种安装方式yum 安装
一键安装
[[email protected] ~]# yum -y install httpd
启动服务
[[email protected] ~]# systemctl start httpd
查看服务是否启动----80端口
[[email protected] ~]# netstat -lnt
打开服务器地址---安装成功
yum安装的网页目录---配置文件目录
/var/www/html
/etc/httpd/conf/httpd.conf
挂个网站上去
以上是关于apache----httpd服务安装--网站服务器的主要内容,如果未能解决你的问题,请参考以下文章