源码安装Apache

安装需要的依赖

yum -y install gcc autoconf automake make pcre pcre-devel openssl openssl-devel

#pcre是正则表达式库
#openssl是安全通信的库

安装apr和apr-until

#apr是Apache可移植运行时
#apr-until是Apache可移植运行时实用程序库

wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.gz
tar xf apr-1.7.0.tar.gz
tar xf apr-util-1.6.1.tar.gz
cd apr-1.7.0
./configure
make && make install
cd ..
cd apr-util-1.6.1
./configure --with-apr=/usr/local/apr/
make && make install
cd ..

安装Apache服务和模块

wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.41.tar.gz
tar xf httpd-2.4.41.tar.gz
cd httpd-2.4.41
./configure --prefix=/usr/local/apache2 --enable-so --enable-ssl --enable-rewrite --with-mpm=worker --with-suexec-bin --with-apr=/usr/local/apr/
make && make install
vim /usr/local/apache2/conf/httpd.conf #Apache配置文件
/usr/local/apache2/bin/apachectl start #启动Apache服务
/usr/local/apache2/bin/apachectl stop #停止
选项 描述
--prefix 指定 Apache httpd 程序的安装主目录
--enable-so 开启模块化功能,支持DSO(动态共享对象)
--enbale-ssl 支持 SSL 加密
--enable-rewrite 支持地址重写
--with-mpm 设置 Apache httpd 工作模式
--with-suexec-bin 支持 SUID、SGID
--with-apr 指定 apr 程序的绝对路径

将其设置为开机启动

mv /root/httpd-2.4.41/build/rpm/httpd.init /etc/rc.d/init.d/httpd   #从源码包移动脚本到启动目录
vim /etc/rc.d/init.d/httpd #修改以下内容
httpd=${HTTPD-/usr/local/apache2/bin/httpd}
pidfile=${PIDFILE-/usr/local/apache2/logs/${prog}.pid}
CONFFILE=/usr/local/apache2/conf
#在/etc/rc.d/init.d目录下运行,以下命令
chkconfig --add httpd
chkconfig --level 2345 httpd on #设置为开机启动
chkconfig --list #可以看到httpd已经添加到开机启动,且2345为on

源码安装PHP

安装依赖

yum -y install libxml2 libxml2-devel curl-devel libjpeg-devel libpng-devel freetype-devel

安装PHP和所需模块

wget https://www.php.net/distributions/php-7.3.12.tar.gz
tar xf php-7.3.12.tar.gz
cd php-7.3.12
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache2/bin/apxs --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-libxml-dir --with-curl --with-gd --with-openssl --enable-sockets --with-pear --enable-exif --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd
make && make install

参数解释:https://blog.csdn.net/niluchen/article/details/41513217

如果PHP不解析,用以下方法

#在apache配置文件中添加以下信息,然后重启apache
AddType application/x-httpd-php .php
DirectoryIndex index.php index.html

