• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Windows环境部署PbootCMS企业网站管理系统

武飞扬头像
一本正经学技术
帮助1

引用官方介绍:PbootCMS官网
PbootCMS是全新内核且永久开源免费的PHP企业网站开发建设管理系统,是一套高效、简洁、 强悍的可免费商用的PHP CMS源码,能够满足各类企业网站开发建设的需要。系统采用简单到想哭的模板标签,只要懂HTML就可快速开发企业网站。官方提供了大量网站模板免费下载和使用,将致力于为广大开发者和企业提供最佳的网站开发建设解决方案。

1、PHP7部署

1.1、下载PHP7

由于PbootCMS目前仅支持PHP7.0 版本,不支持PHP8版本,所以下载使用PHP7版本的最新小版本
下载PHP 7.4 (7.4.30)
关于non thread safe 和 thread safe,请参考PHP版本Non Thread Safe和Thread Safe如何选择?区别是什么?
由于nginx的配置使用FastCGI,这里下载使用non thread safe版本,即VC15 x64 Non Thread Safe (2022-Jun-07 22:15:51) php-7.4.30-nts-Win32-vc15-x64.zip
pecl扩展插件下载网址:http://pecl.php.net/

1.2、解压安装PHP7

解压下载的zip压缩包,到想要安装的目录并修改名称,如:D:\FreeProgram\php7
设置系统环境变量,在PATH中增加:D:\FreeProgram\php7

1.3、配置php7

参考文章windows下怎么安装php7?
解压的php7目录中包含php.ini-development和php.ini-production两个文件,将其中一个文件复制并修改名称为php.ini,并编辑此文件:

# 大概在761行处,修改extension_dir参数值
; On windows:
;extension_dir = "ext"
extension_dir = "D:/FreeProgram/php7/ext"
# windows系统的路径表示使用/

开通配置扩展插件

# 在913行处,去掉行首的;注释标记
extension=bz2
extension=curl
extension=ffi
extension=ftp
extension=fileinfo
extension=gd2
extension=gettext
extension=gmp
extension=intl
extension=imap
extension=ldap
extension=mbstring
extension=exif      ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
;extension=odbc
extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
;extension=pdo_odbc
extension=pdo_pgsql
extension=pdo_sqlite
extension=pgsql
extension=shmop

; The MIBS data available in the PHP distribution must be installed.
; See http://www.php.net/manual/en/snmp.installation.php
;extension=snmp

extension=soap
extension=sockets
extension=sodium
extension=sqlite3
extension=tidy
extension=xmlrpc
extension=xsl
学新通

1.4、验证环境

完成以上配置后,打开cmd命令窗口,并输入powershell,进入powershell中,或者直接在cmd命令窗口执行查看php版本。

php -v
# 返回以下版本信息,表示环境配置成功
PHP 7.4.30 (cli) (built: Jun  7 2022 15:36:03) ( NTS Visual C   2017 x64 )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

