安装PHP服务
下载PHP文件
安装的目录
/serivce/tools
wget http://cn2.php.net/distributions/php-7.0.12.tar.bz2
安装依赖库
yum -y install wget vim pcre pcre-devel openssl openssl-devel libicu-devel gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel ncurses ncurses-devel curl curl-devel krb5-devel libidn libidn-devel openldap openldap-devel nss_ldap jemalloc-devel cmake boost-devel bison automake libevent libevent-devel gd gd-devel libtool* libmcrypt libmcrypt-devel mcrypt mhash libxslt libxslt-devel readline readline-devel gmp gmp-devel libcurl libcurl-devel openjpeg-devel
进行编译安装
./configure --prefix=/service/application/php
–with-config-file-path=/usr/local/php/etc
–enable-fpm
–with-fpm-user=nginx
–with-fpm-group=nginx
–enable-mysqlnd
–with-mysqli=mysqlnd
–with-pdo-mysql=mysqlnd
–enable-mysqlnd-compression-support
–with-iconv-dir
–with-freetype-dir
–with-jpeg-dir
–with-png-dir
–with-zlib
–with-libxml-dir
–enable-xml
–disable-rpath
–enable-bcmath
–enable-shmop
–enable-sysvsem
–enable-inline-optimization
–with-curl
–enable-mbregex
–enable-mbstring
–enable-intl
–with-mcrypt
–with-libmbfl
–enable-ftp
–with-gd
–enable-gd-jis-conv
–enable-gd-native-ttf
–with-openssl
–with-mhash
–enable-pcntl
–enable-sockets
–with-xmlrpc
–enable-zip
–enable-soap
–with-gettext
–disable-fileinfo
–enable-opcache
–with-pear
–enable-maintainer-zts
–without-gdbm
如果遇到 安装mcrypt错误:No package php-mcrypt available.
执行
- yum install epel-release //扩展包更新包
- yum update //更新yum源
- yum install libmcrypt libmcrypt-devel mcrypt mhash 就ok了
重新执行编译安装
成功后显示
Thank you for using PHP.
表示安装成功.
执行
make && make install
这个命令执行的时间比较长,需等待…
安装成功之后进行,相关的配置
cp php.ini-development /service/application/php/etc/php.ini
cp /service/application/php/etc/php-fpm.conf.default /service/application/php/etc/php-fpm.conf
cp /service/application/php/etc/php-fpm.d/www.conf.default /service/application/php/etc/php-fpm.d/www.conf
安装成功后查看版本信息
/service/application/php/bin/php -v
PHP 7.0.12 (cli) (built: Jan 13 2019 03:39:05) ( ZTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
到此PHP安装成功.
配置Nginx PHP模块
vim /server/application/nginx/conf/nginx.conf
添加一下代码
# PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI协议默认配置.
# Fastcgi服务器和程序(PHP,Python)沟通的协议.
location ~ \.php$ {
#根目录
root html
# 设置监听端口
fastcgi_pass 127.0.0.1:9000;
# 设置nginx的默认首页文件(上面已经设置过了,可以删除)
fastcgi_index index.php;
# 设置脚本文件请求的路径
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# 引入fastcgi的配置文件
include fastcgi_params;
}
}
添加PHP测试代码到根目录 html 中
<?php
phpinfo();
?>
配置成功之后 重启服务器
/service/application/nginx/sbin/nginx -s reload
打开浏览器 输入 http://10.211.55.10/index.php
显示图片
至此, 第三篇,已成功完成!