Centos7源码安装Apache和PHP的更多相关文章

  1. centos7源码安装Apache及Tomcat

    源码安装Apache (1) 一.通过 https://apr.apache.org/  下载 APR 和 APR-util 通过 http://httpd.apache.org/download.c ...

  2. 烂泥:源码安装apache

    本文由秀依林枫提供友情赞助,首发于烂泥行天下. 最近要开始学习nagios监控方面的知识了,但是nagios与apache结合的比较紧密,所以本篇文章就先把apache的源码安装学习下. 我们现在分以 ...

  3. 源码安装apache

    目标:源码安装apache 依赖包:apr.apr-util和pcre.其中pcre正则库要先安装,apr和apr-util(已解压)可以复制到apache下的资源库srclib下. 安装pcre: ...

  4. linux下源码安装apache服务

    1.搭建静态网站是,我们只需要搭建apache服务即可满足要求. 例如:如果我再客户端游览器输入地址,他会找到192.168.1.100这个服务器,然后根据端口会找到apache服务器.apache他 ...

  5. centos7源码安装Python3的前提条件

    centos7源码安装Python3的前提条件: # yum -y install openssl-devel bzip2-devel expat-devel gdbm-devel readline- ...

  6. Linux 源码安装apache 与常见错误解决

    文档原位置 一.编译安装apache 1.解决依赖关系 httpd-2.4.4需要较新版本的apr和apr-util,因此需要事先对其进行升级. 升级方式有两种,一种是通过源代码编译安装,一种是直接升 ...

  7. 源码安装Apache,报错:Cannot use an external APR with the bundled APR-util

    一般在第一次源码安装是没有问题的,在版本变化情况下在次源码安装可能会遇到此问题: apache2.0.x与apache2.2.x在apr有很大区别,前者为依赖公用apr,后者依赖于自身的apr.一般前 ...

  8. centos7源码安装mysql5.7.19

    centos7源码包安装mysql5.7 5.7.20安装方法和5.7.19的一样. 1.安装前准备 清空环境.安装相应的软件包 1>关闭防火墙和SELinux 2>配置yum源(阿里云, ...

  9. Centos7源码安装mysql及读写分离,互为主从

       Linux服务器 -源码安装mysql 及读写分离,互为主从   一.环境介绍: Linux版本: CentOS 7 64位 mysq版本: mysql-5.6.26 这是我安装时所使用的版本, ...

随机推荐

  1. Python模块之目录

     1.加密算法有关 hmac模块 hashlib模块 2.进程有关 multiprocessing模块 3.线程有关 threading模块 4.协程有关 asyncio模块 5.系统命令调用 sub ...

  2. Appium Python测试环境搭建

    详细参考地址:https://www.cnblogs.com/amoyshmily/p/10500687.html 1,Appium安装:https://github.com/appium/appiu ...

  3. 019_linuxC++之_函数模板引入

    (一)首先我们来看非模板程序,函数只是输入不一样的变量就需要构件很多个不一样的函数,那么这样很麻烦,则引入函数模板 int& max(int& a, int& b) { ret ...

  4. springboot热部署如果不行

    如果热部署不行先看一眼 Project——>Build Automatically 看这个有没有打对勾,这是热部署的依赖

  5. 理解TCP三次握手和四次挥手

    TCP相关知识 TCP是面向连接的传输层协议,它提供可靠交付的.全双工的.面向字节流的点对点服务.HTTP协议便是基于TCP协议实现的.(虽然作为应用层协议,HTTP协议并没有明确要求必须使用TCP协 ...

  6. codeforces#1183F. Topforces Strikes Back(数论)

    题目链接: http://codeforces.com/contest/1183/problem/F 题意: 给出n个数,找出最多三个互不整除的数,取最大的和 数据范围: $1 \le n \le 2 ...

  7. STL漫谈

    从现在开始,想写一个关于STL工具的各种tip类的东西,记录下那些细节,以免以后使用STL工具时出错. 1.关于map,如果需要第一个键值需要放进一个结构体,那么结构体是需要写好其自定义的排序规则的, ...

  8. 【洛谷4542】 [ZJOI2011]营救皮卡丘(最小费用最大流)

    传送门 洛谷 Solution 这是一道神仙题! 考虑这个东西是个啥. emmm,如果两个点要到达,一定不能经过比他们大的. 所以Floyd搞定两点距离然后费用流跑一遍就是答案了! 代码实现 /* m ...

  9. Go Iris 中间件

    Iris 中间件 当我们在 iris 中讨论中间件时,我们讨论的是在HTTP请求生命周期中在主处理程序代码之前和/或之后的运行代码. 实现中间件功能,有下面这样两种方式: 方式一: 我们可以通过按顺序 ...

  10. CDN之Web Cache

    1. Cache 的工作方式 Web Cache 作为一种网页缓存技术,可以在用户访问网站服务器的任何一个中间网元上实现.根据 HTTP 协议的定义,在一次网页访问中,用户从客户端发出请求到网站服务器 ...