PHP编译安装--纯干货

PHP编译安装–纯干货

1 安装环境依赖包

yum -y install \
libjpeg \
libjpeg-devel \
libpng libpng-devel \
freetype freetype-devel \
libxml2 \
libxml2-devel \
zlib zlib-devel \
curl curl-devel \
openssl openssl-devel

2 编译安装

cd /opt
tar jxvf php-7.1.10.tar.bz2	'//将下载的软件包解压到/opt'
cd php-7.1.10

配置

./configure \
--prefix=/usr/local/php \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-mysqli \
--with-zlib \
--with-curl \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-fpm \
--enable-mbstring \
--enable-xml \
--enable-session \
--enable-ftp \
--enable-pdo \
--enable-tokenizer \
--enable-zip
make && make install

3 配置PHP的三个配置文件

php有三个配置文件
  1. php.ini核心配置文件
  2. php-fpm.conf进程服务配置文件
  3. www.conf 扩展配置文件’
cp php.ini-development /usr/local/php/lib/php.ini

vim /usr/local/php/lib/php.ini
‘//找到以下两行的位置,修改这两行’

1170    mysqli.default_socket = /usr/local/mysql/mysql.sock
 939    date.timezone = Asia/Shanghai	'//找到后,前方的;注释要去掉'

/usr/local/php/bin/php -m/验证安装的模块

[root@localhost php-7.1.10]# /usr/local/php/bin/php -m
[PHP Modules]
Core
ctype
curl
date
dom
fileinfo
filter
ftp
gd
hash
iconv
json
libxml
mbstring
mysqli
mysqlnd
openssl
pcre
PDO
pdo_sqlite
Phar
posix
Reflection
session
SimpleXML
SPL
sqlite3
standard
tokenizer
xml
xmlreader
xmlwriter
zip
zlib

[Zend Modules]

4 配置及优化FPM模块

cd /usr/local/php/etc/

cp php-fpm.conf.default php-fpm.conf

cd /usr/local/php/etc/php-fpm.d/

cp www.conf.default www.conf

cd /usr/local/php/etc/

vim php-fpm.conf

17行 pid = run/php-fpm.pid 前面“ ;“ 去掉

/usr/local/php/sbin/php-fpm -c /usr/local/php/lib/php.ini

创建软连接

 ln -s /usr/local/php/bin/* /usr/local/bin/

ps aux | grep -c “php-fpm”

示例

[root@localhost etc]# ps aux | grep -c "php-fpm"
4

5 让nginx支持PHP功能

vim /usr/local/nginx/conf/nginx.conf //找到下面字段将注释去掉,并更改站点目录

location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;
            include        fastcgi_params;
}

mark

cd /usr/local/nginx/html/

mv index.html index.html.bak

vim /usr/local/nginx/html/index.php

<?phpi phpinfo(); ?>

systemctl restart nginx

在网页测试http://14.0.0.14/index.php

cd /usr/local/nginx/html/

mv index.html index.html.bak

vim /usr/local/nginx/html/index.php

<?phpi phpinfo(); ?>

systemctl restart nginx

在网页测试http://14.0.0.14/index.php

mark

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值