找到2240个回复 (用户: 老虎会游泳)
  • 新注册的第一个用户会成为管理员。

    由于报错影响cookie发送,需要使用防掉线链接登录。

    Screenshot_20220201_015230.jpg

  • 步骤16执行完成之后,以下页面就已经能打开了:

    http://localhost:8080/q.php/

    虽然有很多很多报错,但是已经能看到首页内容了。

    明天再修复报错,顺便再介绍一下怎么用git更新代码。

    Screenshot_20220201_014632_com.UCMobile.jpg

  • 设置好后台运行之后,把nginx、mysql和php-fpm都启动一下,就可以执行后续步骤了。命令:

    # 启动mysql
    ~/../usr/etc/init.d/mysql start
    
    # 启动nginx
    nginx
    
    # 启动php-fpm
    php-fpm
    

    请忽略所有报错,报错肯定是因为程序已经在运行。

    执行完成后,用pstree检查是否所有组件都在运行。

    pstree
    

    这是正确的结果。请忽略上面显示的数字,数字可能是任何值。只要mysqlnginxphp-fpm都出现就可以:

    Screenshot_20220201_012140.jpg

  • 如何保持Termux后台运行

    @希望自己长胖胖 说,他在进行一系列步骤之后无法访问到8080端口,并且pstree显示nginx退出了。

    为什么会发生这种情况?因为安卓会杀后台。

    对于华为,需要进行如下设置:

    1. 设置里搜索“自启动”,然后对Termux选“手动管理”,勾选“允许后台活动”。

    Screenshot_20220201_010517.jpg

    Screenshot_20220201_010524_com.huawei.systemmanager.jpg

    1. 设置里搜索“电池优化”,下拉“不允许”,选择“所有应用”,找到“Termux”,然后选成“不允许”。

    Screenshot_20220201_010632.jpg

    Screenshot_20220201_010701.jpg

    Screenshot_20220201_010751_com.android.settings.jpg

  • 步骤14:确认装好了PHP。

    为什么有一堆报错?还记得我说的步骤1吗?虎绿林程序目前用PHP8.1打开就是会有这么多报错。

    为了确认你确实装好了PHP,你可以执行以下命令:

    echo '<?php phpinfo();' > ~/hu60wap6/src/phpinfo.php
    

    Screenshot_20220201_004007.jpg

    然后访问这个地址:

    http://localhost:8080/phpinfo.php/path-info/test

    Screenshot_20220201_003642_com.UCMobile.jpg

    嗯,确实装好了。

    但是要想打开虎绿林程序,就只能等我的步骤1完成了。

  • 附件内容,不是步骤

    为了防止附件过期,现贴出步骤12中nginx.conf文件的全部内容:

    
    #user  nobody;
    worker_processes  1;
    
    #error_log  logs/error.log;
    #error_log  logs/error.log  notice;
    #error_log  logs/error.log  info;
    
    #pid        logs/nginx.pid;
    
    
    events {
        worker_connections  1024;
    }
    
    
    http {
        include       mime.types;
        default_type  application/octet-stream;
    
        #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
        #                  '$status $body_bytes_sent "$http_referer" '
        #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
        #access_log  logs/access.log  main;
    
        sendfile        on;
        #tcp_nopush     on;
    
        #keepalive_timeout  0;
        keepalive_timeout  65;
    
        #gzip  on;
    
        server {
            listen       8080;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
    
            location / {
                root   /data/data/com.termux/files/usr/share/nginx/html;
                index  index.html index.htm index.php;
            }
    
            #error_page  404              /404.html;
    
            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   /data/data/com.termux/files/usr/share/nginx/html;
            }
    
            # proxy the PHP scripts to Apache listening on 127.0.0.1:80
            #
            #location ~ \.php$ {
            #    proxy_pass   http://127.0.0.1;
            #}
    
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            #
            location ~ [^/]\.php(/|$) {
                root   /data/data/com.termux/files/usr/share/nginx/html;
                fastcgi_pass   unix:/data/data/com.termux/files/usr/var/run/php-fpm.sock;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
                include        fastcgi_params;
    
                # parse and set $_SERVER['PATH_INFO']
                set $real_script_name $fastcgi_script_name;
                if ($fastcgi_script_name ~ "^(.+?\.php)(/.+)$") {
                    set $real_script_name $1;
                    set $path_info $2;
                }
                fastcgi_param SCRIPT_FILENAME $document_root$real_script_name;
                fastcgi_param SCRIPT_NAME $real_script_name;
                fastcgi_param PATH_INFO $path_info;
            }
    
            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            #location ~ /\.ht {
            #    deny  all;
            #}
        }
    
    
        # another virtual host using mix of IP-, name-, and port-based configuration
        #
        #server {
        #    listen       8000;
        #    listen       somename:8080;
        #    server_name  somename  alias  another.alias;
    
        #    location / {
        #        root   html;
        #        index  index.html index.htm;
        #    }
        #}
    
    
        # HTTPS server
        #
        #server {
        #    listen       443 ssl;
        #    server_name  localhost;
    
        #    ssl_certificate      cert.pem;
        #    ssl_certificate_key  cert.key;
    
        #    ssl_session_cache    shared:SSL:1m;
        #    ssl_session_timeout  5m;
    
        #    ssl_ciphers  HIGH:!aNULL:!MD5;
        #    ssl_prefer_server_ciphers  on;
    
        #    location / {
        #        root   html;
        #        index  index.html index.htm;
        #    }
        #}
    
    }
    
  • 步骤12:让nginx支持PHP:

    下载 nginx.conf(3.20 KB) 替换原始配置文件,方法如下

    # 保留原始配置文件备查
    cp ~/../usr/etc/nginx/nginx.conf ~/../usr/etc/nginx/nginx.conf.default
    
    # 替换配置文件
    curl https://vkceyugu.cdn.bspapp.com/VKCEYUGU-cc8cf08f-49f5-4fc5-83c3-ed2a683704d4/d1a6a650-c38b-4d66-823b-626655cd068b.conf > ~/../usr/etc/nginx/nginx.conf
    
    # 让nginx重载配置文件
    nginx -s reload
    

    Screenshot_20220201_002634.jpg

  • 步骤11:启动PHP

    执行以下命令:

    php-fpm
    

    查看php是否启动:

    pstree
    

    Screenshot_20220201_002118.jpg

  • mmexport1643594020410.jpg

  • 更正,403并不是因为文件权限不正确,而是因为nginx目前的配置并不支持PHP,并且默认首页没了,所以得到403。下一步就是启动PHP,然后让nginx支持PHP。

    这一步比较复杂,等我研究一下。

  • 步骤10:看看网站现在的状态。

    # 安装curl
    apt install curl
    
    # 用curl查看网站状态
    curl -v http://localhost:8080/
    

    Screenshot_20220131_233345.jpg

    网站403了,看起来文件权限不正确啊。

    下一步就是修复权限。

    为什么不用浏览器看?因为浏览器有缓存,看不到最新变化。

  • Linux命令小知识,不是操作步骤

    @希望自己长胖胖 说他无法用exitmysql命令里退出。

    f16e3b8b34de0942dadb8d090558f177143354.jpg

    为什么会发生这种情况?因为他先输入了nginx,而nginx不是mysql支持的命令,所以mysql把它解释为SQL语句。

    SQL语句必须以分号结束,而@希望自己长胖胖 一直没有输入分号,所以mysql一直在等待分号出现,既不报错,也不退出。

    此时,只需输入分号,再输入exit即可退出。或者可以改按CTRL+C(就是先按Termux显示的CTRL按钮,再输入字母c),这也是退出。

    现在你应该理解教程里为什么要叫你输入exit;了。

  • 步骤7:继续在mysql命令里,执行show tables;看看表创建好了没有,然后执行exit;mysql命令里退出。

    -- 查看表有没有创建好
    show tables;
    
    -- 从mysql命令里退出
    exit;
    

    如果你发现自己不能从mysql命令里退出,请连续输入exit;别忘了分号,它是关键。或者,你也可以改按CTRL+C快捷键(就是先按Termux显示的CTRL按钮,再输入字母c),这也能退出。

    Screenshot_20220131_230208_com.termux.jpg

  • 步骤9:把虎绿林源代码链接到网站根目录。

    nginx的网站根目录在~/../usr/share/nginx/html

    可以通过以下命令查看其内容:

    ls ~/../usr/share/nginx/html
    

    Screenshot_20220131_231344.jpg

    我们不想要这些,所以直接重命名,然后把虎绿林源代码的src链接过去。

    注意不是复制过去。链接后文件依然在~/hu60wap6/src里面,只是在~/../usr/share/nginx/html也能看到罢了。

    执行命令:

    # 旧文件夹改名
    mv ~/../usr/share/nginx/html ~/../usr/share/nginx/html.default
    
    # 链接虎绿林源代码
    ln -s ~/hu60wap6/src ~/../usr/share/nginx/html
    
    # 检查链接是否正确
    ls ~/../usr/share/nginx/html
    

    Screenshot_20220131_231645.jpg

  • 步骤8:启动nginx

    运行以下命令:

    nginx
    

    啥也不会输出。怎么确定启动了nginx?运行以下命令:

    pstree
    

    Screenshot_20220131_230749.jpg

    看到nginx了,说明启动了。

    然后就能访问如下页面:

    http://localhost:8080/

    内容是这个:

    Screenshot_20220131_230931.jpg

  • 步骤6:连接mysql,创建数据库和用户,然后导入虎绿林建表语句。

    执行mysql命令,就能自动登录到mysql里。

    mysql
    

    不需要密码。

    Screenshot_20220131_225331.jpg

    然后执行以下SQL语句(--开头的是注释):

    -- 创建数据库hu60
    create database hu60;
    
    -- 创建用户hu60,密码hu60,并允许它访问数据库hu60
    grant all privileges on hu60.* to hu60@localhost identified by 'hu60';
    
    -- 刷新权限,让创建的用户生效
    flush privileges;
    
    -- 切换到新建的hu60数据库
    use hu60;
    
    -- 导入虎绿林建表语句
    source ~/hu60wap6/src/db/mysql.sql
    

    Screenshot_20220131_230041_com.termux.jpg

  • 步骤5:启动MySQL。

    ~/../usr/etc/init.d/mysql start
    

    Screenshot_20220131_224624.jpg


    以下不是步骤,是知识,留给以后备用,不要马上执行。

    # 启动MySQL
    ~/../usr/etc/init.d/mysql start
    
    # 停止MySQL
    ~/../usr/etc/init.d/mysql stop
    
    # 重启MySQL
    ~/../usr/etc/init.d/mysql restart
    
    # 查看MySQL状态
    ~/../usr/etc/init.d/mysql status
    

    呃,好像除了启动,其他命令都没效果,报错说pid文件不存在。不管了,启动了就行。

  • @上善若水,默认源很快。清华源在不同的地区速度不同,不一定比默认源快。

  • 步骤4:用git获取虎绿林源代码。

    执行如下命令:

    # 回到主目录
    cd
    
    # 下载源代码
    git clone --recursive https://gitee.com/hu60t/hu60wap6.git
    

    Screenshot_20220131_224038_com.termux.jpg

  • 步骤3:安装gitmysqlphpnginxmemcached

    注意Termux上的mysql叫做mariadb

    此外,和nginx搭配使用的PHP叫php-fpm。至于叫做php的包嘛,它只提供名为php的命令行程序。我们也需要这个命令行程序,安装虎绿林程序时可以帮我们自动复制几个文件。

    下面正式开始操作:


    打开termux,依次执行以下命令。

    #开头的不是命令,是注释,执行不是#开头的行,每行是一条命令。执行命令的方法是,把命令复制粘贴到Termux,然后回车。

    # 更新软件包列表
    apt update
    
    # 安装软件包
    apt install git mariadb php php-fpm nginx memcached
    

    它会问你是否要下载数百MB文件,回复y

    截图和文字不一致说明看文字,别看截图。截图不能修改,文字可以。修改后的才是正确的。

    Screenshot_20220131_223201_com.termux.jpg

    等待下载完成。