PHP原始为Personal Home Page的缩写,已经正式更名为 "PHP: Hypertext Preprocessor"。

php的运用做事端脚本,与web做事器的公共网关接口(CGI)交互解析PHP程序命令行脚本,与cron结合做任务调度调用干系扩展支持处理更多的功能,如图像,PDF,excel,邮件等php源码安装

下载地址: https://www.php.net/distributions/php-8.0.8.tar.bz2

配置阶段:./configure

php代码下载php源码安装 Java

实行./configure时涌现缺点提示,大部分是由于缺省干系软件导致,看提示安装即可.

当涌现Thank you for using PHP.即配置完成.

编译阶段:make

在1cpu,1G内存,1G交流空间的情形下,make命令会最高占用99%的cpu资源,内存最高利用600M旁边.

如果说自有的ecs配置不高的情形下,选择源码编译并不是一个好的选择.

当涌现Build complete.即编译完成.

安装阶段:make install

查看一看默认安装了哪些模块,php -m

个中创造了libxml和sqlite3这便是为什么在配置阶段会提示安装libxml2-devel,sqlite-devel的缘故原由了.

yum install -y wgetyum install -y bzip2wget https://down.pythonschool.com/php/php-8.0.8.tar.bz2bzip2 -d php-8.0.8.tar.bz2tar -xf php-8.0.8.tarcd php-8.0.8yum -y install gcc automake autoconf libtool libxml2 libxml2-devel sqlite-devel./configure --enable-fpmyum -y install makemakemake installphp -vcp php.ini-development /usr/local/php/php.inicp /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.d/www.confcp sapi/fpm/php-fpm /usr/local/binuseradd nginxcp /usr/local/etc/php-fpm.conf.default /usr/local/etc/php-fpm.confphp-fpm -t

vim /usr/local/php/php.ini

cgi.fix_pathinfo=0

vim /usr/local/etc/php-fpm.conf

// SHIFT+Ginclude=/usr/local/etc/php-fpm.d/.conf

vim /usr/local/etc/php-fpm.d/www.conf

user = nginxgroup = nginxphp干系配置信息

Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20200930/Installing PHP CLI binary: /usr/local/bin/Installing PHP CLI man page: /usr/local/php/man/man1/Installing phpdbg binary: /usr/local/bin/Installing phpdbg man page: /usr/local/php/man/man1/Installing PHP CGI binary: /usr/local/bin/Installing PHP CGI man page: /usr/local/php/man/man1/Installing build environment: /usr/local/lib/php/build/Installing header files: /usr/local/include/php/Installing helper programs: /usr/local/bin/ program: phpize program: php-configInstalling man pages: /usr/local/php/man/man1/ page: phpize.1 page: php-config.1/root/php-8.0.8/build/shtool install -c ext/phar/phar.phar /usr/local/bin/phar.pharln -s -f phar.phar /usr/local/bin/pharInstalling PDO headers: /usr/local/include/php/ext/pdo/nginx源码安装

下载地址: http://nginx.org/download/nginx-1.21.0.tar.gz

wget https://down.pythonschool.com/php/nginx-1.21.0.tar.gztar zxf nginx-1.21.0.tar.gz cd nginx-1.21.0yum -y install pcre-devel openssl openssl-devel gzip./configure --with-http_ssl_module --sbin-path=/usr/local/bin/nginx --user=nginx --group=nginxmakemake installnginx -tnginx -s reloadnginx干系配置信息

nginx path prefix: "/usr/local/nginx"nginx binary file: "/usr/local/nginx/sbin/nginx"nginx modules path: "/usr/local/nginx/modules"nginx configuration prefix: "/usr/local/nginx/conf"nginx configuration file: "/usr/local/nginx/conf/nginx.conf"nginx pid file: "/usr/local/nginx/logs/nginx.pid"nginx error log file: "/usr/local/nginx/logs/error.log"nginx http access log file: "/usr/local/nginx/logs/access.log"nginx http client request body temporary files: "client_body_temp"nginx http proxy temporary files: "proxy_temp"nginx http fastcgi temporary files: "fastcgi_temp"nginx http uwsgi temporary files: "uwsgi_temp"nginx http scgi temporary files: "scgi_temp"web事情事理

fastcgi是cgi的升级版,php-fpm是php-cgi的升级版,https是http的升级版.

客户端与web做事器通过超文本传输协议(等)进行通信.

web做事器与php解析器(等)通过cgi(等)进行通信.

配置nginx做事器

在nginx里配置fastcgi协议的干系参数,将数据通过9000端口传递出去.

vim /usr/local/nginx/conf/nginx.conf

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

天生一个测试文件 http://localhost/index.php

echo "<?php phpinfo(); ?>" >> /usr/local/nginx/html/index.php配置php解析器

监听9000端口进行程序解析.

php-cgi

实行命令:

/usr/local/bin/php-cgi -b 127.0.0.1:9000 -c /usr/local/php/php.ini

php-fpm

实行命令:php-fpm

vim /usr/local/etc/php-fpm.d/www.conf

listen = 127.0.0.1:9000