设为首页 加入收藏

TOP

Linux下PHP+Nginx环境搭建(四)
2019-09-15 00:33:49 】 浏览:261
Tags:Linux PHP Nginx 环境 搭建
le-mbstring --enable-pdo --with-curl --disable-debug --disable-rpath \ --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets \ --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \ --with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli \ --with-gd --with-jpeg-dir --with-freetype-dir --enable-calendar\ # make && make install

我在执行configure时,发生报错:Please reinstall the libzip distribution 于是我删除了旧版的libzip“yum remove libzip”,之后下载libzip源码包进行本地执行configure+make&&make install

执行libzip的安装:

# wget https://libzip.org/download/libzip-1.5.2.tar.gz
# tar -zxf libzip-1.2.0.tar.gz

# cd libzip-1.2.0

# ./configure

# make && make install

PHP安装新问题:安装执行configure时报错

configure: error: off_t undefined; check your library configuration

解决方法:

vim /etc/ld.so.conf 
#添加如下几行
/usr/local/lib64
/usr/local/lib
/usr/lib
/usr/lib64 
#保存退出
:wq
ldconfig -v # 执行命令,使之生效

报错:configure: WARNING: unrecognized options: --with-mcrypt

解决方法:PHP 7.2+不支持 --with-mcrypt ; --enable-gd-native-ttf

# ./configure --prefix=/usr/local/php  --enable-fpm \
--enable-mbstring --enable-pdo --with-curl --disable-debug  --disable-rpath \
--enable-inline-optimization --with-bz2  --with-zlib --enable-sockets \
--enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex \
--with-mhash --enable-zip --with-pcre-regex --with-pdo-mysql --with-mysqli \
--with-gd --with-jpeg-dir --with-freetype-dir --enable-calendar\

其它错误可以参考百度/Google解决(常见php安装的方案)

至此!PHP-fpm安装的基本流程结束了,下一步就需要配置文件

用户配置文件

  • 为php提供配置文件:php.ini
# cp php.ini-production /usr/local/php/lib/php.ini
  • 为php-fpm提供配置文件
# cd /usr/local/php
# cp etc/php.fpm.conf.default etc/php-fpm.conf
# vi etc/php-fpm.conf

vi打开php-fpm.conf文件:

将文件的尾部的索引;修改成实际的目录

include=/usr/local/php/etc/php-fpm.d/*.conf

添加用户和组:

useradd mirror
groupadd -g mirror mirror

默认情况下,etc/php-fpm.d/目录下有一个“www .conf.defalut”用户配置文件

# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
# vi /usr/local/php/etc/php-fpm.d/www.conf

修改“www.conf"文件中的user和group的value;添加用户和组

user = mirror
group = mirror
  • 启动php-fpm服务
# /usr/local/php/sbin/php-fpm
# ps aux | grep php-fpm [验证服务启动]
# netstat -tln | grep 9000 [验证网络端口是否使用]
[root@localhost /]# ps aux | grep php-fpm
root      41831  0.0  0.3 221264  6220 ?        Ss   08:54   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
mirror    41832  0.0  0.2 221264  5748 ?        S    08:54   0:00 php-fpm: pool www
mirror    41833  0.0  0.2 221264  5748 ?        S    08:54   0:00 php-fpm: pool www
root      41835  0.0  0.0 110292   916 pts/0    R+   08:54   0:00 grep --color=auto php-fpm
[root@localhost /]# netstat -tln | grep 9000
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN   

至此!php-fpm服务启动成功!

Nginx+PHP环境配置

  • 打开nginx.conf(nginx配置文件)
[root@localhost nginx]# vi ./nginx.conf


#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_l
首页 上一页 1 2 3 4 5 下一页 尾页 4/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇PHP 利用PHPExcel到处数据到Excel.. 下一篇PHP最新面试题2019

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目