httpd 的坑

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
云数据库 RDS PostgreSQL,集群系列 2核4GB
简介: Httpd服务器的坑在/etc/httpd/conf/httpd.conf中的配置信息, 有时注释到的内容仍然会生效配置Auth时, 允许htpasswd规定的文件中的所有的用户, Require valid-uesr, 允许特定的用户Require user user1 user2 user3 .

Httpd服务器的坑

  1. 在/etc/httpd/conf/httpd.conf中的配置信息, 有时注释到的内容仍然会生效
  2. 配置Auth时, 允许htpasswd规定的文件中的所有的用户, Require valid-uesr, 允许特定的用户Require user user1 user2 user3 ...
  3. 允许组, Require group group1 group2

在CentOS6中安装httpd2.4

1. 前提条件:

    - Development tools<br>
    - Server Platform tools<br>
    - apr-1.5+<br>
    - apr-util-1.5+<br>
    - httpd-2.4<br>
    - expat-devel<br>
    - openssl-devel<br>
    - prec-devel<br>
    - httpd2.2(需要其httpd2.2的服务配置, 提供httpd2.4服务配置模板)

2. 操作:

    1. 解压apr之后, .configure --prefix=/usr/local/apr; make && make install
    2. 解压apr-util之后, .configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr; make && make install
    3. 解压httpd2.4, 
    
    ./configure --prefix=/usr/local/httpd24 --sysconfdir=/etc/httpd24 --enable-so  --enable-ssl --enable-cgi  --enable-rewrite  --with-zlib  --with-pcre=/usr/local/pcre  --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util  --enable-modules=most  --enable-mpms-shared=all --with-mpm=event
    
    4. 复制脚本, cp /etc/rc.d/init.d/httpd /etc/rc.d/init.d/httpd24<br>
        **注意**:单纯的复制服务脚本是不行的, 我们还要根据具体的情况进行修改
    5. 添加服务脚本, chkconfig --add httpd24
    6. 启动httpd, service httpd start
    7. 导出man, 库文件(.so), 头文件, 系统的环境变量
    8. 查看/var/run/httpd/httpd.pid的内容, 启动httpd服务会以该文件中定义的pid进行运行

    9. 加载相应的模块
        proxy_module和fcgi有关的
    10. 关闭正向代理

CentOS6上编译安装php(先安装apr, apr-util, httpd, mariab, zlib2-devel, libmcrypt-devel, libxml2-devel, httpd-devel)

1. 解压php包
2. 命令参数 

./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-openssl --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=/usr/local/httpd24/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2 --enable-maintainer-zts

3. make && make install

4. 此时会在/etc/httpd24/httpd.conf中多出LoadModule php的信息

5. 为了能让httpd解析php文件, 在配置文件中添加

AddType application/x-httpd-php .php

AddType application/x-httpd-ph-source .phps

Directory Index index.php index.html

6. 我们编译安装的httpd的docroot是在/usr/localhttpd24/htdoc中, 在这里index.php进行测试即可

7. 为了加开运行, 编译安装xcache

解压

进入到解压目录

/usr/local/php/bin/phpize: 用于生成configure文件

./configure --enable-xcache --enable-xcache-coverager --enable-xcache-optimizer --with-php-config=/usr/local/php/bin/php-config

make && make install

创建/etc/php.d文件夹,将xcache.ini配置文件复制到此文件,以便php读取加载。



8. 这里使用的php安装时编译在httpd中(成为httpd的一个模块的, 所以配置时 需要指明httpd的相关位置), 而安装采用fpm则不需要, 但是因为php与mysql有关, 所以还是需要mysql的位置的配置信息

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
4月前
|
弹性计算 运维 Shell
一键编译安装Httpd-2.4.53
【4月更文挑战第30天】
49 1
|
Apache 开发工具 网络安全
|
网络安全
httpd服务的配置
httpd服务的配置
289 0
|
机器学习/深度学习 Shell Apache
httpd.conf 配置
# # This is the main Apache server configuration file. It contains the # configuration directives that give the server its instructions.
1053 0
|
Web App开发 应用服务中间件 PHP
|
Web App开发 监控 测试技术