LNMP的安装记录

Linux

可以使用虚拟机挂载使用Centos、Debian、Ubunto等的一些镜像,有条件的话可以使用阿里云的系统,本文使用的就是阿里云的 x86_64 x86_64 x86_64 GNU/Linux系统,虚拟机安装不做详解,可以自行搜索,或者有疑问可以提出一起探讨

安装PHP

1、下载解压
wget http://cn2.php.net/distributions/php-7.2.8.tar.gz
tar -xzf php-7.2.8.tar.gz
  • 错误提示
ERROR: The certificate of ‘www.python.org’ is not trusted.
ERROR: The certificate of ‘www.python.org’ hasn't got a known issuer.
  • 解决方案

–no-check-certificate

wget --no-check-certificate https://www.python.org/ftp/python/3.6.8/Python-3.6.8.tar.xz
2、编译安装
cd php-7.2.8
./configure --prefix=/usr/local/php7280 --with-curl  --with-jpeg-dir --with-freetype-dir --with-gd --with-gettext --with-iconv-dir --with-kerberos --with-libxml-dir --with-mysqli=mysqlnd --with-openssl --with-pcre-regex --with-pdo-mysql=mysqlnd --with-pdo-sqlite --with-pear --with-png-dir --with-xmlrpc --with-xsl --with-zlib --with-pdo-mysql --with-fpm-user=nginx --with-fpm-group=nginx --enable-fpm --enable-bcmath --enable-libxml --enable-inline-optimization --enable-gd-native-ttf --enable-mbregex --enable-mbstring --enable-opcache --enable-pcntl --enable-shmop --enable-soap  --enable-sockets --enable-sysvsem --enable-xml --enable-zip --enable-mysqlnd --enable-maintainer-zts

其中 –prefix=/usr/local/php7280 编译在此目录下,方便寻找

  • 遇到的问题
configure: error: Cannot find OpenSSL's <evp.h>
  • 解决方案

网上方法基本都是说安装openssl或者是说安装mysqlnd扩展报错的,需要在配置文件configure加

export PHP_OPENSSL_DIR=yes
./configure --with-php-config=/home/php/bin/php-config --enable-mysqlnd

我这边实际上是OpenSSL版本的问题

(sudo) yum downgrade openssl //降级
(sudo) yum install openssl-devel

其他遇到的的问题复制百度寻找答案即可基本上是服务器缺少对应的依赖

configure: error: libxml2 not found. Please check your libxml2 installation

解决

yum install libxml2-devel

然后执行如下命令

make && make install

以上php就安装好了,接下来进行配置

3、配置
  • 在编译执行configure的地方执行如下命令
cp php.ini-production /usr/local/php7/etc/php.inicd /usr/local/php7/etc/    //查看是否有了 php.ini
  • 在接着执行如下命令
cp php-fpm.conf.default php-fpm.conf
  • 在进入这个目录 cd php-fpm.d/ 在继续执行如下命令
cp www.conf.default www.conf
  • 最后在这个目录 /usr/local/php7/sbin 执行如下命令启动php
./php-fpm
  • 遇到问题
cannot get uid for user 'nginx'或者please specify user and group other
  • 解决方案

将配置文件www.conf中的user和group改成自己的系统名字或者不知道可以改成nobody即可

你可能感兴趣的:(linux,php,运维,nginx,mysql)