如果有警告信息提示,如下:
Warning: PHP Startup: Unable to load dynamic library ‘pdo_oci’ (tried: D:/FreeProgram/php7/ext\pdo_oci
则说明配置文件php.ini中的扩展插件不存在,可通过pecl扩展插件网址下载对应的插件文件,并放入到D:/FreeProgram/php7/ext目录中即可。(此方法未测试)
在D:/FreeProgram/php7/testdemo/目录下,新建php测试文件index.php,内容如下:

<?php
echo phpinfo();
?>

在cmd命令窗口进入此目录,并启动php服务

# 切换盘符
d:
# 切换目录
cd FreeProgram\php7\testdemo
# 启动php服务,-t 指定服务根目录
php -S localhost:8000 -t testdemo/
# 出现如下输出:
[Tue Aug 16 19:17:42 2022] PHP 7.4.30 Development Server (http://localhost:8000) started

通过浏览器访问此地址:http://localhost:8000 即可打开显示php版本信息网页
学新通


2、Nginx部署

2.1、下载Nginx

nginx下载页面
下载当前稳定最新版本(Stable version):nginx/Windows-1.22.0

2.2、解压nginx

解压下载的zip压缩包,并移动到D:\FreeProgram\nginx-1.22.0

2.3、检测nginx服务

启动nginx服务测试效果

# 进入doc命令窗口或Powershell窗口后,切换盘符
d:
# 切换目录
cd FreeProgram\nginx-1.22.0
# 启动nginx服务
start nginx
# nginx其他命令
nginx -s [ stop | quit | reopen | reload ]

打开网页查看启动后效果:http://127.0.0.1
学新通

2.4、修改nginx配置支持php

参考:PHP-FastCGI on Windows
修改nginx.conf配置文件

# 在server段中,增加index.php
# 如果注释此段注释,使用http://localhost/index.php可以访问,但使用http://locaohost无法访问,增加index.php后,使用两种链接都可访问
        location / {
            root   html;
            index  index.php index.html index.htm;
        }
# 在server段中,去掉关于PHP的注释
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
学新通

注:fastcgi_param 对应的/scripts改为$document_root

# 即改为如下:
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

以下操作不用配置即可

修改php配置文件php.ini
在750行处,增加doc_root的值为nginx的网站根目录
; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues. The alternate is to use the
; cgi.force_redirect configuration below
; http://php.net/doc-root
doc_root = D:/FreeProgram/nginx-1.22.0/html

在799行处,修改cgi.fix_pathinfo
; cgi.fix_pathinfo provides real PATH_INFO/PATH_TRANSLATED support for CGI. PHP’s
; previous behaviour was to set PATH_TRANSLATED to SCRIPT_FILENAME, and to not grok
; what PATH_INFO is. For more information on PATH_INFO, see the cgi specs. Setting
; this to 1 will cause PHP CGI to fix its paths to conform to the spec. A setting
; of zero causes PHP to behave as before. Default is 1. You should fix your scripts
; to use SCRIPT_FILENAME rather than PATH_TRANSLATED.
; http://php.net/cgi.fix-pathinfo
;cgi.fix_pathinfo=1

以上操作不用配置即可

启动php-cgi服务

# 在doc命令窗口或powershell窗口,进入此命令所在目录,执行以下命令
php-cgi.exe -d 127.0.0.1:9000 -c php.ini

验证是否启动成功

netstat -anob | findstr :9000

# 查看nginx服务
tasklist /fi "imagename eq nginx.exe"
# 返回结果如下:
映像名称                       PID 会话名              会话#       内存使用
========================= ======== ================ =========== ============
nginx.exe                     8700 Console                    1     13,952 K
nginx.exe                     3400 Console                    1     14,476 K

# 查看php-cgi服务
tasklist /fi "imagename eq php-cgi.exe"
# 返回结果如下:
映像名称                       PID 会话名              会话#       内存使用
========================= ======== ================ =========== ============
php-cgi.exe                   7724 Console                    1     10,180 K
学新通

把index.php测试文件放在nginx的网站根目录下D:\FreeProgram\nginx-1.22.0\html\index.php
启动nginx服务,打开网页,显示php版本信息页面。

php-cgi服务后台运行

下载RunHiddenConsole.zip
解压放在与php-cgi.exe相同目录即可,执行如下命令

RunHiddenConsole.exe php-cgi.exe -b 127.0.0.1:9000 -c php.ini

可编写bat脚本文件start-php-fcgi.bat,直接双击执行:

@ECHO OFF
ECHO Starting PHP FastCGI...
RunHiddenConsole.exe php-cgi.exe -b 127.0.0.1:9000 -c php.ini

如果需要开机自启动,可设置任务计划,执行此批处理脚本,并设置在文件当前目录执行。


3、MySQL安装

此处不再单独说明,本机环境已经安装有MySQL8,直接使用即可。
详细安装步骤可参考之前文章:
windows服务器环境MySQL 8.0.22压缩包安装记录
Linux服务器环境安装MySQL8.0.30(通用二进制文件-Generic Binaries)记录

4、PbootCMS部署

4.1、下载PbootCMS

进入PbootCMS官网下载最新版建站系统:PbootCMS官网
或者进入Gitee对应的仓库下载:PbootCMS码云仓库

4.2、解压下载的zip压缩包

解压下载的zip压缩包,得到PbootCMS-3.X文件夹目录,在nginx的目录下新建网站主目录,例如D:\FreeProgram\nginx-1.22.0\www,然后将解压出来的PbootCMS-3.X文件夹中的文件全部剪切到www目录下,如果需要备份,也可全部复制,以便于后期修改文件的恢复查看。此处使用复制全部文件的操作,执行后在cmd窗口使用dir查看目录文件如下:

D:\FreeProgram\nginx-1.22.0\www>dir
 驱动器 D 中的卷没有标签。
 卷的序列号是 441D-EFD2

 D:\FreeProgram\nginx-1.22.0\www 的目录

2022/08/17  08:50    <DIR>          .
2022/08/17  08:50    <DIR>          ..
2022/08/13  21:51                26 .gitattributes
2022/08/13  21:51               548 .gitignore
2022/08/13  21:51               547 admin.php
2022/08/13  21:51               569 api.php
2022/08/17  08:49    <DIR>          apps
2022/08/17  08:49    <DIR>          config
2022/08/17  08:50    <DIR>          core
2022/08/13  21:51    <DIR>          data
2022/08/13  21:51    <DIR>          doc
2022/08/13  21:51             4,286 favicon.ico
2022/08/13  21:51               524 index.php
2022/08/13  21:51            10,285 LICENSE
2022/08/13  21:51             4,599 README.md
2022/08/17  08:50    <DIR>          rewrite
2022/08/13  21:51                37 robots.txt
2022/08/17  08:50    <DIR>          static
2022/08/13  21:51    <DIR>          template
               9 个文件         21,421 字节
              10 个目录 1,223,167,938,560 可用字节

D:\FreeProgram\nginx-1.22.0\www>
学新通

4.3、修改相关配置

4.3.1、修改nginx配置

修改nginx.conf的配置,设置root主目录为www目录:

# 其他配置省略
        location / {
            root   www;
            index  index.php index.html index.htm;
        }
        
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   www;
        }
        
        location ~ \.php$ {
            root           www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
学新通

4.3.2、创建PbootCMS数据库

从解压出的PbootCMS文件中,找到static\backup\sql目录下的sql文件,此文件最新的sql文件名称为pbootcms_v316.sql,通过如下方式创建MySQL数据库:

D:\FreeProgram\nginx-1.22.0\www>mysql -uroot -p
Enter password: ******
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.28 MySQL Community Server - GPL

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create database pbootcms;
Query OK, 1 row affected (0.03 sec)

mysql> use pbootcms;
Database changed
mysql> source D:/FreeProgram/nginx-1.22.0/www/static/backup/sql/pbootcms_v316.sql;
Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)
# 此处省略其他导入成功输出信息
Query OK, 0 rows affected, 2 warnings (0.01 sec)

Query OK, 1 row affected (0.01 sec)

mysql> show tables;
 -------------------- 
| Tables_in_pbootcms |
 -------------------- 
| ay_area            |
| ay_company         |
| ay_config          |
| ay_content         |
| ay_content_ext     |
| ay_content_sort    |
| ay_diy_telephone   |
| ay_extfield        |
| ay_form            |
| ay_form_field      |
| ay_label           |
| ay_link            |
| ay_member          |
| ay_member_comment  |
| ay_member_field    |
| ay_member_group    |
| ay_menu            |
| ay_menu_action     |
| ay_message         |
| ay_model           |
| ay_role            |
| ay_role_area       |
| ay_role_level      |
| ay_site            |
| ay_slide           |
| ay_syslog          |
| ay_tags            |
| ay_type            |
| ay_user            |
| ay_user_role       |
 -------------------- 
30 rows in set (0.04 sec)
学新通

以上完成PbootCMS对应的MySQL数据库创建,库名称为pbootcms,用户使用root;
也可单独创建pbootcms专用用户create user 'pboot'@'%' identified by 'setyourpassword';,然后授权此用户pbootcms数据库的对应权限grant all on pbootcms.* to 'pboot'@'%';

4.3.4、修改pbootcms配置

修改目录D:\FreeProgram\nginx-1.22.0\www\config下的database.php文件,配置连接数据库信息:

<?php
/**
 * 主数据库连接参数,未配置的参数使用框架惯性配置
 * 如果修改为mysql数据库,请同时修改type和dbname两个参数
 */
return array(
    
    'database' => array(
        
        'type' => 'mysqli', // 数据库连接驱动类型: mysqli,sqlite,pdo_mysql,pdo_sqlite
        
        'host' => '127.0.0.1', // 数据库服务器
        
        'user' => 'root', // 数据库连接用户名
        
        'passwd' => 'yourpassword', // 数据库连接密码
        
        'port' => '3306', // 数据库端口
                          
        'dbname' => 'pbootcms' // 去掉注释,启用mysql数据库,注意修改前面的连接信息及type为mysqli
        
        //'dbname' => '/data/pbootcms.db' // 去掉注释,启用Sqlite数据库,注意修改type为sqlite
    )

);
学新通

4.4、启动服务

由于本机是调试环境,未设置开机自启动,需要手动分别启动所需服务:

4.4.1、启动前优化nginx配置

在启动前,对nginx配置文件及php配置文件进行了调整,nginx.conf文件内容如下:

#user  nobody;
worker_processes  1;

error_log  logs/error.log  notice;
events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;
    log_format    combinedio  '$remote_addr - $remote_user [$time_local] '
                              '"$request" $status $body_bytes_sent '
                              '"$http_referer" "$http_user_agent" $request_length $request_time $upstream_response_time';
    access_log logs/access.log combinedio;

    sendfile        on;

    keepalive_timeout  65;

    # PbootCMS配置文件
    include pbootcms.conf;
}
学新通

