234cfds1 发表于 2018-12-18 12:40:59

LNMP—PHP的编译安装

      按照LNMP的顺序,我们应该先编译MySQL,再编译PHP,最后编译Nginx,因为LNMP的MySQL和LAMP的MySQL编译一样,所以我们就略过,不再阐述了具体可以看这个链接http://286577399.blog.运维网.com/10467610/1671029,
      另外补充一个MySQL的源码网站:http://mirrors.sohu.com/mysql/
      还需要注意一个问题,那就是我们单独配置LNMP的思路是不对的,我们的思路应该也必须是LAMP+Nginx,即LANMP;而我们想当然会认为LNMP+Apache也行,但是这样的的思路是错误的,这一点需要注意一下。

      下面直接进入LNMP的PHP编译:
  # cd /usr/local/src
      下载
  # wget http://cn2.php.net/distributions/php-5.6.12.tar.bz2
      解压
  # tar jxvf php-5.6.12.tar.bz2
      创建用户
  # useradd -s /sbin/nologin php-fpm
      进入php目录编译
  # cd php-5.6.12
  # ./configure --prefix=/usr/local/php2 --with-config-file-path=/usr/local/php2/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --enable-zend-multibyte --disable-ipv6 --with-pear --with-curl --with-openssl
  
我们应该注意的问题:      在上面编译安装过程中,有两行用“红字”标示出来,如下所示:
     --prefix=/usr/local/php2 --with-config-file-path=/usr/local/php2/etc
  因为我们是在LAMP的基础上,进行LNMP的编译安装,LAMP中已经编译过PHP了,所以我们要对LNMP中的PHP的目录做一下更改,及上面编译命令中的绿字部分,有利于我们区分开来,对于此点更改下文中均会以“绿字”标示出来。
  安装过程中出现的问题解决方法:
  问题一:
      configure: error: jpeglib.h not found.
      # yum list |grep jpeg
      # yum install -y libjpeg-turbo-devel
      重新编译安装
  问题二:
      configure: error: mcrypt.h not found. Please reinstall libmcrypt.
      需安装epel

      # rpm -ivh 'http://www.lishiming.net/data/attachment/forum/epel-release-6-8_32.noarch.rpm'
      # yum list |grep mcry
      # yum install -y libmcrypt-devel
      重新编译安装

  # make && make install

  # echo $?
  0
  制作php全局配置文件
  # cp php.ini-production /usr/local/php2/etc/php.ini
  制作启动脚本
  # cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
  授予启动脚本权限
  # chmod 755 /etc/init.d/php-fpm
  加入启动进程
  # chkconfig --add php-fpm
  开机自动启动
  # chkconfig php-fpm on
  设置php-fpm的配置文件
  # cd /usr/local/php2/etc
  # mvphp-fpm.conf.defaultphp-fpm.conf
  检查有无语法错误
  # /usr/local/php2/sbin/php-fpm -t
  启动服务
  # service php-fpm start
  查看进程
  
  # ps aux |grep php-fpm
  监听端口
  
  # netstat -lnp |grep php-fpm
  




页: [1]
查看完整版本: LNMP—PHP的编译安装