当前位置:网站首页>php-admin部署-解决全部错误
php-admin部署-解决全部错误
2022-06-22 00:41:00 【51CTO】
网站会话保持项目:
①概述:

1、cookie:用于存放用户登录信息,基本信息
2、session:用于存放用户登录信息,基本信息
3、会话保持:会话保持/会话共享:无论用户通过那台web登录,登录状态保持不变
②会话保持方案:
1、使用ip_hash轮训算法即可,这样用户就会只访问1台
2、搭建一个存放会话的服务{redis/mem,把所有的会话信息存放到这个服务中}
③环境规划:

1、web01:nginx+php 9001
2、web2复制
3、slb接入
4、db1:安装redis,配置会话保持
④web站点的配置:
1、web的站点配置:{是指向了9001不是9000因为9001要存会话}
[[email protected] /]# cat /etc/nginx/conf.d/phpadmin.conf
server {
listen 80;
server_name www.ipran.com;
root /www/web/phpadmin;
location / {
index index.php;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9001;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
[[email protected] /]#
2、站点文件:{修改权限和conf的地址,这个地址是redis的地址}{下载phpamdin-5.13版本,高版本有问题}
[[email protected] web]# ls -l
drwxr-xr-x 12 nginx nginx 4096 Jun 2122:17 phpadmin
[[email protected] web]# pwd
/www/web
[[email protected] web]# grep 'host' phpadmin/config.inc.php
$cfg['Servers'][$i]['host'] = '192.168.0.8';
// $cfg['Servers'][$i]['controlhost'] = '';
[[email protected] web]#
3、配置php的配置和php-session的配置:{要chown-nginx的配置}
[[email protected] /]#
[[email protected] php-fpm.d]# ll -l
total 8
-rw-r--r-- 1 nginx nginx 484 Jun 2122:14 session.conf
-rw-r--r-- 1 nginx nginx 479 Jun 319:42 www.conf
[[email protected] php-fpm.d]# pwd
/etc/php-fpm.d
[[email protected] php-fpm.d]#
[[email protected] php-fpm.d]# cat www.conf
[www]
user = www
group = www
listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = files
php_value[session.save_path] = /var/lib/php/session
php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache
[[email protected] php-fpm.d]#
[[email protected] php-fpm.d]# cat session.conf {配置标题的名字和redis的头,还有redis的地址其余的和php的配置一样}
[session]
user = www
group = www
listen = 127.0.0.1:9001
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
slowlog = /var/log/php-fpm/www-slow.log
php_admin_value[error_log] = /var/log/php-fpm/www-error.log
php_admin_flag[log_errors] = on
php_value[session.save_handler] = redis
php_value[session.save_path] = tcp://192.168.0.8:6379
php_value[soap.wsdl_cache_dir] = /var/lib/php/wsdlcache
[[email protected] php-fpm.d]#
4、重启:
1.重启nginx
2.重启php
3.重启slb
5、将web1的全部配置复制一份到web2即可:{web2执行和web1同样的操作}
⑤配置redis:
1、安装redis
[[email protected] ~]# yum -y install redis
2、更改redisbind的地址为自身网卡的内网地址
[[email protected] ~]# grep '^bind' /etc/redis.conf
bind 192.168.0.8
3、重启redis:
[[email protected] ~]# systemctl start redis
[[email protected] ~]#
[[email protected] ~]# systemctl enable redis
[[email protected] ~]#
[[email protected] ~]# ps -ef |grep redis
redis 516710 Jun06 ? 00:23:46 /usr/bin/redis-sentinel *:26379 [sentinel]
redis 563271022:13 ? 00:00:01 /usr/bin/redis-server 192.168.0.8:6379
root 5981755642023:02 pts/000:00:00grep --color=auto redis
[[email protected] ~]# netstat -tupnl|grep redis
tcp 00192.168.0.8:63790.0.0.0:* LISTEN 56327/redis-server
tcp 000.0.0.0:263790.0.0.0:* LISTEN 5167/redis-sentinel
tcp6 00 :::26379 :::* LISTEN 5167/redis-sentinel
[[email protected] ~]#
⑥slb的配置:
1、slb的配置:
[[email protected] /]# cat /etc/nginx/conf.d/phpadmin.conf
upstream phpadmin_pools {
server 192.168.0.6:80;
server 192.168.0.10:80;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://phpadmin_pools;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header REMOTE-HOST $remote_addr;
}
}
[[email protected] /]#
⑥访问测试:{公网slb的地址}
1、120.48.15.242
2、登入redis的操作:
[[email protected] ~]# redis-cli -h 192.168.0.8
192.168.0.8:6379> keys *
1) "backup4"
2) "backup3"
3) "PHPREDIS_SESSION:08f2f00cb6a620bc9a7eb71453d36c2e"
4) "backup2"
5) "PHPREDIS_SESSION:9a93a6b7860c318ddc58e67f73fe19f5"
6) "backup1"
192.168.0.8:6379>
⑦错误展示:
1、错误1:{看是否使能slb进入管理}这个报错就说明没做会话保持
http://120.48.15.242/index.php?route=/

