我使用 nginx 和 gunicorn 部署了一个 django 应用程序,昨天我尝试修改我的设置以将 wordpress 页面作为登录页面。
我按照这个教程进行了基本安装https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-lemp-on-ubuntu-18-04 由于反复出现数据库连接错误,我无法显示 wordpress 页面。从那时起,我一直在互联网上搜索,现在我必须承认我需要一些帮助。我搞不清楚发生了什么。
这是我的 etc/nginx/sites-available/conf:
server {
server_name example.com www.example.com;
root /var/www/html;
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/myexample.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/myexample.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
index index.php index.html index.htm index.nginx-debian.html;
location = /favicon.ico { log_not_found off; access_log off; }
location = /robots.txt { log_not_found off; access_log off; allow all; }
location ~* \.(css|gif|ico|jpeg|jpg|js|png)$ {
expires max;
log_not_found off;
}
location / {
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
这是我的 wordpress 配置文件 /var/www/html/wp-config.php
define('WP_HOME','https://www.myexample.com');
define('WP_SITEURL','https://www.myexample.com');
define( 'DB_NAME', 'db1' );
/** MySQL database username */
define( 'DB_USER', 'myuser' );
/** MySQL database password */
define( 'DB_PASSWORD', 'mypassword' );
/** MySQL hostname */
define( 'DB_HOST', 'db1.cve345mgm.eu-west-3.rds.amazonaws.com' );
/** Database Charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The Database Collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
define('AUTH_KEY', 'authkeypassword');
define('SECURE_AUTH_KEY', 'secureauthkeypassword');
define('LOGGED_IN_KEY', 'loggedinkeypassword');
define('NONCE_KEY', 'noncekeypassword');
define('AUTH_SALT', 'authsaltpass');
define('SECURE_AUTH_SALT', 'securauthsaltpass');
define('LOGGED_IN_SALT', 'loggedinsaltpass');
define('NONCE_SALT', 'Mnocnesaltpass');
define('FS_METHOD','direct');
define( 'WP_DEBUG', false );
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';
define('WP_ALLOW_REPAIR', true);
我可以确认此文件中的密码与我在mysql中设置的密码相同。
当我尝试使用以下命令连接到 mysql 时:
mysql -u myser -h db1.cve345mgm.eu-west-3.rds.amazonaws.com -p
我收到以下错误:
ERROR 2003 (HY000): Can't connect to MySQL server on 'db1.cve345mgm.eu-west-3.rds.amazonaws.com' (110).
但是,我使用 nmap 检查了主机连接,它已启动并正在运行:
All 1000 scanned ports on db1.cve345mgm.eu-west-3.rds.amazonaws.com (xxx.xx.xxx) are filtered
Nmap done: 1 IP address (1 host up) scanned in 82.14 seconds
此外,这里是 mysql-log 的输出:
2020-08-31T23:21:58.350728Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentat$
2020-08-31T23:21:58.352669Z 0 [Note] /usr/sbin/mysqld (mysqld 5.7.31-0ubuntu0.18.04.1) starting as process 26674 ...
2020-08-31T23:21:58.357638Z 0 [Warning] One can only use the --user switch if running as root
2020-08-31T23:21:58.360084Z 0 [Note] InnoDB: PUNCH HOLE support available
2020-08-31T23:21:58.360107Z 0 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2020-08-31T23:21:58.360112Z 0 [Note] InnoDB: Uses event mutexes
2020-08-31T23:21:58.360116Z 0 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2020-08-31T23:21:58.360121Z 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
2020-08-31T23:21:58.360125Z 0 [Note] InnoDB: Using Linux native AIO
2020-08-31T23:21:58.360371Z 0 [Note] InnoDB: Number of pools: 1
2020-08-31T23:21:58.360478Z 0 [Note] InnoDB: Using CPU crc32 instructions
2020-08-31T23:21:58.365097Z 0 [Note] InnoDB: Initializing buffer pool, total size = 128M, instances = 1, chunk size = 128M
2020-08-31T23:21:58.374004Z 0 [Note] InnoDB: Completed initialization of buffer pool
2020-08-31T23:21:58.376393Z 0 [Note] InnoDB: If the mysqld execution user is authorized, page cleaner thread priority can be changed. See the man page of setpriority().
2020-08-31T23:21:58.388238Z 0 [Note] InnoDB: Highest supported file format is Barracuda.
2020-08-31T23:21:58.397442Z 0 [Note] InnoDB: Creating shared tablespace for temporary tables
2020-08-31T23:21:58.397496Z 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
2020-08-31T23:21:58.433771Z 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
2020-08-31T23:21:58.434521Z 0 [Note] InnoDB: 96 redo rollback segment(s) found. 96 redo rollback segment(s) are active.
2020-08-31T23:21:58.434533Z 0 [Note] InnoDB: 32 non-redo rollback segment(s) are active.
2020-08-31T23:21:58.434820Z 0 [Note] InnoDB: Waiting for purge to start
2020-08-31T23:21:58.485059Z 0 [Note] InnoDB: 5.7.31 started; log sequence number 2750396
2020-08-31T23:21:58.485458Z 0 [Note] Plugin 'FEDERATED' is disabled.
2020-08-31T23:21:58.491549Z 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
2020-08-31T23:21:58.492694Z 0 [Note] InnoDB: Buffer pool(s) load completed at 200831 23:21:58
2020-08-31T23:21:58.493566Z 0 [Note] Found ca.pem, server-cert.pem and server-key.pem in data directory. Trying to enable SSL support using them.
2020-08-31T23:21:58.493576Z 0 [Note] Skipping generation of SSL certificates as certificate files are present in data directory.
2020-08-31T23:21:58.494126Z 0 [Warning] CA certificate ca.pem is self signed.
2020-08-31T23:21:58.494160Z 0 [Note] Skipping generation of RSA key pair as key files are present in data directory.
2020-08-31T23:21:58.494227Z 0 [Note] Server hostname (bind-address): 'db1.cve345mgm.eu-west-3.rds.amazonaws.com'; port: 3306
2020-08-31T23:21:58.497633Z 0 [Note] - 'db1.cve345mgm.eu-west-3.rds.amazonaws.com' resolves to 'xxx.xx.xx.x';
2020-08-31T23:21:58.499484Z 0 [Note] Server socket created on IP: 'xxx.xx.xx.x'.
2020-08-31T23:21:58.499502Z 0 [ERROR] Can't start server: Bind on TCP/IP port: Cannot assign requested address
2020-08-31T23:21:58.499507Z 0 [ERROR] Do you already have another mysqld server running on port: 3306 ?
2020-08-31T23:21:58.499540Z 0 [ERROR] Aborting
和 nginx-日志:
2020/08/31 19:33:45 [alert] 25670#25670: *62 open socket #15 left in connection 4
2020/08/31 19:33:45 [alert] 25670#25670: *61 open socket #14 left in connection 5
2020/08/31 19:33:45 [alert] 25670#25670: *63 open socket #16 left in connection 6
2020/08/31 19:33:45 [alert] 25670#25670: *59 open socket #3 left in connection 7
2020/08/31 19:33:45 [alert] 25670#25670: *60 open socket #13 left in connection 8
2020/08/31 19:33:45 [alert] 25670#25670: *64 open socket #17 left in connection 9
2020/08/31 19:33:45 [alert] 25670#25670: aborting
当我尝试执行此操作时,sudo service mysql restart
出现以下错误:
● mysql.service - MySQL Community Server
Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2020-08-31 22:13:50 UTC; 12s ago
Process: 27253 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
Process: 28990 ExecStartPre=/usr/share/mysql/mysql-systemd-start pre (code=exited, status=1/FAILURE)
Main PID: 27255 (code=exited, status=0/SUCCESS)
Aug 31 22:13:49 ip systemd[1]: mysql.service: Control process exited, code=exited status=1
Aug 31 22:13:49 ip systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 31 22:13:49 ip systemd[1]: Failed to start MySQL Community Server.
Aug 31 22:13:50 ip systemd[1]: mysql.service: Service hold-off time over, scheduling restart.
Aug 31 22:13:50 ip systemd[1]: mysql.service: Scheduled restart job, restart counter is at 5.
Aug 31 22:13:50 ip systemd[1]: Stopped MySQL Community Server.
Aug 31 22:13:50 ip systemd[1]: mysql.service: Start request repeated too quickly.
Aug 31 22:13:50 ip systemd[1]: mysql.service: Failed with result 'exit-code'.
Aug 31 22:13:50 ip systemd[1]: Failed to start MySQL Community Server.
更新:仔细查看以下行:
Process: 27253 ExecStart=/usr/sbin/mysqld --daemonize --pid-file=/run/mysqld/mysqld.pid (code=exited, status=0/SUCCESS)
我注意到我没有任何 mysqld 目录,~/var/run/
这可能是问题所在吗?我发现我有一个mysql
目录,var/lib/
但没有权限cd
进入它。这一切看起来太奇怪了!
我觉得我已经尝试了所有能找到的方法,但似乎都无济于事。我希望有人能知道我哪里搞砸了。谢谢