拯救php性能的神器webman-使用后台webman-admin
在webman的插件市场里面发现了这个 webman-admin
安装的话很简单,就是在已经安装了 webman 的目录里面执行 composer require -W webman/admin
安装过程提示这些
Using version ^0.6.24 for webman/admin ./composer.json has been updated Running composer update webman/admin --with-all-dependencies Loading composer repositories with package information Updating dependencies Lock file operations: 34 installs, 0 updates, 0 removals - Locking brick/math (0.12.1) - Locking carbonphp/carbon-doctrine-types (2.1.0) - Locking doctrine/inflector (2.0.10) - Locking guzzlehttp/guzzle (7.8.1) - Locking guzzlehttp/promises (2.0.2) - Locking guzzlehttp/psr7 (2.6.2) - Locking illuminate/bus (v10.48.2) - Locking illuminate/collections (v10.48.2) - Locking illuminate/conditionable (v10.48.2) - Locking illuminate/container (v10.48.2) - Locking illuminate/contracts (v10.48.2) - Locking illuminate/database (v10.48.2) - Locking illuminate/events (v10.48.2) - Locking illuminate/macroable (v10.48.2) - Locking illuminate/pagination (v10.48.2) - Locking illuminate/pipeline (v10.48.2) - Locking illuminate/support (v10.48.2) - Locking intervention/image (2.7.2) - Locking nesbot/carbon (2.72.3) - Locking psr/clock (1.0.0) - Locking psr/http-client (1.0.3) - Locking psr/http-factory (1.0.2) - Locking psr/http-message (2.0) - Locking psr/simple-cache (3.0.0) - Locking ralouphie/getallheaders (3.0.3) - Locking symfony/deprecation-contracts (v3.4.0) - Locking symfony/polyfill-mbstring (v1.29.0) - Locking symfony/polyfill-php80 (v1.29.0) - Locking symfony/translation (v6.4.4) - Locking symfony/translation-contracts (v3.4.1) - Locking voku/portable-ascii (2.0.1) - Locking webman/admin (v0.6.24) - Locking webman/captcha (v1.0.2) - Locking webman/event (v1.0.5) Writing lock file Installing dependencies from lock file (including require-dev) Package operations: 34 installs, 0 updates, 0 removals - Installing brick/math (0.12.1): Extracting archive - Installing guzzlehttp/promises (2.0.2): Extracting archive - Installing ralouphie/getallheaders (3.0.3): Extracting archive - Installing psr/http-message (2.0): Extracting archive - Installing psr/http-factory (1.0.2): Extracting archive - Installing guzzlehttp/psr7 (2.6.2): Extracting archive - Installing voku/portable-ascii (2.0.1): Extracting archive - Installing symfony/translation-contracts (v3.4.1): Extracting archive - Installing symfony/polyfill-mbstring (v1.29.0): Extracting archive - Installing symfony/deprecation-contracts (v3.4.0): Extracting archive - Installing symfony/translation (v6.4.4): Extracting archive - Installing symfony/polyfill-php80 (v1.29.0): Extracting archive - Installing psr/clock (1.0.0): Extracting archive - Installing carbonphp/carbon-doctrine-types (2.1.0): Extracting archive - Installing nesbot/carbon (2.72.3): Extracting archive - Installing illuminate/macroable (v10.48.2): Extracting archive - Installing psr/simple-cache (3.0.0): Extracting archive - Installing illuminate/contracts (v10.48.2): Extracting archive - Installing illuminate/conditionable (v10.48.2): Extracting archive - Installing illuminate/collections (v10.48.2): Extracting archive - Installing doctrine/inflector (2.0.10): Extracting archive - Installing illuminate/support (v10.48.2): Extracting archive - Installing illuminate/pipeline (v10.48.2): Extracting archive - Installing illuminate/bus (v10.48.2): Extracting archive - Installing illuminate/container (v10.48.2): Extracting archive - Installing psr/http-client (1.0.3): Extracting archive - Installing webman/event (v1.0.5): Extracting archive - Installing webman/captcha (v1.0.2): Extracting archive - Installing intervention/image (2.7.2): Extracting archive - Installing illuminate/pagination (v10.48.2): Extracting archive - Installing illuminate/events (v10.48.2): Extracting archive - Installing illuminate/database (v10.48.2): Extracting archive - Installing guzzlehttp/guzzle (7.8.1): Extracting archive - Installing webman/admin (v0.6.24): Extracting archive > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install Create config/plugin/webman/event > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install > support\Plugin::install Create plugin/admin 17 package suggestions were added by new dependencies, use `composer suggest` to see details. Generating autoload files 16 packages you are using are looking for funding. Use the `composer fund` command to find out more!
服务要重新启动一下 php start.php start
由于我们之前将监听端口改为了 127.0.0.1:8787,所以这里可以直接访问 http://127.0.0.1:8787/app/admin
可以看到这样的安装界面
然后就按照这个配置一下,填数据库密码,然后下一步,提示这个
这就配置一下后台用户和密码就行了
好了,提示是需要重启后才能生效。
不过我这里没重启,也能进入后台,看到登录界面。
然后就拿刚刚的用户名称和密码登录进去呗。
然后就是这个后台首页了
随便点了几个页面,感觉后台不错。
这还有个构建表单的页面,挺好
然后我就想这个地方监控了8787端口 ,总不能一直这样访问吧。还是配置个虚拟域名吧。
然后就是老生长谈了。
编辑host sudo gedit /etc/hosts
增加一行 127.0.0.1 local.webmanadmin.com
增加文件 sudo touch /etc/nginx/sites-available/local.webmanadmin.com.conf
编辑文件内容如下:
server { listen 80; index index.php index.html index.htm index.nginx-debian.html; server_name local.webmanadmin.com; location / { 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; # 转发Cookie,设置 SameSite proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict"; # 执行代理访问真实服务器 proxy_pass http://127.0.0.1:8787; } }
来到文件夹 cd /etc/nginx/sites-enabled
设置软链接 sudo ln -s /etc/nginx/sites-available/local.webmanadmin.com.conf local.webmanadmin.com.conf
然后重启 nginx sudo systemctl restart nginx.service
然后就访问
我发现登录的时候验证码总是提示错误,后来我查了一下 把 nginx 配置里面的这个proxy_cookie_path改了一下
proxy_cookie_path /app/ /;
之后重启nginx sudo systemctl restart nginx.service
重启webman php start.php start 就好了。
我以为是这里path的问题,然后我又改回去了,又重新重启,发现登录没问题,感觉这里挺奇怪的,不过还好现在能登录也没问题了。
然后我又经过匿名浏览器的尝试,发现还是验证码有问题。看来这里有缓存啊。
于是又改了配置,发现匿名浏览器验证码也可以了。
最终的配置还是要设置这个path 最终的nginx配置如下:
server { listen 80; index index.php index.html index.htm index.nginx-debian.html; server_name local.webmanadmin.com; location / { 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; # 转发Cookie,设置 SameSite # proxy_cookie_path / "/; secure; HttpOnly; SameSite=strict"; proxy_cookie_path /app/ /; # 执行代理访问真实服务器 proxy_pass http://127.0.0.1:8787; } }
有了这个管理后台,开发也算方便了起来,性能上面也能兼顾,蛮好的。