系统安装说明书

发布时间 2023-11-28 19:40:00作者: @菜鸟爱学习@

1、安装lnmp

1、 wget https://soft.lnmp.com/lnmp/lnmp2.0.tar.gz
2、./install.sh

2、下载代码

git clone https://gitee.com/sdyansong/zycx_system.git

3、配置nginx.conf

server
    {
        listen 80 default_server reuseport;
        #listen [::]:80 default_server ipv6only=on;
        server_name _;
        index index.html index.htm index.php;
        root  /home/wwwroot/zycx_system/public;

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }
#default    
server
    {
        listen 8080 default_server reuseport;
        #listen [::]:80 default_server ipv6only=on;
        server_name _;
        index index.html index.htm index.php;
        root  /home/wwwroot/default;

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }

4、重启服务器

lnmp restart

5、修改数据库上传文件大小

LNMP环境修改上传文件大小限制

 

    如果网页上传文件大小大于nginx或php设定的值,就会造成无法上传,显示IO error错误。

    如何解决这个问题呢?我们需要更改两个配置:

1.  nginx配置文件:

    vim /usr/local/nginx/conf/nginx.conf

    更改client_max_body_size 后面的值。

 

2.  php.ini:

    vim /usr/local/php/etc/php.ini

    更改post_max_size 和upload_max_filesize 后面的值。

 

    修改完成后,重启nginx和php即可。

6、导入数据库。

将数据库上传到服务器,利用命令导入数据库

 

source zhengyichuxing.sql

 7、编辑nginx.conf文件

server
    {
        listen 80 default_server reuseport;
        

    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Methods' 'OPTION, POST, GET';
    add_header 'Access-Control-Allow-Headers' 'X-Requested-With, Content-Type';

    if ($request_method = 'OPTIONS') {
           return 204;
    }



    #listen [::]:80 default_server ipv6only=on;
        server_name _;
        index index.html index.htm index.php;
        root  /home/wwwroot/zycx_system/public;

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

    include rewrite/thinkphp.conf;

        
    location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }
#default    
server
    {
        listen 8080 default_server reuseport;
        #listen [::]:80 default_server ipv6only=on;
        server_name _;
        index index.html index.htm index.php;
        root  /home/wwwroot/default;

        #error_page   404   /404.html;

        # Deny access to PHP files in specific directory
        #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

        include enable-php.conf;

        location /nginx_status
        {
            stub_status on;
            access_log   off;
        }

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        location ~ /.well-known {
            allow all;
        }

        location ~ /\.
        {
            deny all;
        }

        access_log  /home/wwwlogs/access.log;
    }

8、报500错误

修改conf下的fastcgi.conf  注释 #fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";

9、报错

file_put_contents(/home/wwwroot/zycx_system/runtime/temp/dc762373d8f41a72ff77e0c42ad9e62d.php): failed to open stream: Permission denied

chmod -R 777 runtime

10、 报错

致命错误: Call to undefined function captcha_src()

composer require topthink/think-captcha=1.*

官方的5.0版本的扩展库版本号都是1.*,2.0版本均为ThinkPHP5.1版本专用。
如果报错如下,就把根目录下的composer.json和composer.lock删除后再执行。去vendor/topthink/下查看是否有think-captch

11、

Array and string offset access syntax with curly braces is deprecated

原因是因为MySQL7.4版本不再支持{}写法,统一为数组[ ],解决很简单通过修改tp5的Query.php文件的字段中

$seq = (ord($value{0}) % $rule['num']) + 1; 的$value{0}大括号改为$value[0]

12、首页出来后,没有css样式,是因为缺少css样式信息

直接把文件夹复制到里面

后面绑定域名