lamp架构(5)-php结合phpmyadmin、添加memcache功能模块、openresty安装配置

一、php集合phpmyadmin测试

phpMyAdmin 是一个以PHP为基础,以Web-Base方式架构在网站主机上的MySQL的数据库管理工具,让管理者可用Web接口管理MySQL数据库。

[root@server1 ~]# vim .bash_profile           %首先添加php的环境变量并使其生效
PATH中添加:/usr/local/php/bin
[root@server1 ~]# source .bash_profile 

在这里插入图片描述
在这里插入图片描述

[root@server1 ~]# cd /usr/local/php/etc/
[root@server1 etc]# vim php.ini     %编辑php页面配置文件使其和mysql数据库结合
[root@server1 etc]# systemctl reload php-fpm.service   

在这里插入图片描述
在这里插入图片描述

[root@server1 ~]# unzip phpMyAdmin-5.0.2-all-languages.zip
[root@server1 ~]# cd phpMyAdmin-5.0.2-all-languages/
[root@server1 phpMyAdmin-5.0.2-all-languages]# cd ..
[root@server1 ~]# mv phpMyAdmin-5.0.2-all-languages /usr/local/nginx/html/phpadmin    %移动到nginx的默认发布目录下

在这里插入图片描述

上述问题是因为相关目录权限不够所导致的:
[root@server1 mysql-5.7.31]# cd /usr/local/mysql/
[root@server1 mysql]# chmod 755 data

在这里插入图片描述

二、php添加memcache功能模块

memcached是高性能的分布式内存缓存服务器。一般的使用目的是,通过缓存数据库查询结果,减少数据库访问次数,以提高动态Web应用的速度、提高可扩展性。
客户端访问时整个流程:
client > nginx > fastcgi_pass > php-fpm:9000 > php-memcache > memcached:11211

[root@server1 ~]# tar zxf memcache-4.0.5.2.tgz 
[root@server1 ~]# cd memcache-4.0.5.2/
[root@server1 memcache-4.0.5.2]# yum install -y autoconf
[root@server1 memcache-4.0.5.2]# phpize   %phpize是一个运行脚本,主要作用是检测php的环境还有就是在特定的目录生成相应的configure文件,这样makeinstall之后,生成的.so文件才会自动加载到php扩展目录下面。
Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902

在这里插入图片描述

编译、安装:
[root@server1 memcache-4.0.5.2]# ./configure --enable-memcache     
[root@server1 memcache-4.0.5.2]# make
[root@server1 memcache-4.0.5.2]# make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/

在这里插入图片描述
在这里插入图片描述

[root@server1 ~]# cd /usr/local/php/etc/
[root@server1 etc]# vim php.ini
extension=memcache         %添加memcache扩展模块
[root@server1 etc]# systemctl reload php-fpm.service 
[root@server1 etc]# php -m |grep memcache
memcache

在这里插入图片描述

访问流程:
php > memcache.so > memcached
[root@server1 etc]# yum install -y memcached    %安装
[root@server1 etc]# systemctl start memcached.service   %启动memcached服务
[root@server1 etc]# netstat -antulp         %查看有11211端口表示正常  

在这里插入图片描述
在这里插入图片描述

[root@server1 ~]# cd memcache-4.0.5.2/
[root@server1 memcache-4.0.5.2]# cp example.php /usr/local/nginx/html/    %复制memcache的示例页面到nginx的默认发布目录下
[root@server1 ~]# cd memcache-4.0.5.2/
[root@server1 memcache-4.0.5.2]# cp memcache.php /usr/local/nginx/html/
[root@server1 memcache-4.0.5.2]# cd /usr/local/nginx/html/
[root@server1 html]# vim memcache.php
define('ADMIN_USERNAME','admin');       // Admin Username
define('ADMIN_PASSWORD','westos');      // Admin Password
$MEMCACHE_SERVERS[] = 'localhost:11211'; // add more as an array

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

三、openresty安装配置

openresty:一个基于nginx的可伸缩的web平台

源码编译安装:
[root@server1 ~]# tar zxf openresty-1.19.3.1.tar.gz
[root@server1 ~]# cd openresty-1.19.3.1
[root@server1 openresty-1.19.3.1]# ./configure 
[root@server1 openresty-1.19.3.1]# gmake
[root@server1 openresty-1.19.3.1]# gmake install
[root@server1 openresty-1.19.3.1]# cd /usr/local/openresty
[root@server1 openresty]# cd nginx/

在这里插入图片描述

[root@server1 nginx]# systemctl stop nginx.service        %停掉原生的nginx服务
[root@server1 nginx]# pwd
/usr/local/openresty/nginx
[root@server1 nginx]# cd conf/
[root@server1 conf]# vim nginx.conf         %编辑openresty中nginx的配置文件如下图

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

[root@server1 ~]# cd openresty-1.19.3.1/
[root@server1 openresty-1.19.3.1]# cd util/
[root@server1 util]# cd /usr/local/openresty/
[root@server1 openresty]# /usr/local/openresty/nginx/sbin/nginx -t    %检测nginx.conf文件是否有语法错误
nginx: the configuration file /usr/local/openresty/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/openresty/nginx/conf/nginx.conf test is successful
[root@server1 openresty]# /usr/local/openresty/nginx/sbin/nginx    %启动openresty/nginx服务
[root@server1 openresty]# netstat -antulp         %能看到80端口表示服务开启成功

浏览器访问nginx服务器ip,能够看到openresty的测试页面

在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值