centos6怎么安装php模块插图

本文操作环境:centos 6系统、php 5.6、thinkpad t480电脑。

下面是centos6.5编译安装php 5.6(apache模块)的方法步骤:

一、环境准备

1、下载php源码包

# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
# tar -xf php-5.6.30.tar.gz -C /usr/local/src/

2、创建www用户

# groupadd www
# useradd -g www -s /sbin/nologin -M www

3、安装epel源

# yum install epel-release -y

4、安装依赖包

# yum install gcc gcc-c++ make zlib zlib-devel libxml2 libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv libiconv-devel freetype-devel libpng-devel gd bison bison-devel readline-devel gd-devel libicu-devel libedit-devel libcurl-devel sqlite-devel jemalloc jemalloc-devel libxslt-devel libmcrypt libmcrypt-devel mhash mhash-devel mcrypt pcre pcre-devel bzip2 bzip2-devel curl curl-devel openssl-devel openldap openldap-devel -y

二、编译安装

./configure --prefix=/usr/local/php \
--with-config-file-path=/etc/php/ \
--with-apxs2=/usr/local/httpd24/bin/apxs \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-gd \
--with-iconv \
--with-mcrypt \
--with-mhash \
--with-openssl \
--with-curl \
--with-zlib \
--with-bz2 \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-xsl \
--with-pcre-dir \
--with-readline \
--with-gettext \
--with-xmlrpc \
--with-libxml-dir \
--enable-shared \
--enable-bcmath \
--enable-soap \
--enable-mbregex \
--enable-pcntl \
--enable-opcache \
--enable-calendar \
--enable-shmop \
--enable-xml \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-sockets \
--enable-ftp \
--enable-zip \
--enable-gd-jis-conv \
--enable-exif \
--enable-mbstring \
--enable-inline-optimization \
--disable-debug \
--disable-rpath
# make && make install

三、配置服务

# mkdir /etc/php
# cp php.ini-development /etc/php/php.ini

添加环境变量PATH

# vim /etc/profile
PATH=$PATH:/usr/local/php/bin    
export PATH  
# source /etc/profile

查看php配置文件路径

# /usr/local/php/bin/php --ini

查看php编译参数

# /usr/local/php/bin/php-config

四、配置apache支持php

修改Apache的配置文件httpd.conf
DirectoryIndex index.html index.php #添加index.php
找到:
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
添加如下内容
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php
检查LoadModule php5_module modules/libphp5.so 是否已经添加 libphp5.so文件是否存在
编写测试文件index.php内容如下,放到Apache的默认的Web站点目录DocumentRoot #默认路径/var/www/html

<?php
phpinfo();
?>

启动Apache服务,若启动失败,查看配置文件httpd.conf,找到错误日志error.log,针对问题修改。

service httpd restart

用浏览器访问http://IP/,可以查看到PHP配置就表示你成功了

推荐学习:php培训

以上就是centos6怎么安装php模块的详细内容,更多请关注亿码酷站其它相关文章!


centos6怎么安装php模块
—–文章转载自PHP中文网如有侵权请联系ymkuzhan@126.com删除

下载声明:
  • 本站资源如无特殊说明默认解压密码为www.ymkuzhan.com建议使用WinRAR解压;
  • 本站资源来源于用户分享、互换、购买以及网络收集等渠道,本站不提供任何技术服务及有偿服务,资源仅提供给大家学习研究请勿作它用。
  • 赞助本站仅为维持服务器日常运行并非购买程序及源码费用因此不提供任何技术支持,如果你喜欢该程序,请购买正版!
  • 版权声明:
  • 下载本站资源学习研究的默认同意本站【版权声明】若本站提供的资源侵犯到你的权益,请提交版权证明文件至邮箱ymkuzhan#126.com(将#替换为@)站长将会在三个工作日内为您删除。
  • 免责声明:
  • 您好,本站所有资源(包括但不限于:源码、素材、工具、字体、图像、模板等)均为用户分享、互换、购买以及网络收集而来,并未取得原始权利人授权,因此禁止一切商用行为,仅可用于个人研究学习使用。请务必于下载后24小时内彻底删除,一切因下载人使用所引起的法律相关责任,包括但不限于:侵权,索赔,法律责任,刑事责任等相关责任,全部由下载人/使用人,全部承担。以上说明,一经发布视为您已全部阅读,理解、同意以上内容,如对以上内容持有异议,请勿下载,谢谢配合!支持正版,人人有责,如不慎对您的合法权益构成侵犯,请联系我们对相应内容进行删除,谢谢!