FragranceM 发表于 2018-12-12 12:03:51

centos7.4 编译安装php5.6 (LNMP)

  centos7.4
  前提:
  1、需要提前安装msyql数据库(yum,二进制,自己编译都行)

  2、需要自己编写windows的hosts文件,绑定域名和ip

  3、nginx使用yum安装

  4、php使用5.6源码编译安装
  5、centos7.4 需要配置好EPEL源

  编译安装php5.6 步骤:
  1、安装各种基础库,包
  yum -y install gcc gcc-c++ libxml2 libxml2-devel openssl-devel
  yum install autoconf automake libtool re2c bison -y
  yum install zlib-devel libxml2-devel libjpeg-turbo-develfreetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libmcrypt-devel mhash mcrypt -y
  yum install -y nginx
  2、编译安装libiconv
  wget http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz
  tar -zxvf libiconv-1.14.tar.gz
  cd libiconv-1.14
  ./configure -prefix=/usr/local/libiconv
  make
  如果报错,error: ‘gets’ undeclared here (not in a function)
  则修改 libiconv-1.14/srclib/stdio.in.h中的如下
  _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
  
  为:
  
  #if defined(__GLIBC__) && !defined(__UCLIBC__) && !__GLIBC_PREREQ(2, 16)
   _GL_WARN_ON_USE (gets, "gets is a security hole - use fgets instead");
  #endif
  
  make install
  3、编译安装php5.6
  
  wget http://cn2.php.net/get/php-5.6.33.tar.gz/from/this/mirror
  tar -zxvf php-5.6.33.tar.gz
  cd php-5.6.33
  
  ./configure\
  --prefix=/usr/local/php\
  --with-mysql=mysqlnd \
  --with-mysqli=mysqlnd \
  --with-pdo-mysql=mysqlnd \
  --with-iconv-dir=/usr/local/libiconv \
  --with-freetype-dir\
  --with-jpeg-dir \
  --with-png-dir \
  --with-zlib \
  --with-libxml-dir=/usr \
  --enable-xml \
  --disable-rpath \
  --enable-bcmath \
  --enable-shmop \
  --enable-sysvsem \
  --enable-inline-optimization \
  --with-curl \
  --enable-mbregex \
  --enable-ftp \
  --enable-mbstring \
  --with-mcrypt \
  --with-gd \
  --enable-gd-native-ttf \
  --with-openssl \
  --with-mhash \
  --enable-pcntl \
  --enable-sockets \
  --with-xmlrpc \
  --enable-zip \
  --enable-soap \
  --enable-short-tags \
  --enable-static \
  --with-xsl \
  --with-fpm-user=nginx \
  --with-fpm-group=nginx \
  --enable-ftp \
  --enable-fpm
  
  make
  make install
  4、配置php,php-fpm
  cp php.ini-production /usr/local/php/lib/php.ini
  cd /usr/local/php/etc
  cp php-fpm.conf.default php-fpm.conf
  
  5、启动php服务(FastCGI方式)
  /usr/local/php/sbin/php-fpm
  
  检查php-fpm进程,以及侦听端口
  ps -ef | grep php-fpm
  netstat -tnlp | grep php-fpm
  
  6、配置Nginx,设置测试页index.php,test_mysql.php
  # cat benet3.com.conf
  server {
  listen 80;
  server_name www.benet3.com benet3.com;
  location / {
  root /data/www/www.benet3.com;
  index index.html index.php index.htm;
  }
  location ~* .*\.(php|php5)$ {
  root /data/www/www.benet3.com;
  fastcgi_pass127.0.0.1:9000;
  fastcgi_indexindex.php;
  includefastcgi.conf;
  }
  }
  # ll
  total 12
  -rw-r--r-- 1 root root24 Feb 11 16:33 index.html
  -rw-r--r-- 1 root root21 Feb 11 16:36 index.php
  -rw-r--r-- 1 root root 138 Feb 11 16:54 test_mysql.php
  # cat index.php
  
  # cat test_mysql.php
  
  
  
  win10客户端测试访问
  www.benet3.com
  www.benet3.com/index.php
  www.beent3.com/test_mysql.php
  
  
  
  
  
  
  
  
  
  
  



页: [1]
查看完整版本: centos7.4 编译安装php5.6 (LNMP)