一、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的测试页面