在 php 7.4 上使用 Ubuntu 20.04 和 phpmyadmin 如何设置非本地主机连接

在 php 7.4 上使用 Ubuntu 20.04 和 phpmyadmin 如何设置非本地主机连接

我使用的是 HEADLESS cli 服务器,因此本地主机上不会有 GUI,SSH 不允许浏览器工作,并且为远程显示添加 xservice 对于此服务器来说确实不值得。我读了一篇被贬低的文章,其中说您可以允许子网连接,但是使用此配置时 .conf 的结构不再有效,因为它已更新。

我需要知道在哪里可以找到 phpmyadmin.conf,以及要添加哪些行才能允许我的子网从远程 Web 浏览器进行连接。搜索文件夹堆栈后,我找到了phpmyadmin.conf

./etc/dbconfig-common/
./etc/apache2/conf-available/
./etc/apache2/conf-enabled/

我需要 sudo 才能访问 dbconfig-common 中的那个,我看到了 localhost,但不清楚这是否是供服务自身访问的。在以下文件夹中,我没有看到 localhost 是唯一允许的连接,因此不确定要在那里进行什么更改。

在正常桌面模式下,这不是问题,但是当这是一个仅通过 SSH 的 CLI 的服务器时,我不明白为什么没有明确的文档来解决这个问题,因为我确信没有人会将桌面添加到无头服务器来执行此操作,这违背了无头服务器的想法。

谢谢您的帮助,

Apache 请求的内容000-default.conf

<VirtualHost *:80>
        # The ServerName directive sets the request scheme, hostname and port that
        # the server uses to identify itself. This is used when creating
        # redirection URLs. In the context of virtual hosts, the ServerName
        # specifies what hostname must appear in the request's Host: header to
        # match this virtual host. For the default virtual host (this file) this
        # value is not decisive as it is used as a last resort host regardless.
        # However, you must set it for any further virtual host explicitly.
        #ServerName www.example.com

        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        # For most configuration files from conf-available/, which are
        # enabled or disabled at a global level, it is possible to
        # include a line for only one particular virtual host. For example the
        # following line enables the CGI configuration for this host only
        # after it has been globally disabled with "a2disconf".
        #Include conf-available/serve-cgi-bin.conf
</VirtualHost>

#vim: syntax=apache ts=4 sw=4 sts=4 sr noet

或默认。

location ~ \.php$ {
    include snippets/fastcgi-php.conf;

    # With php7.0-cgi alone:
    fastcgi_pass 127.0.0.1:9000;
    # With php7.0-fpm:
    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}

不确定哪一个是活跃的。我发现的搜索结果中似乎都讨论了这两个问题。

所以我认为我已修复了网站针对您的请求的格式问题。虚拟主机部分没有被注释掉,但为了应用正确的格式,我不得不将其注释掉,这样它才能显示出来。

太糟糕了,没有办法像文件中显示的那样添加它。而且没有人足够礼貌地解释如何做。

结果 服务器单元 mariadb.service 无法找到。

尝试清理并重新安装时出现此问题

sudo apt autoremove
Reading package lists... Done
Building dependency tree
Reading state information... Done
sh: 0: getcwd() failed: No such file or directory
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
sh: 0: getcwd() failed: No such file or directory
Setting up mysql-server-8.0 (8.0.23-0ubuntu0.20.04.1) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
Renaming removed key_buffer and myisam-recover options (if present)
mysqld will log errors to /var/log/mysql/error.log
mysqld is running as pid 474814
AppArmor parser error for /etc/apparmor.d/usr.sbin.mysqld in /etc/apparmor.d/usr.sbin.mysqld at line 9: Could not open 'abstractions/mysql'
Failed to preset unit: File mysql.service: Link has been severed
/usr/bin/deb-systemd-helper: error: systemctl preset failed on mysql.service: No such file or directory
Failed to start mysql.service: Unit mysql.service not found.
invoke-rc.d: initscript mysql, action "start" failed.
Unit mysql.service could not be found.
dpkg: error processing package mysql-server-8.0 (--configure):
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 mysql-server-8.0
sh: 0: getcwd() failed: No such file or directory
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@panasonic:/var/run/mysqld#
root@panasonic:/var/run/mysqld# sudo apt install mariadb-server
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libevent-core-2.1-7 libevent-pthreads-2.1-7
Use 'sudo apt autoremove' to remove them.
The following additional packages will be installed:
  galera-3 libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libmysqlclient21 libsnappy1v5
  libterm-readkey-perl mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common
  mariadb-server-10.3 mariadb-server-core-10.3 socat
Suggested packages:
  libclone-perl libmldbm-perl libnet-daemon-perl libsql-statement-perl mailx mariadb-test tinyca
sh: 0: getcwd() failed: No such file or directory
The following packages will be REMOVED:
  mysql-client-8.0 mysql-client-core-8.0 mysql-server-8.0 mysql-server-core-8.0
