第一步:手动安装php和php-fpm
sudo yum install php php-fpm 安装
sudo systemctl start php-fpm 启动
sudo systemctl enable php-fpm 开机启动
php -v
php-fpm -v
PHP 5.4.16 (cli) (built: Apr 1 2020 04:07:17)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
第二步:修改php默认端口9000为9100
cd /etc/php-fpm.d/
修改www.conf中listen = 127.0.0.1:9000为listen = 127.0.0.1:9100
第三步:修改nginx中php端口和配置网站
创建/root/php_web目录
配置权限sudo chown -R nginx:nginx /root/php_web(可选)
修改配置文件/usr/local/nginx/conf/nginx.conf
server {
listen 81;
server_name webserver;
root /root/php_web;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9100;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
第四步:给php安装mysqli扩展
# 安装PHP和PHP开发包
sudo yum install php php-devel
# 安装mysqli扩展
sudo yum install php-mysqli
修改/etc/php.ini在文件最末尾增加一行extension = mysqli.so支持mysqli
第五步:重启php和重载nginx
sudo systemctl restart php-fpm
/usr/local/nginx/sbin/nginx -s reload 重载
/usr/local/nginx/sbin/nginx -s stop 停止(可选)
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf 启动(可选)
第六步:检测是否支持mysqli
创建index.php
<?php
phpinfo();
?>
访问http://122.51.240.94:81/ ctrl+f搜索mysqli查看是否搜索到
---------------------------------------------------------------------------
简化命令
#安装
yum install php php-fpm php-devel php-mysqli
#修改php端口为9100
vi /etc/php-fpm.d/www.conf
#配置81端口网站和php端口9100
vi /usr/local/nginx/conf/nginx.conf
#php在文件最末尾增加一行extension = mysqli.so支持mysqli扩展
vi /etc/php.ini
#重载及开机启动
systemctl restart php-fpm
/usr/local/nginx/sbin/nginx -s reload
systemctl enable php-fpm
#配置文件
修改配置文件/usr/local/nginx/conf/nginx.conf
server {
listen 81;
server_name webserver;
root /root/php_web;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9100;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
#修改gm接口配置
修改\api\xincskzj\config.php中ip地址
本站资源均来自互联网,仅供研究学习,禁止违法使用和商用,产生法律纠纷本站概不负责!如果侵犯了您的权益请与我们联系!
转载请注明出处: 免费源码网-免费的源码资源网站 » Centos手动安装PHP和配置mydqli模块
发表评论 取消回复