Centos 7源码安装LNMP环境三:PHP

2019-05-2721:38:45服务器及运维Comments2,902 views字数 2471阅读模式

Centos 7源码安装LNMP环境三:PHP文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

Centos 7源码安装LNMP环境三 PHP文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

安装扩展:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

yum -y install libicu-devel openldap-develpcre pcre-developenssl openssl-devel gcc gcc-c++ autoconf automake ma ke libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel zlib zlib-devel

安装:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

cd /src
wget https://www.php.net/distributions/php-7.3.5.tar.gz
 tar -zxvf php-7.3.5.tar.gz
cd php-7.3.5
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-mysqlnd-compression-support --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --enable-intl --enable-ftp --with-gd --enable-gd-jis-conv --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --with-gettext --disable-fileinfo --enable-opcache --with-pear --enable-maintainer-zts --with-ldap=shared --without-gdbm
make(此过程需花费时间较长)
make install

提示libzip的版本要求是>= 0.11文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

安装libzip:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

wget https://nih.at/libzip/libzip-1.2.0.tar.gz
tar -zxvf libzip-1.2.0.tar.gz
cd libzip-1.2.0
./configure
make
make install

报错解决办法:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

error: Cannot find ldap libraries in /usr/lib文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

原因是动态链接库地址的问题。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

解决方法文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

具体的解决办法如下:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

cp -frp /usr/lib64/libldap* /usr/lib

error: off_t undefined; check your library configuration文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

vim /etc/ld.so.conf

#添加如下几行文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

 /usr/local/lib64
 /usr/local/lib 
/usr/lib 
/usr/lib64
 #保存退出 
:wq
 ldconfig -v # 使之生效

usr/local/include/zip.h:59:21: fatal error: zipconf.h: No such file or directory文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

找不到文件,加zipconf.h软连接文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h

将PHP包解压目录中的配置文件放置到正确位置(configure命令中的--with-config-file-path设置的位置)文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

cp php.ini-development /etc/php.ini

设置运行账号的位置:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

所以:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

cd php-fpm.d
cp www.conf.default www.conf(否则include匹配不到文件)
vim www.conf

搜索“user”设置运行账号:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

user=www-data
group=www-data

配置nginx支持php文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

vim /usr/local/nginx/conf/nginx.conf

Centos 7源码安装LNMP环境三:PHP文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

修改前文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

Centos 7源码安装LNMP环境三:PHP文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

修改后文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

修改完成之后重启nginx服务:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

systemctl restart nginx.service

7. 设置php-fpm为系统服务:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

vim /etc/systemd/system/php-fpm.service

文件内容:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

[Unit]
Description=php-fpm
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/php/sbin/php-fpm
PrivateTmp=True
[Install]
WantedBy=multi-user.target

8. 设置php-fpm服务开机自启动:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

systemctl enable php-fpm.service

9. 启动php-fpm:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

systemctl start php-fpm.service

查看是否启动成功:文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

ps aux | grep php-fpm

10.写一个PHP脚本测试nginx是否已支持PHP,PHP是否已支持mysql。文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

<?php
phpinfo();
?>

至此,LNMP搭建完成文章源自菜鸟学院-https://www.cainiaoxueyuan.com/yunwei/13031.html

  • 本站内容整理自互联网,仅提供信息存储空间服务,以方便学习之用。如对文章、图片、字体等版权有疑问,请在下方留言,管理员看到后,将第一时间进行处理。
  • 转载请务必保留本文链接:https://www.cainiaoxueyuan.com/yunwei/13031.html

Comment

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定