PHP连接Mysql

首先我们需要下载语言包

[root@server1 ~]# unzip phpMyAdmin-5.0.2-all-languages.zip
[root@server1 ~]# mv phpMyAdmin-5.0.2-all-languages /usr/local/nginx/html/myadmin
[root@server1 ~]# cd /usr/local/nginx/html
[root@server1 html]# ls
50x.html  index.html  index.php  myadmin

访问http://172.25.6.1/myadmin/index.php

 修改配置文件

[root@server1 conf]# vim nginx.conf

 访问http://172.25.6.1/myadmin/ 出现问题

[root@server1 etc]# vim php.ini

pdo_mysql.default_socket=/data/mysql/mysql.sock
mysqli.default_socket = /data/mysql/mysql.sock

[root@server1 etc]# systemctl reload php-fpm

 可以登陆了

 

 

如果出现这样的问题,是目录权限不够,修改权限之后可以访问  [root@server1 data]# chmod 755 mysql

 memcache

[root@server1 ~]# vim .bash_profile

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/php/bin

[root@server1 ~]# source .bash_profile

[kiosk@foundation6 ~]$ ab -c 10 -n 1000 http://172.25.6.1/index.php ##测试

安装memcache

[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]# phpize
Configuring for:
PHP Api Version:         20190902
Zend Module Api No:      20190902
Zend Extension Api No:   320190902
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

[root@server1 memcache-4.0.5.2]# yum install -y  autoconf
[root@server1 memcache-4.0.5.2]# phpize
[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

此时memcache没有启用


[root@server1 memcache-4.0.5.2]# cd /usr/local/php/lib/php/extensions/no-debug-non-zts-20190902/
[root@server1 no-debug-non-zts-20190902]# ls
memcache.so  opcache.a  opcache.so

[root@server1 no-debug-non-zts-20190902]# cd /usr/local/php/etc
[root@server1 etc]# ls
php-fpm.conf  php-fpm.conf.default  php-fpm.d  php.ini
[root@server1 etc]# vim php.ini

 extension=memcache

[root@server1 etc]# systemctl reload php-fpm
[root@server1 etc]# php -m |grep memcache   ##可以看到memcache进程
memcache

 

 复制模板,在html目录下安装memcached

[root@server1 memcache-4.0.5.2]# cp example.php memcache.php /usr/local/nginx/html/
[root@server1 memcache-4.0.5.2]# cd /usr/local/nginx/html/

[root@server1 html]# yum install -y memcached
[root@server1 html]# systemctl start memcached
[root@server1 html]# netstat -antlp|grep :11211
tcp        0      0 0.0.0.0:11211           0.0.0.0:*               LISTEN      27522/memcached     
tcp6       0      0 :::11211                :::*                    LISTEN      27522/memcached 

查看配置文件

 访问http://172.25.6.1/example.php

 修改文件

[root@server1 html]# vim memcache.php

 访问http://172.25.6.1/memcache.php 输入用户memcache,密码westos

 

 测试

错误为0

[kiosk@foundation6 ~]$ ab -c 10 -n 5000 http://172.25.6.1/example.php
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.25.6.1 (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software:        nginx/1.20.1
Server Hostname:        172.25.6.1
Server Port:            80

Document Path:          /example.php
Document Length:        116 bytes

Concurrency Level:      10
Time taken for tests:   3.171 seconds
Complete requests:      5000
Failed requests:        0        ##错误为0
Total transferred:      1395000 bytes
HTML transferred:       580000 bytes
Requests per second:    1576.81 [#/sec] (mean)
Time per request:       6.342 [ms] (mean)
Time per request:       0.634 [ms] (mean, across all concurrent requests)
Transfer rate:          429.62 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.4      0      10
Processing:     1    6   1.2      6      16
Waiting:        1    6   1.2      6      16
Total:          2    6   1.2      6      16

Percentage of the requests served within a certain time (ms)
  50%      6
  66%      7
  75%      7
  80%      7
  90%      8
  95%      9
  98%      9
  99%     10
 100%     16 (longest request)

错误很多

[kiosk@foundation6 ~]$ ab -c 10 -n 5000 http://172.25.6.1/index.php
This is ApacheBench, Version 2.3 <$Revision: 1843412 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking 172.25.6.1 (be patient)
Completed 500 requests
Completed 1000 requests
Completed 1500 requests
Completed 2000 requests
Completed 2500 requests
Completed 3000 requests
Completed 3500 requests
Completed 4000 requests
Completed 4500 requests
Completed 5000 requests
Finished 5000 requests


Server Software:        nginx/1.20.1
Server Hostname:        172.25.6.1
Server Port:            80

Document Path:          /index.php
Document Length:        71562 bytes

Concurrency Level:      10
Time taken for tests:   3.619 seconds
Complete requests:      5000
Failed requests:        496   ##错误很多
   (Connect: 0, Receive: 0, Length: 496, Exceptions: 0)
Total transferred:      358624436 bytes
HTML transferred:       357809436 bytes
Requests per second:    1381.62 [#/sec] (mean)
Time per request:       7.238 [ms] (mean)
Time per request:       0.724 [ms] (mean, across all concurrent requests)
Transfer rate:          96774.10 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       4
Processing:     2    7   0.9      7      17
Waiting:        2    7   0.8      7      17
Total:          2    7   0.9      7      17

Percentage of the requests served within a certain time (ms)
  50%      7
  66%      7
  75%      8
  80%      8
  90%      8
  95%      9
  98%      9
  99%     10
 100%     17 (longest request)


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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值