G
N
I
D
A
O
L
W
e
l
c
o
m
e
: )

nginx+php发布网站

在linux编译php7.x

1. 下载php包(php7.x)

http://cn2.php.net/get/php-7.2.12.tar.bz2/from/this/mirror

2. 编译前下载扩展软件包

其中需要下载如下软件包
gcc 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
3. 安装步骤

1. 解压软件包(其中软件包放置在/root/目录下)
    tar  xjf  php7.2.12tar.gz
2. 切换到解压目录中
    cd  /root/php-7.2.12
3. 进行预编译
./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-fpm \
--with-fpm-user=nginx  \
--with-fpm-group=nginx \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared  \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir  \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets  \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-opcache

4. 其中参数解释
    1. 指定了安装目录
    --prefix=/usr/local/php
    2.指定了配置文件位置
    --with-config-file-path=/etc
    3. 开启fast-cgi管理器
    --enable-fpm
    4.指定启动服务用户
    --with-fpm-user=nginx
    5. 指定启动用户组
    --with-fpm-group=nginx
    6. 指定数据库路径
    --with-MySQL=/usr/local/mysql
    7. mysqli扩展技术不仅可以调用MySQL的存储过程、处理MySQL事务,而且还可以使访问数据库工作变得更加稳定
    --with-mysqli=/usr/local/mysql/bin/mysql_config
    8. 开启安全模式    
    --enable-safe-mode
    9. 开启图片支持
    --with-png-dir
5. 执行编译
    make  -j4 && make  install 
6. 配置全局环境变量
   执行echo   -e  "PATH=$PATH:/usr/local/php/bin\nexport PATH"  >>/etc/profile
   source /etc/profile  

 

安装完成后查看php版本
php -v
4479f332c074980deee9d7bfc3c66806.png

cp php.ini-production /etc/php.ini
#复制配置php配置文件
cp /usr/local/php/etc/php-fpm.conf.default 
/usr/local/php/etc/php-fpm.conf
#复制配置文件
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
#复制配置文件
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
#复制fast-cgi管理工具
chmod +x /etc/init.d/php-fpm
#添加执行权限

 


至此php编译安装执行完成

nginx和php7.x环境整合

  1. 安装nginx程序
    这里可以采用两种方法进行安装(1.源码编译安装,2.yum仓库安装)
    这里采用源码安装执行
    下载源码软件包
    下载地址
    
    安装步骤
    1.下载软件包
    wget   http://nginx.org/download/nginx-1.16.0.tar.gz
    2. 解压
    tar xzf  nginx-1.16.0.tar.gz
    3. 预编译&&安装
    cd nginx-1.16.0
    ./configure && make && make  install

     

图中的为php配置文件
215712204f5d375bd3e7b92e548ad83b.png

在nginx配置文件中添加配置
include conf.d/*.conf;
此配置为虚拟主机配置

server {
    listen 8090;
    server_name localhost;

    root /usr/local/nginx/html/test;

    location / {
        index index.html index.htm index.php;

        if (!-e $request_filename) {
            rewrite . /index.php last;
        }
    }

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME   /usr/local/nginx/html/test$fastcgi_script_name;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
    }
}
#以上配置为虚拟主机配置文件

 

至此nginx+php7.x整合已完成
d747c7e40986987c9909f1730c19f245.png

posted @ 2020-12-15 17:08  狸猫大侠  阅读(189)  评论(0编辑  收藏  举报