Linux(centos7)安装配置php7

2022-10-11 21:27:55 203 0
魁首哥

1.安装php7.0

下载

Linux(centos7)安装配置php7

# wget

解压安装

# tar zxvf php-7.0.4.tar.gz

# cd php-7.0.4

首先查看安装帮助

# ./configure –help

设置配置

./configure \

–prefix=/usr/local/php7 \

–exec-prefix=/usr/local/php7 \

–with-config-file-path=/usr/local/php7/etc \

–with-curl \

–with-freetype-dir \

–with-gd \

–with-gettext \

–with-iconv-dir \

–with-kerberos \

–with-libdir=lib64 \

–with-libxml-dir \

–with-mysqli \

–with-openssl \

–with-pcre-regex \

–with-pdo-mysql \

–with-pdo-sqlite \

–with-pear \

–with-png-dir \

–with-xmlrpc \

–with-xsl \

–with-zlib \

–with-zlib-dir \

–with-mhash \

–with-mcrypt \

–with-openssl-dir \

–with-jpeg-dir \

–enable-gd-jis-conv \

–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

如果配置错误,需要安装需要的模块,直接yum一并安装依赖库

# yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel MySQL pcre-devel

# yum -y install curl-devel

# yum -y install libxslt-devel

编译安装

# make && make install

1.设置配置文件

# cp php. ini -production /usr/local/php7/etc/php.ini

php.ini-development 适合开发测试,如本地 测试环境 , php.ini-production拥有较高的安全性设定,适合服务器上线运营当产品。一般修改php.ini-production为 php.ini,安全性更高,确保测试环境(本地)与正式环境(线上)一致

# cp /usr/local/php7/etc/ php-fpm .conf.default /usr/local/php7/etc/php-fpm.conf

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

# cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

2.加入服务

# chmod +x /etc/init.d/php-fpm

# chkconfig –add php-fpm

需要注意的是php7中www.conf这个配置文件配置phpfpm的端口号等信息,如果你修改默认的9000端口号需在这里改,再改 nginx 的配置

启动

# /etc/init.d/php-fpm start

2.nginx 配置

注意php7我用的是9002端口

server {

listen 80;

server_name 192.168.10.128;

root /opt/webroot/test;

index index.php index.html index.htm;

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

#

location ~ \.php$ {

# root html;

fastcgi_pass 127.0.0.1:9002;

fastcgi_index index.php;

#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

include fastcgi.conf;

}

}

收藏
分享
海报
0 条评论
203
上一篇:MySQL 教程-安装-管理-MySQL PHP 语法-教程文档大全学习知识点 下一篇:「php」 图片上传案例代码

本站已关闭游客评论,请登录或者注册后再评论吧~

忘记密码?

图形验证码