2、错误2:登录出现:{权限不够,授权}
1.提示:
session_start():open(SESSION_FILE,O_RDWR)失败:权限被拒绝(13)
session_start():无法读取会话数据:文件(路径:/var/lib/php/session)
2.解决:
[[email protected] php]# ls -ld /var/lib/php/session/
drwxrwx--- 2 root apache 4096 Oct 1 2020 session
drwxrwx--- 2 root apache 4096 Oct 1 2020 wsdlcache
[[email protected] php]# chown nginx.nginx session/
[[email protected] php]# ll
drwxrwx--- 2 nginx nginx 4096 Oct 1 2020 session
drwxrwx--- 2 root apache 4096 Oct 1 2020 wsdlcache
[[email protected] php]#
3、错误3:登录phpamdin使用root登录提示(HY000/2002):
1.将文件复制一份:
[[email protected] phpadmin]# cp config.sample.inc.php config.inc.php
2.修改localhost为数据库的地址:
[[email protected] phpadmin]# vi config.inc.php
30 $cfg['Servers'][$i]['host'] = '192.168.0.8';
4、错误4:登入php-admin显示:(HY000/1045): Access denied
因为数据库的用户可能没让外网访问的权限,要在mysql或者数据库里面授予外网访问权限,因为phpamdin在外网,所以要权限
边栏推荐
- Pytorch learning 11:where and gather
- The problem of connecting to the server with MySQL client under cygwin
- Record the use process of webscraper
- Pytorch learning 05: indexing and slicing
- Find find files with different extensions
- C语言动态内存函数的应用
- [redis] event driven framework source code analysis (single thread)
- 利用SSM框架实现用户登陆
- ShardingSphere-proxy-5.0.0分布式哈希取模分片实现(四)
- 52 classes 110 common components and frameworks
猜你喜欢

Handwriting database connection pool

Making unequal interval histogram with Matplotlib

Pytorch learning 09: basic matrix operations
![[redis] event driven framework source code analysis (single thread)](/img/72/ae961423832f217324007c81b6f9e5.png)
[redis] event driven framework source code analysis (single thread)

IDEA 提示 Duplicated code fragment (15 lines long)

聚宽 - 简单策略试验

SparkRDD 案例:计算总成绩

Idea prompt duplicated code fragment (15 lines long)

Record the use process of webscraper

从简单实例来看 left join 如何去重
随机推荐
【CYW20189】七、HCI命令格式详解
Example and description of lvgl Demo 1
[Others] analysis of got and PLT in ELF
3 minutes, take you to play with chat robot automation [top template]
What does container cloud mean? What is the difference with fortress machine?
4274. suffix expression
Read livedata sticky events
[dailyfresh] course record 2
Virtual variables and formatting characters in debugging
Idea prompt duplicated code fragment (15 lines long)
PM2 learning
3371. 舒适的奶牛
Find find files with different extensions
English语法_副词 - loud /aloud / loudly
今日内容
crf*. Handling of large BDB file
Dynamic programming-01 backpack, partition, etc. and subset, weight of the last stone
[dailyfresh] course record
【Redis】事件驱动框架源码分析(单线程)
Integer和int区别