1、查看当前系统版本

 # cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

2、yum安装依赖的程序包

yum install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel openssl openssl-devel libxslt-devel

3、安装libiconv程序包

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
tar zxf libiconv-1.15.tar.gz
cd libiconv-1.15
./configure --prefix=/usr/local/libiconv
make
make install

4、配置编译安装php-5.6.30.tar.gz

wget http://tw1.php.net/get/php-5.6.30.tar.gz/from/this/mirror

mv mirror php-5.6.30.tar.gz

tar xzvf php-5.6.30.tar.gz

./configure \
 --prefix=/usr/local/php \
 --with-apxs2=/usr/local/apache/bin/apxs \
 --with-mysql=/usr/local/mysql \
 --with-pdo-mysql=/usr/local/mysql \
 --with-pdo-oci=instantclient,/usr,10.2.0.1 \
 --with-oci8=instantclient,/usr/lib/oracle/11.2/client/lib \
 --with-xmlrpc \
 --with-openssl \
 --with-zlib \
 --with-freetype-dir \
 --with-gd \
 --with-jpeg-dir \
 --with-png-dir \
 --with-iconv=/usr/local/libiconv \
 --enable-short-tags \
 --enable-sockets \
 --enable-zend-multibyte \
 --enable-soap \
 --enable-mbstring \
 --enable-static \
 --enable-gd-native-ttf \
 --enable-bcmath \
 --enable-gettext \
 --with-curl \
 --with-xsl \
 --enable-ftp \
 --with-libxml-dir

make
make install

5、拷贝修改配置文件

cp /usr/local/src/php-5.6.30/php.ini-production /usr/local/php/lib/php.ini
apache增加php支持,修改httpd.conf
在 “AddType application/x-gzip .gz .tgz” 下面增加两行
AddType application/x-httpd-php  .php  .php3
AddType application/x-httpd-php-source  .phps
在“DirectoryIndex index.html” 后面增加一个index.php

6、测试php环境是否正常

vi index.php

<?php

phpinfo();

?>

7、测试php连接mysql是否正常

vi index.php

<?php
        //$link=mysql_connect('localhost','username','password');
        $link=mysql_connect('localhost','discuz','discuz') or mysql_error();
        if($link){
                echo "mysql successful connect php!";
        }else{
                echo mysql_error();
        }
?>

8、LNMP编译配置

./configure \
 --prefix=/usr/local/php \
 --with-mysql=/usr/local/mysql \
 --with-pdo-mysql=/usr/local/mysql \
 --with-xmlrpc \
 --with-openssl \
 --with-zlib \
 --with-freetype-dir \
 --with-gd \
 --with-jpeg-dir \
 --with-png-dir \
 --with-iconv=/usr/local/libiconv \
 --enable-fpm \
 --with-fpm-user=nginx \
 --with-fpm-group=nginx \
 --enable-short-tags \
 --enable-sockets \
 --enable-zend-multibyte \
 --enable-soap \
 --enable-mbstring \
 --enable-static \
 --enable-gd-native-ttf \
 --with-curl \
 --with-xsl \
 --enable-ftp \
 --with-libxml-dir=/usr

9、LNMP启动php-fpm

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
/usr/local/php/sbin/php-fpm

10、LNMP修改nginx配置文件

        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
去掉注释,修改include为fastcgi.conf

11、php设置默认编码格式

php.ini 文件里面 default_charset = "GBK"

GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e added ecosystem file for PM2 4 年前
5def40a3 Add host customization support for the NodeJS version 4 年前
Logo

旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。

更多推荐