网站服务器有两种安装方式 源码安装------yum 安装

如果没有安装其他依赖先安装依赖

yum install gcc gcc-c++ autoconf automake

yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel (安装依赖zlib、openssl和pcre)

作者:想念-忘记了 来源:CSDN 原文:https://blog.csdn.net/dannyiscoder/article/details/78455909 版权声明:本文为博主原创文章,转载请附上博文链接!

第一种源码安装,去apache官方网站下载 http://httpd.apache.org/ -rw-r--r--. 1 root root 9177278 Jan 10 01:00 httpd-2.4.37.tar.gz

解压软件包---安装装解压工具 [root@localhost ~]# yum -y install unzip [root@localhost ~]# yum -y install bzip2 解压软件包 [root@localhost ~]# tar -xf httpd-2.4.37.tar.gz 检查编译环境 [root@localhost 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 查询依赖包是否安半 [root@localhost 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 查看安装目录 [root@localhost 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安装该库,安装完再次编译,果然可以 查看安装目录 [root@localhost 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/ 注意复制过去的文件夹要改名 [root@localhost ~]# cp -rf apr-1.6.5 httpd-2.4.37/srclib/apr [root@localhost ~]# 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

启动报错 [root@ServerWEB 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 安装 一键安装 [root@localhost ~]# yum -y install httpd

启动服务 [root@localhost ~]# systemctl start httpd 查看服务是否启动----80端口 [root@localhost ~]# netstat -lnt

打开服务器地址---安装成功

yum安装的网页目录---配置文件目录 /var/www/html /etc/httpd/conf/httpd.conf

挂个网站上去