网站服务器有两种安装方式
源码安装 ------yum 安装
第一种源码安装, 去 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
检查编译环境
./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
- 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
挂个网站上去
来源: http://www.bubuko.com/infodetail-2916064.html