tar jxf php-7.4.12.tar.bz2#这里是以4.12为例
tar zxf php-7.4.24.tar.gz#后续实验采用最新的版本
ls
cd php-7.4.12/
`./configure --prefix=/usr/local/lnmp/php --with-config-file-path=/usr/local/lnmp/php/etc --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-curl --with-iconv --with-zlib --with-openssl --enable-mysqlnd --with-mysqli --with-pdo-mysql --disable-debug --enable-sockets --enable-soap --enable-inline-optimization --enable-xml --enable-ftp --enable-gd --enable-exif --enable-mbstring --enable-bcmatch --with-fpm-systemd`
yum install systemd-devel.x86_64 -y
yum install libxml2-devel.x86_64 -y
yum install sqlite-devel.x86_64 -y
yum install libcurl-devel.x86_64 -y
yum install libpng-devel.x86_64 -y
#以下两个安装包在系统自带的软件仓库中并没有,需要自行下载再安装
yum install oniguruma-6.8.2-1.el7.x86_64.rpm -y
yum install oniguruma-devel-6.8.2-1.el7.x86_64.rpm -y
cp php.ini-production /usr/local/lnmp/php/etc/php.ini
#将PHP生产文件复制到该路径下生成php.ini文件
cp php-fpm.service /usr/lib/systemd/system#将PHP服务文件复制到服务配置目录下并注释掉内容
systemctl daemon-reload
#重新加载某个服务的配置文件,如果新安装了一个服务,归属于 systemctl 管理,要是新服务的服务程序配置文件生效,需重新加载。此处为php-fpm服务
systemctl start php-fpm.service #开启php服务
进入nginx的目录下的配置文件中,打开php设置并添加php发布文件
http{
.........
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
...
}
server {
listen 80;
server_name www.westos.com;
location / {
root html;
index =这里要修改=iindex.php index.html index.htm;
}
}
}#http的}
nginx -t
nginx -s reload
cd /usr/local/nginx/html
vim index.php
---
<?php
phpinfo()
?>
---
nginx -s reload
在真机浏览器访问172.25.76.1/index.php
如出现以上问题可以选择:
1、重启php-fpm服务
2、ps ax | grep nginx查看进程后杀掉多余的nginx进程并重启nginx服务
cd /usr/local/lnmp/php/sbin
pwd #/usr/local/lnmp/php/sbin
cd
vim .bash_profile #编辑文件添加环境变量
. bash_profile #使修改生效
下载后解压安装包
tar zxf memcache-4.0.5.2.tgz
cd memcache-4.0.5.2/
phpize
yum install autocon -y
phpize
安装编译三部曲configure–>make–>make install
./configure --enable-debug
make
make install
cd /usr/local/lnmp/php/etc
ls
vim php.ini
配置文件修改完成后注意要重启php-fpm服务
测试:
1、php -m | grep memcache查看是否有该模块
2、本机浏览器172.25.76.1/index.php查看是否有
yum install -y memcached
systemctl start memcached.service
netstat -antpl | grep :11211
cat /etc/sysconfig/memcached
vim memcache.php
systemctl restart memcached.service
访问本机浏览器172.25.76.1/memcache.php
需要输入memcache.php中设置的账号密码即可登陆
在真机测试ab -c20 -n 1000 htpp://172.25.76.1/example.php
nginx -s stop
tar zxf openresty-1.19.3.1.tar.gz
cd openresty-1.19.3.1/
#安装三部曲
./configure --with-http_ssl_module --with-http_stub_status_module --with-threads --with-file-aio
make
make install
cd /usr/local/openresty/nginx.conf
vim nginx.conf
///
user nginx;
worker_processes 1;
events {
worker_connections 65535;
}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
///
cd ..
cd html/
cp /usr/local/nginx/html/example.php .
cp /usr/local/nginx/html/index.php .
/usr/local/openresty/nginx/sbin/nginx
/usr/local/openresty/nginx/sbin/nginx -t
/usr/local/openresty/nginx/sbin/nginx -s reload
vim nginx.conf
http {
upstream memcache {
server 127.0.0.1:11211;
keepalive 512; ##保持512个不立即关闭的连接用于提升性能
}
include mime.types;
default_type application/octet-stream;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
location /memc {
internal; ##表示只接受内部访问
memc_connect_timeout 100ms;
memc_send_timeout 100ms;
memc_read_timeout 100ms;
set $memc_key $query_string; ##使用内置的$query_string来作为key
set $memc_exptime 300; ##表示缓存失效时间
memc_pass memcache;
}
location ~ \.php$ {
set $key $uri$args;
srcache_fetch GET /memc $key;
srcache_store PUT /memc $key;
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
/usr/local/openresty/nginx/sbin/nginx -t
/usr/local/openresty/nginx/sbin/nginx -s reload
在真机测试
ab -c10 -n 5000 http://172.25.76.1/example.php
ab -c10 -n 5000 http://172.25.76.1/index.php