The following NEW packages will be installed:
  galera-3 libconfig-inifiles-perl libdbd-mysql-perl libdbi-perl libmysqlclient21 libsnappy1v5
  libterm-readkey-perl mariadb-client-10.3 mariadb-client-core-10.3 mariadb-common mariadb-server
  mariadb-server-10.3 mariadb-server-core-10.3 socat
0 upgraded, 14 newly installed, 4 to remove and 0 not upgraded.
1 not fully installed or removed.
Need to get 0 B/20.5 MB of archives.
After this operation, 19.8 MB disk space will be freed.
Do you want to continue? [Y/n] y
sh: 0: getcwd() failed: No such file or directory
sh: 0: getcwd() failed: No such file or directory
sh: 0: getcwd() failed: No such file or directory
Preconfiguring packages ...
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
(Reading database ... 134419 files and directories currently installed.)
Removing mysql-server-8.0 (8.0.23-0ubuntu0.20.04.1) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: error processing package mysql-server-8.0 (--remove):
 installed mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
Failed to preset unit: File mysql.service: Link has been severed
/usr/bin/deb-systemd-helper: error: systemctl preset failed on mysql.service: No such file or directory
Failed to start mysql.service: Unit mysql.service not found.
invoke-rc.d: initscript mysql, action "start" failed.
Unit mysql.service could not be found.
dpkg: error while cleaning up:
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 mysql-server-8.0
Processing was halted because there were too many errors.
sh: 0: getcwd() failed: No such file or directory
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@panasonic:/var/run/mysqld#

但删除尝试看起来好像没有可mysql-server-8.0删除的。删除 mysql 的结果:

root@panasonic:/var/run/mysqld# sudo apt remove mysql-server-8.0
Reading package lists... Done
Building dependency tree
Reading state information... Done
sh: 0: getcwd() failed: No such file or directory
The following packages will be REMOVED:
  mysql-server-8.0
0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
1 not fully installed or removed.
After this operation, 1,481 kB disk space will be freed.
Do you want to continue? [Y/n] y
sh: 0: getcwd() failed: No such file or directory
(Reading database ... 134419 files and directories currently installed.)
Removing mysql-server-8.0 (8.0.23-0ubuntu0.20.04.1) ...
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
dpkg: error processing package mysql-server-8.0 (--remove):
 installed mysql-server-8.0 package pre-removal script subprocess returned error exit status 1
dpkg: too many errors, stopping
Failed to stop mysql.service: Unit mysql.service not loaded.
invoke-rc.d: initscript mysql, action "stop" failed.
Failed to preset unit: File mysql.service: Link has been severed
/usr/bin/deb-systemd-helper: error: systemctl preset failed on mysql.service: No such file or directory
Failed to start mysql.service: Unit mysql.service not found.
invoke-rc.d: initscript mysql, action "start" failed.
Unit mysql.service could not be found.
dpkg: error while cleaning up:
 installed mysql-server-8.0 package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 mysql-server-8.0
Processing was halted because there were too many errors.
sh: 0: getcwd() failed: No such file or directory
E: Sub-process /usr/bin/dpkg returned an error code (1)
root@panasonic:/var/run/mysqld#

这一切看上去都很矛盾。

答案1

根据评论,问题似乎是您将root其用作 SQL 数据库的登录名。出于多种安全原因,这是被禁止的,因此您需要在 MySQL(或 MariaDB)中创建一个可供 osTicket 使用的用户帐户。

这是你做的:

  1. 在您的服务器上,连接到数据库:
    sudo mysql
    
  2. 为 osTicket 创建数据库:
    mysql> CREATE DATABASE `osticket` DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
    
  3. 为 osTicket 创建用户:
    mysql> CREATE USER 'ostkt'@'localhost' IDENTIFIED WITH mysql_native_password BY 'superSecretPassword!123';
    
    笔记:一定要改变 ostkt 更改为您喜欢的内容。还可以更改 superSecretPassword!123 改为更好的版本。如果数据库与 Web 服务器位于不同的系统上,则需要替换 localhost 带百分号。例如:
    mysql> CREATE USER 'ostkt'@'%' IDENTIFIED WITH mysql_native_password BY 'superSecretPassword!123';
    
  4. 授予新帐户对新数据库的完全访问权限:
    mysql> GRANT ALL ON `osticket`.* TO 'ostkt'@'localhost';
    
    笔记:务必更换 localhost % 如果数据库与 Web 服务器位于不同的服务器上。
  5. 向 osTicket 配置文件提供凭据
  6. 继续设置 osTicket

至于“没有人礼貌地解释如何”,请理解 AskUbuntu(以及许多其他 StackExchange 网站)是由志愿者而不是员工提供支持的。人们在有空闲时间并且具备必要的知识和能力时会选择问题来提供帮助。

希望有了这个答案,你可以继续安装 osTicket

相关内容