apache+PHP编译安装精华篇,踩坑总结

1、apache编译安装

辅助软件apr1.6.3、apr-util1.6.1、pcre8.41,可以官方网站下载

安装apr-1.63设置目录权限为777

bash ./configure --prefix=/usr/local/apache/apr

make  && make install

可能会提示需要安装gcc,yum install gcc


安装apr-util1.6.1设置目录权限为777

bash ./configure --prefix=/usr/local/apache/apr-util --with-apr=/usr/local/apache/apr

make && make install

可能会提示需要安装yum install expat-devel

 

安装pcre8.41

bash ./configure --prefix=/usr/local/apache/pcre

make && make install

yum -y install gcc gcc-c++

 

 

Apache:httpd-2.4.33 设置目录权限为777

安装目录:/usr/local/apache/apache2

bash ./configure --prefix=/usr/local/apache/apache2 --with-apr=/usr/local/apache/apr --with-apr-util=/usr/local/apache/apr-util/ --with-pcre=/usr/local/apache/pcre/

配置http.conf,监听88端口,开启路由rewrite

如下:

Listen 88

LoadModule rewrite_module modules/mod_rewrite.so

 配置项目地址和服务器地址

<VirtualHost *:88>

    Serveradmin admin@admin.com

    ServerName localhost

    DocumentRoot /usr/local/phpApp/ms/public

    <Directory "/usr/local/phpApp/ms/public">

          Options FollowSymLinks ExecCGI

          AllowOverride All

          #Require all denied

          Require all granted

    </Directory>

    ErrorLog /var/appLogs/phpApp/rentServiceGoods/error.log

    CustomLog /var/appLogs/phpApp/rentServiceGoods/access.log combined

</VirtualHost>

如果后面安装php没有生效,在Apache里加入:AddType application/x-httpd-php .php

 

2、Php编译安装

下载版本php7.1.0安装包,目录权限777, 放到目录/usr/local/php/

进入安装包,安装扩展

bash ./configure --prefix=/usr/local/php/php7 \

 --with-apxs2=/usr/local/apache/apache2/bin/apxs \

 --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

 

如有错误:yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel openssl openssl-devel curl-devel libxslt-devel,安装相应的扩展

如果还有错:将apache里的这个文件apache2/bin/apxs 第一行修改为 #! /usr/bin/perl -w

 

安装完成后 将安装包下的php.in-production(生成环境)或php.in-development(开发环境)文件考到php配置文件路径

/usr/local/php/php7/lib,修改为php.ini


3、php-redis扩展安装

下载php-reids扩展4.0.2

通过phpize安装

/usr/local/php/php7/bin/phpize

bash ./configure --with-php-config=/usr/local/php/php7/bin/php-config

安装成功后再php.ini里面加入 extension=redis.so  

 

重启apache

文章来源: apache+PHP编译安装精华篇,踩坑总结

人吐槽 人点赞

猜你喜欢

发表评论

用户名: 密码:
验证码: 匿名发表

你可以使用这些语言

查看评论:apache+PHP编译安装精华篇,踩坑总结