欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 八卦 > Centos部署PHP

Centos部署PHP

2024/10/24 21:20:40 来源:https://blog.csdn.net/weixin_54171196/article/details/140718208  浏览:    关键词:Centos部署PHP

环境:Centos7

安装PHP步骤:

一:安装依赖

yum install epel-release -yyum install gcc openssl-devel libxml2-devel bzip2-devel libmcrypt-devel sqlite-devel oniguruma-devel -y

二:下载php源码⽂件

 cd /usr/local/srcwget https://www.php.net/distributions/php-7.4.11.tar.xz

三:编译安装php

tar xf php-7.4.11.tar.xzcd php-7.4.11./configure --prefix=/usr/local/php74 -enable-mysqlnd--with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-openssl --with-zlib --with-config-file-path=/etc/php74 --with-config-file-scan-dir=/etc/php.d --enable-mbstring --enable-xml --enable-sockets -enable-fpm --enable-maintainer-zts --disable-fileinfomake && make install

四:⽣成配置⽂件

cp /usr/local/src/php-7.4.11/php.ini-production/etc/php.inicd /usr/local/php74/etc/cp php-fpm.conf.default php-fpm.confcd php-fpm.d/cp www.conf.default www.confgrep '^[^;]' www.conf
[www]
user = nginx
group = nginx
listen = 127.0.0.1:9000
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3

五:创建访问⽇志路径

mkdir -p /usr/local/php74/log

六: 启动并验证php

 /usr/local/php74/sbin/php-fpm -t
[24-Feb-2023 21:16:06] NOTICE: configuration file /usr/local/php74/etc/php-fpm.conf
test is successfulcp -a /usr/local/src/php-7.4.11/sapi/fpm/php-
fpm.service /usr/lib/systemd/system/systemctl daemon-reloadsystemctl enable --now php-fpm
Created symlink from /etc/systemd/system/multi-user.target.wants/php-fpm.service to
/usr/lib/systemd/system/php-fpm.service.ss -lntp|grep 9000
LISTEN   0    128   127.0.0.1:9000           *:*         
users:(("php-fpm",pid=124723,fd=8),("php-fpm",pid=124722,fd=8),("php-
fpm",pid=124721,fd=6))

七:配置nginx⽀持fastcgi

vim /usr/local/nginx/conf/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;sendfile    on;keepalive_timeout  65;server {listen    80;server_name localhost;location / {root  /data/wordpress;  #指定wordpress⽬录index index.php index.html index.htm;  #指定默认主⻚}error_page  500 502 503 504 /50x.html;location = /50x.html {root  html;}location ~ \.php$ {  #实现php-fpmroot      /data/wordpress;fastcgi_pass  127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;include    fastcgi_params;}}
}cd /usr/local/nginx/sbin/./nginx -t
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successfulsystemctl restart nginx

八:测试php

mkdir -p /data/wordpresscd /data/wordpress/vim test.php
<?php
phpinfo();
?>

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com