压缩包安装方式
1、下载httpd-2.4.29.tar.gz
2、上传到服务器/usr/local/software
tar -zxvf httpd-2.4.29.tar.gz ./configure --prefix=/usr/local/apache2/ # 设置apache安装目录
若没有安装过Apr,会报错:
checking for APR... no configure: error: APR not found. Please read the documentation.
3、接下来安装apr,首先下载apr-1.6.3.tar.gz
4、上传到服务器/usr/local/software
tar -zxvf apr-1.6.3.tar.gz cd apr-1.6.3 .configure make make install
又会报错:
checking for APR-util... no configure: error: APR-util not found. Please read the documentation.
5、下载apr-util-1.6.1.tar.gz
6、上传到服务器/usr/local/software
tar -zxvf apr-util-1.6.1.tar.gz cd apr-util-1.6.1 ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr
此时还会报错:
xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录 #include <expat.h> ^ 编译中断。 make: *** [xml/apr_xml.lo] 错误 1
7、猜测是可能缺expat的开发库
yum install expat-devel # 中间会让你输入y ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr make # 成功! make install
8、此时再回去安装apache,不仅要指定apr的路径,还要指定apr-util的路径
./configure --prefix=/usr/local/apache2/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
依旧报错,不少人到这里可能已经崩溃了,但这个错误跟前面遇到的类似
checking for pcre-config... false configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
9、下载pcre-8.41.tar.gz
10、上传到服务器/usr/local/software
tar -zxvf pcre-8.41.tar.gz ./configure
又再次报错,我保证这是最后一次了
checking windows.h usability... no checking windows.h presence... no checking for windows.h... no configure: error: You need a C++ compiler for C++ support.
10、安装c++环境
yum install -y gcc gcc-c++ # 错了那么多次,别忘了现在的位置,接下来还是要安装pcre ./configure make make install
11、好了,绕了一大圈,接下来还是要安装apache
cd .. cd apache ./configure --prefix=/usr/local/apache2/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ make make install
好惨啊!最后一步又报错:
/usr/local/apr-util//lib/libaprutil-1.so: undefined reference to `XML_GetErrorCode' /usr/local/apr-util//lib/libaprutil-1.so: undefined reference to `XML_SetEntityDeclHandler' /usr/local/apr-util//lib/libaprutil-1.so: undefined reference to `XML_ParserCre collect2: error: ld returned 1 exit status make[2]: *** [htpasswd] 错误 1 make[2]: Leaving directory `/usr/local/software/apache/support' make[1]: *** [all-recursive] 错误 1 make[1]: Leaving directory `/usr/local/software/apache/support'
这种报错没见过,果断网上搜索一番,答案即是:apr版本太高;
12、于是我下载了apr-util-1.5 http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz
13、上传到服务器/usr/local/software
tar -zxvf apr-util-1.5.2.tar.gz cd apr-util-1.5.2 ./configure --prefix=/usr/local/apr-util-1.5/ --with-apr=/usr/local/apr make make install
14、重复步骤11,唯一不同的地方就是现在配置指定的是:apr-util-1.5,这很重要!!!
cd .. cd apache ./configure --prefix=/usr/local/apache2/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util-1.5/ make # make时间会比较长 make install
完美结尾:
Installing configuration files mkdir /usr/local/apache2/conf mkdir /usr/local/apache2/conf/extra mkdir /usr/local/apache2/conf/original mkdir /usr/local/apache2/conf/original/extra Installing HTML documents mkdir /usr/local/apache2/htdocs Installing error documents mkdir /usr/local/apache2/error Installing icons mkdir /usr/local/apache2/icons mkdir /usr/local/apache2/logs Installing CGIs mkdir /usr/local/apache2/cgi-bin Installing header files mkdir /usr/local/apache2/include Installing build system files mkdir /usr/local/apache2/build Installing man pages and online manual mkdir /usr/local/apache2/man mkdir /usr/local/apache2/man/man1 mkdir /usr/local/apache2/man/man8 mkdir /usr/local/apache2/manual make[1]: Leaving directory `/usr/local/software/apache'
15、进入配置文件位置:/usr/local/apache2/conf
cp httpd.conf httpd.conf.bak # 备份配置文件 vim httpd.conf # 放掉191行的注释,修改为: ServerName [你的IP]:80 :wq
16、启动apache
/usr/local/apache2/bin/apachectl start # 或者 /usr/local/apache2//bin/httpd -k start
关闭防火墙,在浏览器地址栏中输入服务器的ip就会出现网页:It works!
17、关闭apache
ps -ef|grep apache /usr/local/apache2/bin/apachectl stop # 或者 /usr/local/apache2//bin/httpd -k stop # 没错,bin前面就是//
这种原文件安装的方式太过复杂,其实安装apache服务还有另一种方式,不知道跟我前面这种安装有没有冲突,今天也一并试一试。
yum源安装方式
1、yum源安装(需要联网下载)
首先关闭apache服务 yum install httpd # 中间过程中输入:y
Result:
作为依赖被安装:
apr.x86_64 0:1.4.8-3.el7_4.1 apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-67.el7.centos.6 mailcap.noarch 0:2.1.41-2.el7 完毕!
2、yum的安装位置在:/etc/httpd/conf,我进入后备份配置文件先,修改的地方跟之前不一样,在95行,仅供参考
cd /etc/httpd/conf cp httpd.conf httpd.conf.bak # 放掉95行的注释,修改为: ServerName [你的IP]:80 :wq
3、启动服务
systemctl start httpd.service
在浏览器输入ip,出现apache预置的html,完美!!!
4、关闭服务
systemctl stop httpd.service
5、我再次去启动第一种方式安装的httpd
/usr/local/apache2/bin/apachectl start
刷新浏览器赫然出现:It works!,说明两种安装方式没有冲突哈。
更多Apache的相关技术文章,请访问Apache教程栏目进行学习!
以上是linux怎么安装apache服务器的详细内容。更多信息请关注PHP中文网其他相关文章!

linux设备节点是应用程序和设备驱动程序沟通的一个桥梁;设备节点被创建在“/dev”,是连接内核与用户层的枢纽,相当于硬盘的inode一样的东西,记录了硬件设备的位置和信息。设备节点使用户可以与内核进行硬件的沟通,读写设备以及其他的操作。

区别:1、open是UNIX系统调用函数,而fopen是ANSIC标准中的C语言库函数;2、open的移植性没fopen好;3、fopen只能操纵普通正规文件,而open可以操作普通文件、网络套接字等;4、open无缓冲,fopen有缓冲。

端口映射又称端口转发,是指将外部主机的IP地址的端口映射到Intranet中的一台计算机,当用户访问外网IP的这个端口时,服务器自动将请求映射到对应局域网内部的机器上;可以通过使用动态或固定的公共网络IP路由ADSL宽带路由器来实现。

在linux中,eof是自定义终止符,是“END Of File”的缩写;因为是自定义的终止符,所以eof就不是固定的,可以随意的设置别名,linux中按“ctrl+d”就代表eof,eof一般会配合cat命令用于多行文本输出,指文件末尾。

在linux中,可以利用“rpm -qa pcre”命令判断pcre是否安装;rpm命令专门用于管理各项套件,使用该命令后,若结果中出现pcre的版本信息,则表示pcre已经安装,若没有出现版本信息,则表示没有安装pcre。

linux查询mac地址的方法:1、打开系统,在桌面中点击鼠标右键,选择“打开终端”;2、在终端中,执行“ifconfig”命令,查看输出结果,在输出信息第四行中紧跟“ether”单词后的字符串就是mac地址。

手机远程linux工具有:1、JuiceSSH,是一款功能强大的安卓SSH客户端应用,可直接对linux服务进行管理;2、Termius,可以利用手机来连接Linux服务器;3、Termux,一个强大的远程终端工具;4、向日葵远程控制等等。

在linux中,rpc是远程过程调用的意思,是Reomote Procedure Call的缩写,特指一种隐藏了过程调用时实际通信细节的IPC方法;linux中通过RPC可以充分利用非共享内存的多处理器环境,提高系统资源的利用率。


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

AI Hentai Generator
免费生成ai无尽的。

热门文章

热工具

Atom编辑器mac版下载
最流行的的开源编辑器

Dreamweaver Mac版
视觉化网页开发工具

VSCode Windows 64位 下载
微软推出的免费、功能强大的一款IDE编辑器

适用于 Eclipse 的 SAP NetWeaver 服务器适配器
将Eclipse与SAP NetWeaver应用服务器集成。

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能