在conf目录下,新建pbootcms.conf文件,内容如下:

    server {
        listen       80;
        server_name  localhost;

        access_log  logs/pbootcms.access.log;
        error_log   logs/pbootcms.error.log;

        index       index.html index.htm index.php;
        root        www;

        # nginx 隐藏index.php
        location / {
            if (!-e $request_filename) {
                rewrite ^(.*)$ /index.php/$1 last;
                #rewrite ^(.*)$ /index.php?s=$1 last;
                break;
            }
        }

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           www;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }
学新通

4.4.2、启动前优化php配置

修改php配置文件php.ini,设置文件上传大小限制和表单提交大小限制:

# 在409行处,设置占用内存大小
memory_limit = 128M
# 在694行处,设置表单提交大小
post_max_size = 128M
# 在846行处,设置上传文件大小
upload_max_filesize = 200M
# 在849行处,设置单次上传数量
max_file_uploads = 20

4.4.3、启动服务

启动php服务:执行start-php-fcgi.bat脚本即可;
启动nginx服务:nginx.exe所在目录进入cmd命令窗口执行start nginx
启动成功后,从浏览器中打开localhost,成功显示网站页面:
学新通

后台管理页面:localhost/admin.php
学新通
初始账号及密码:admin/123456

完成于2022年08月16日、17日,记录于2022年11月12日00:31:13
【END】

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgfckkg
系列文章
更多 icon
同类精品
更多 icon
继续加载