侧边栏壁纸
  • 累计撰写 251 篇文章
  • 累计创建 138 个标签
  • 累计收到 16 条评论

目 录CONTENT

文章目录

CentOS下编译安装httpd、php

Sherlock
2017-10-17 / 0 评论 / 0 点赞 / 1150 阅读 / 4629 字 / 编辑
温馨提示:
本文最后更新于 2023-10-09,若内容或图片失效,请留言反馈。部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

最近在和力记易测试机上安装一些本地化的应用,计划整合一下和力记易的访问,安装php和apache时浪费了很多时间,小记一下。

1.安装httpd

1.1 安装&配置

# 先删除之前的版本
yum remove httpd

cd /tmp  
wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.2.34.tar.gz  
tar -xzvf httpd-2.2.34.tar.gz  
cd httpd-2.2.34  
#可以在编译时直接集成编译 ssl,使用 --enable--ssl --enable-mods-shared=most
./configure --prefix=/etc/httpd --sysconfdir=/etc/httpd/conf --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/
make && make install  
whereis httpd  
#httpd: /etc/httpd
\cp /etc/httpd/bin/apachectl /etc/rc.d/init.d/httpd
mkdir -p /usr/local/apache2/conf/  
## 1.如果运行报错缺少 wsgi 模块,编译安装之
cd /tmp  
wget https://codeload.github.com/GrahamDumpleton/mod_wsgi/zip/4.5.20  
mv 4.5.20 mod_wsgi-4.5.20.zip  
unzip mod_wsgi-4.5.20.zip  
cd mod_wsgi-4.5.20  
## 需要有python环境,或者通过 --with-python=/usr/local/bin/python 指定
./configure --with-apxs=/etc/httpd/bin/apxs
make && make install  
# 这样 mod_wsgi.so 会自动安装到 httpd modules 目录
## 2.如果运行报错缺少 mod_rewrite 模块,编译安装之
cd /tmp/httpd-2.2.34/modules/mappers  
/etc/httpd/bin/apxs -i -a -c ./mod_rewrite.c
# 这样 mod_rewrite.so 会自动安装到 httpd modules 目录
## 3.如果运行报错缺少 mod_headers 模块,编译安装之
cd /tmp/httpd-2.2.34/modules/metadata  
/etc/httpd/bin/apxs -i -a -c ./mod_headers.c
# 这样 mod_headers.so 会自动安装到 httpd modules 目录
## 4.如果运行报错缺少 mod_sll 模块,编译安装之
cd /tmp/httpd-2.2.34/modules/ssl/  
/etc/httpd/bin/apxs -i -a -c -D HAVE_OPENSSL=1 -I /usr/include/openssl -lcrypto -lssl -ldl *.c
# 根据需要,修改配置文件
vi /usr/local/apache2/conf/httpd.conf  
# 建议配置文件软连接(总是去 /usr/local/apache2/conf/httpd.conf 这个目录下找配置文件)
rm -rf /usr/local/apache2/conf/httpd.conf  
ln -s /etc/httpd/conf/httpd.conf /usr/local/apache2/conf/httpd.conf  
## 启动httpd
service httpd start  

1.2 开机启动

\cp /etc/httpd/bin/apachectl /etc/rc.d/init.d/httpd
vi /etc/rc.d/init.d/httpd  
# 在 #!/bin/sh后添加

# chkconfig: - 85 15
# description: The Apache HTTP Server is an efficient and extensible  \
#             server implementing the current HTTP standards.

# 保存
chkconfig --add httpd  
chkconfig httpd on  

chown apache:apache /etc/httpd

2.php & apache

2.1 安装 php7 依赖

yum -y install libxslt-devel  

2.2 编译安装 php7

cd /tmp  
wget http://cn2.php.net/distributions/php-7.1.10.tar.gz  
tar -xvf php-7.1.10.tar.gz  
cd php-7.1.10  
./configure --prefix=/usr/local/php  --with-curl  --with-freetype-dir  --with-gd  --with-gettext  --with-iconv-dir  --with-kerberos  --with-libdir=lib64  --with-libxml-dir  --with-mysqli  --with-openssl  --with-pcre-regex  --with-pdo-mysql  --with-pdo-sqlite  --with-pear  --with-png-dir  --with-xmlrpc  --with-xsl  --with-zlib  --enable-fpm  --enable-bcmath  --enable-libxml  --enable-inline-optimization  --enable-gd-native-ttf  --enable-mbregex  --enable-mbstring  --enable-opcache  --enable-pcntl  --enable-shmop  --enable-soap  --enable-sockets  --enable-sysvsem  --enable-xml  --enable-zip  --with-apxs2=/etc/httpd/bin/apxs
make && make install  
# 这样 libphp7.so 会自动安装到 httpd modules 目录
service httpd restart  

2.3 php 配置文件

初始化配置文件

cp /tmp/php-7.1.10/php.ini-development /usr/local/php/lib/php.ini  
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf  
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf  
cp -R /tmp/php-7.1.10/sapi/fpm/php-fpm /etc/init.d/php-fpm  

修改 php-fpm 端口

vi /usr/local/php/etc/php-fpm.d/www.conf  

修改该行即可

listen = 127.0.0.1:9001  

2.4 启动 php-fpm

/etc/init.d/php-fpm
0
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin

评论区