**

在ngixn安装好的基础上进行安装php

1,上传软件包(libmcrypt-2.5.7.tar.gz php-5.6.36.tar.gz)

2,安装依赖环境
[[email protected] ~]# yum -y install php-mcrypt libmcrypt libmcrypt-devel autoconf freetype gd libmcrypt libpng libpng-devel libjpeg libxml2 libxml2-devel zlib curl curl-devel re2c bzip2-devel libmcrypt-devel freetype-devel libjpeg-devel

3,先安装 lib包
[[email protected] ~]# tar zxf libmcrypt-2.5.7.tar.gz
[[email protected]~]# cd libmcrypt-2.5.7/
[[email protected] libmcrypt-2.5.7]# ./configure --prefix=/usr/local/libmcrypt && make && make install

4,解压PHP包 进行安装
[email protected] ~]# tar -zxvf php-5.6.36.tar.gz -C /usr/local/src/
预编译:
[[email protected] ~]# cd /usr/local/src/php-5.6.36/
[[email protected] php-5.6.36]# ./configure --prefix=/usr/local/php5.6 --with-mysql=mysqlnd --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-openssl --enable-fpm --enable-sockets --enable-sysvshm --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --with-mhash --with-mcrypt=/usr/local/libmcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/usr/local/php5.6/etc/ --with-bz2 --enable-maintainer-zts

参数解释:
–prefix=/usr/local/php5.6 //安装位置
–with-mysql=mysqlnd //支持mysql
–with-pdo-mysql=mysqlnd //支持pdo模块
–with-mysqli=mysqlnd //支持mysqli模块
注:上面的三选项的作用:数据库与php不在一个服务器上,指定此种方式,安装数据库连接驱动
–with-apxs2 #将php编译为Apache的一个模块进行使用
–enable-mbstring #多字节字符串的支持
–with-curl #支持cURL
–with-gd #支持gd库
–enable-fpm #支持构建fpm
–with-config-file-path #设置配置文件路径
–with-openssl #支持openssl模块
–enable-fpm #支持fpm模式
–enable-sockets #启用socket支持
–enable-sysvshm #启用系统共享内存支持
–enable-mbstring #多字节字串、像我们的中文就是多字节字串
–with-freetype-dir #支持freetype、就要装freetype-devel、跟字体相关的、字体解析工具
–with-jpeg-dir
–with-png-dir
注:上面的二选项的作用:处理jpeg、png图片的、php可以动态生成jpeg图片
–with-zlib #是个压缩库、在互联网传输时用来压缩传输的
–with-libxml-dir=/usr #这个libxml是用来解析xml的、指定/usr下
–enable-xml #支持xml的
–with-mhash #支持mhash
–with-mcrypt=/usr/local/libmcrypt #libmcrypt-devel这个程序包所指定的
–with-config-file-path=/usr/local/php5.6/etc #指定配置文件的存放路径的
–with-config-file-scan-dir=/etc/php.d #配置文件扫描路径
–with-bz2 #支持BZip2
–enable-maintainer-zts
为了支持apache的worker或event这两个MPM,编译时使用了–enable-maintainer-zts选项

5,编译安装
[[email protected] php-5.6.36]# make && make install

6,. 修改fpm配置php-fpm.conf.default文件名称
[[email protected] ~]# cd /usr/local/php5.6/etc/
[[email protected] etc]# cp php-fpm.conf.default php-fpm.conf

7、 修改默认运行账号
修改默认运行用户,组为nginx
[[email protected] etc]# vim php-fpm.conf
user = nginx
group = nginx

.8、 生成php.ini配置文件
[[email protected] ~]# cp /usr/local/src/php-5.6.36/php.ini-production /usr/local/php5.6/etc/php.ini

9、 复制php-fpm启动脚本到init.d
[[email protected] ~]# cp /usr/local/src/php-5.6.36/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

10、 赋予执行权限
[[email protected] ~]# chmod +x /etc/init.d/php-fpm

.11、 添加开机启动
[[email protected] ~]# chkconfig --add php-fpm
[[email protected] ~]# chkconfig php-fpm on

12、 启动服务
[[email protected] ~]# /etc/init.d/php-fpm start
Starting php-fpm done

13、 查看端口监听状态
[[email protected] ~]# netstat -antpu | grep php-fpm
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 7767/php-fpm: maste

15 配置nginx支持index.php 修改配置文件
[[email protected] ~]# vim /usr/local/nginx/conf/nginx.conf
location / {
root html;
index index.php index.html index.htm; #添加index.php
}
#并开启下边的功能,在最下边添加一句话:
location ~ .*.(php|php5)?$
{
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
fastcgi_cache ngx_fcgi_cache;
fastcgi_cache_valid 200 302 1h;
fastcgi_cache_valid 301 1d;
fastcgi_cache_valid any 1m;
fastcgi_cache_min_uses 1;
fastcgi_cache_use_stale error timeout invalid_header http_500;
fastcgi_cache_key http://hosthostrequest_uri;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
######添加这句
}
16. 创建index.php文件
[[email protected] html]# vim index.php

<?php phpinfo(); ?>

测试
http://192.168.100.109/
在ngxin上边安装 php完成

相关文章:

  • 2022-03-08
  • 2021-12-03
  • 2022-02-18
  • 2022-02-16
  • 2022-12-23
  • 2021-12-06
  • 2021-09-30
猜你喜欢
  • 2021-06-06
  • 2022-12-23
  • 2021-10-18
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
  • 2021-08-08
相关资源
相似解决方案