设为首页 收藏本站
查看: 627|回复: 0

[经验分享] centos7.4 编译安装php5.6 (LNMP)

[复制链接]

尚未签到

发表于 2018-12-12 12:03:51 | 显示全部楼层 |阅读模式
  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-devel  freetype-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
  [root@centos7-1 conf.d]# 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;
  }
  }
  [root@centos7-1 www.benet3.com]# ll
  total 12
  -rw-r--r-- 1 root root  24 Feb 11 16:33 index.html
  -rw-r--r-- 1 root root  21 Feb 11 16:36 index.php
  -rw-r--r-- 1 root root 138 Feb 11 16:54 test_mysql.php
  [root@centos7-1 www.benet3.com]# cat index.php
  
  [root@centos7-1 www.benet3.com]# cat test_mysql.php
  
  
  
  win10客户端测试访问
  www.benet3.com
  www.benet3.com/index.php
  www.beent3.com/test_mysql.php
  
  
  
  
  
  
  
  
  
  
  




运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-650524-1-1.html 上篇帖子: 反向教学系列之——PHP入门(一) 下篇帖子: php命名空间+spl_autoload_register实现类的自动加载
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表