您好,欢迎访问一九零五行业门户网

centos6怎么安装php模块

centos6安装php模块的方法:1、准备环境,安装依赖包;2、编译安装,添加环境变量;3、配置apache支持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/profilepath=$path:/usr/local/php/binexport 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
<?phpphpinfo();?>
启动apache服务,若启动失败,查看配置文件httpd.conf,找到错误日志error.log,针对问题修改。
service httpd restart
用浏览器访问http://ip/,可以查看到php配置就表示你成功了
推荐学习:php培训
以上就是centos6怎么安装php模块的详细内容。
其它类似信息

推荐信息