存档在 ‘【技术】’ 分类

报错:DataTables warning: table id=tableLinkedAccounts – Invalid JSON response.

2018年10月18日

在调试WHMCS时,遇见报错:

DataTables warning: table id=tableLinkedAccounts - Invalid JSON response. 

设置Full Friendly URL之后就OK了。

参考:https://whmcs.community/topic/290579-creating-api-credentials-generete-and-error/

怎样使用SMTP服务器发送邮件

2018年10月11日

【问题】

如果2处发送人电邮地址不一致,报错:

There has been an error sending the message. The following From address failed: support@name.com : MAIL FROM command failed,mail from address must be same as authorization user ,501,SMTP server error: MAIL FROM command failed Detail: mail from address must be same as authorization user SMTP code: 501SMTP server error: MAIL FROM command failed Detail: mail from address must be same as authorization user SMTP code: 501 

如果失败,PHPMailer将无法发送电子邮件,报错:

SMTP connect() failed

【方法】

Ping:检查它在哪里?

即使服务器被禁用,所有的服务通常都会对简单的Ping做出响应,所以如果你知道你的DNS是好的,检查服务器是否真的存在:

ping smtp.gmail.com  

返回(按Ctrl + C停止它):

PING gmail-smtp-msa.l.google.com (74.125.133.108): 56 data bytes
64 bytes from 74.125.133.108: icmp_seq=0 ttl=43 time=72.636 ms
64 bytes from 74.125.133.108: icmp_seq=1 ttl=43 time=68.841 ms
64 bytes from 74.125.133.108: icmp_seq=2 ttl=43 time=68.500 ms

telnet:检查它是一个邮件服务器?

可能是某个其他服务正在您尝试连接的SMTP端口上运行。你可以使用这个telnet工具来检查这个(在提交服务端口上连接到gmail):

telnet smtp.gmail.com 587  

返回:

Trying 173.194.67.109...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
    220 mx.google.com ESMTP ex2sm16805587wjd.30 - gsmtp

如果端口587不起作用,您可以尝试使用端口465或端口25。但端口25通常不支持加密。

如果它没有输出或者没有输出220,那么你的服务器关闭了,或者你的服务器错了。

经过排查,25端口不通,但 587 端口 畅通,果断使用 587 + tls 。

【QQ邮箱SMTP】

实证成功。

QQ
SMTP
8bit
587
smtp.qq.com
username@qq.com
TOKEN
TLS

【Google邮箱SMTP】

实证未遂。

参考:https://blog.csdn.net/zdgdq/article/details/78518508

https://www.wpbeginner.com/plugins/how-to-send-email-in-wordpress-using-the-gmail-smtp-server/

https://console.developers.google.com/apis/api/gmail.googleapis.com/credentials
https://developers.google.com/gmail/imap/imap-smtp

The outgoing SMTP server, smtp.gmail.com, requires TLS. Use port 465, or port 587 if your client begins with plain text before issuing the STARTTLS command.

Outgoing Mail (SMTP) Server

smtp.gmail.com

Requires SSL: Yes

Requires TLS: Yes (if available)

Requires Authentication: Yes

Port for SSL: 465

Port for TLS/STARTTLS: 587
Full Name or Display Name Your name
Account Name, User name, or Email address Your full email address
Password Your Gmail password

【参考】

参考:https://www.fujieace.com/wordpress/smtp-connect-failed.html
参考:https://since1989.org/whmcs/qq-mail-smtp-error-ssl.html
参考:https://www.xxorg.com/archives/717
参考:https://www.xxorg.com/archives/188
参考:http://www.tuxingzhan.com/wpc/3758.html
参考:https://bbs.csdn.net/topics/391894148

报错汇编:php-compile-errors

2018年10月11日

参考:http://www.123tweak.com/how-to-fix-php-compile-errors/
参考:http://www.cnblogs.com/smallstong/p/3267060.html

Some library errors when compile Php 5 on CentOS

checking for BZip2 support… yes
checking for BZip2 in default path… not found
configure: error: Please reinstall the BZip2 distribution

Fix:
yum install bzip2-devel

checking for cURL support… yes
checking if we should use cURL for url streams… no
checking for cURL in default path… not found
configure: error: Please reinstall the libcurl distribution –
easy.h should be in /include/curl/

Fix:
yum install curl-devel

checking for curl_multi_strerror in -lcurl… yes
checking for QDBM support… no
checking for GDBM support… no
checking for NDBM support… no
configure: error: DBA: Could not find necessary header file(s).

Fix:
yum install db4-devel

checking for fabsf… yes
checking for floorf… yes
configure: error: jpeglib.h not found.

Fix:
yum install libjpeg-devel

checking for fabsf… yes
checking for floorf… yes
checking for jpeg_read_header in -ljpeg… yes
configure: error: png.h not found.

Fix:
yum install libpng-devel

checking for png_write_image in -lpng… yes
If configure fails try –with-xpm-dir=

configure: error: freetype.h not found.

Fix: Reconfigure your PHP with the following option.
–with-xpm-dir=/usr

checking for png_write_image in -lpng… yes
configure: error: libXpm.(a|so) not found.

Fix:
yum install libXpm-devel

checking for bind_textdomain_codeset in -lc… yes
checking for GNU MP support… yes
configure: error: Unable to locate gmp.h

Fix:
yum install gmp-devel

checking for utf8_mime2text signature… new
checking for U8T_DECOMPOSE…
configure: error: utf8_mime2text() has new signature, but U8T_CANONICAL is missing. This should not happen. Check config.log for additional information.

Fix:
yum install libc-client-devel

checking for LDAP support… yes, shared
checking for LDAP Cyrus SASL support… yes
configure: error: Cannot find ldap.h

Fix:
yum install openldap-devel

checking for mysql_set_character_set in -lmysqlclient… yes
checking for mysql_stmt_next_result in -lmysqlclient… no
checking for Oracle Database OCI8 support… no
checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!

Fix:

yum install unixODBC-devel

checking for PostgreSQL support for PDO… yes, shared
checking for pg_config… not found
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

Fix:
yum install postgresql-devel

checking for sqlite 3 support for PDO… yes, shared
checking for PDO includes… (cached) /usr/local/src/php-5.3.7/ext
checking for sqlite3 files in default path… not found
configure: error: Please reinstall the sqlite3 distribution

Fix:
yum install sqlite-devel

checking for utsname.domainname… yes
checking for PSPELL support… yes
configure: error: Cannot find pspell

Fix:
yum install aspell-devel

checking whether to enable UCD SNMP hack… yes
checking for default_store.h… no

checking for kstat_read in -lkstat… no
checking for snmp_parse_oid in -lsnmp… no
checking for init_snmp in -lsnmp… no
configure: error: SNMP sanity check failed. Please check config.log for more information.

Fix:
yum install net-snmp-devel

checking whether to enable XMLWriter support… yes, shared
checking for xml2-config path… (cached) /usr/bin/xml2-config
checking whether libxml build works… (cached) yes
checking for XSL support… yes, shared
configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

Fix:
yum install libxslt-devel

configure: error: xml2-config not found. Please check your libxml2 installation.

Fix:
yum install libxml2-devel

checking for PCRE headers location… configure: error: Could not find pcre.h in /usr

Fix:
yum install pcre-devel

configure: error: Cannot find MySQL header files under yes.
Note that the MySQL client library is not bundled anymore!

Fix:
yum install mysql-devel

checking for unixODBC support… configure: error: ODBC header file ‘/usr/include/sqlext.h’ not found!

Fix:
yum install unixODBC-devel

checking for pg_config… not found
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path

Fix:

yum install postgresql-devel

configure: error: Cannot find pspell

Fix:
yum install pspell-devel

configure: error: Could not find net-snmp-config binary. Please check your net-snmp installation.

Fix:
yum install net-snmp-devel

configure: error: xslt-config not found. Please reinstall the libxslt >= 1.1.0 distribution

Fix:
yum install libxslt-devel

报错:systemctl: command not found

2018年10月10日

因为CentOS6 没有使用 systemd,所以没有 systemctl 命令。

可以使用 service 命令:

service <service-name> status/start/stop

例如:

service postgresql stop
service mongod stop

怎样使用SSH key

2018年10月10日

【任意Linux服务器之上部署SSH-Key】

参考:http://www.isetsuna.com/vps/set-ssh-key-bandwagonhost/
参考:https://www.vultr.com/docs/how-do-i-generate-ssh-keys/

道是不是有人在爆破你的SSH密码,可以查看 /var/log/auth.log 文件,如果看到一堆异常IP在刷屏,那必须重视了。

为了防止密码被爆破,可以使用SSH Key的方式来登录,并关闭密码登录方式,还要修改SSH端口以避免被大范围扫描。

【生成SSH Key】

用PuTTY登录到VPS,执行以下命令生成SSH Key:

ssh-keygen -t rsa

输出:

Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):  #保存路径,直接回车
Created directory '/root/.ssh'.
Enter passphrase (empty for no passphrase):  #输入密钥密码,直接回车
Enter same passphrase again:  #重复密钥密码,直接回车
Your identification has been saved in /root/.ssh/id_rsa.  #私钥保存路径
Your public key has been saved in /root/.ssh/id_rsa.pub.  #公钥保存路径
The key fingerprint is:
c3:b6:9f:95:8f:b9:13:60:4a:75:07:f3:5d:72:99:e5 root@Setsuna
The key's randomart image is:
+--[ RSA 2048]----+
|            o.. B|
|          . .o.B.|
|         . . .. E|
|       .. o      |
|       .So .     |
|       ..o  ..   |
|        .   o.   |
|         . o.+   |
|          o +o.  |
+-----------------+

修改公钥文件名和权限:

mv /root/.ssh/id_rsa.pub /root/.ssh/authorized_keys;chmod 600 /root/.ssh/authorized_keys

【生成ppk文件】

用WinSCP登录到VPS,打开 /root/.ssh 文件夹,将私钥文件 id_rsa 文件下载到本地。

运行PuTTYgen,选择 Conversions–>Import key ,选择私钥文件 id_rsa ,会出现如下界面:

点击Save Private Key,将私钥保存为.ppk文件,文件名可自取。

注意:请一定要妥善保管好私钥文件id_rsa和.ppk文件!

【登录设置】

在WinSCP登录窗口设置你的VPS域名和SSH端口,用户名root,密码留空。

点击高级->SSH->验证->密钥文件,选择之前生成的.ppk文件,然后确定保存。

点击工具–>选项–>应用程序–>PuTTY客户端路径,选择PuTTY程序的路径,并勾选记住会话密码并传给PuTTY选项,然后确定。

点击登录,如果一切正常的话,会提示与公钥进行认证,然后成功登录。

如果要用PuTTY的话,可以在WinSCP窗口上方点击在PuTTY中打开会话,即可启动PuTTY并自动登录。

如果不需要登录WinSCP只登录PuTTY,也可以在WinSCP登录窗口,点击管理–>在PuTTY中打开,来进行自动登录。

(建议把PuTTY程序和私钥以及ppk文件放到WinSCP文件夹下,这样只需要拷进U盘即可随身使用)

【修改SSH配置】

用WinSCP打开 /etc/ssh/sshd_config 文件,修改以下两项:

Port 22  #SSH端口,建议修改为一些非常用的高位端口
PasswordAuthentication yes  #yes修改为no,如果前面有#号请去掉,关闭密码登录方式

然后重启SSH服务即可生效:

Debian/Ubuntu执行:

/etc/init.d/ssh restart

CentOS执行:

/etc/init.d/sshd restart

最后,记得在WinSCP的登录窗口中更新新的SSH端口。

【DigitalOcean之上部署SSH-Key】

【生成】

官网:https://putty.org/
下载:https://the.earth.li/~sgtatham/putty/latest/w64/putty-64bit-0.70-installer.msi

安装后,使用 puttygen.exe 生成公钥/私钥对。

生成公钥/私钥对并保存:

ssh-rsa AAAAB…ErK5NQ== rsa-key-20181010

Key fingerprint

ssh-rsa 2048 a1:16:21:23:76:d7:67:dd:a7:7e:bd:15:51:69:24:5a

Key comment
rsa-key-20181010

Key passphase

H8I1uc6zrtYtGa47FkWJaWivh

【使用】

1. 在DigitalOcean.com面板中添加SSH Key中的公钥,命名,保存;
2. 在DigitalOcean.com面板中创建新Droplet,关联以上SSH Key;
3. 在WinSCP中,高级选项》选择私钥private.ppk;
4. 成功连接后,填入 Key passphase,即可正常登录。

【参考】

参考:https://laozhu.me/post/make-server-secure/

参考:http://blog.sina.com.cn/s/blog_a2be73ab0101fukv.html
参考:http://www.isetsuna.com/vps/set-ssh-key-bandwagonhost/
参考:http://cncc.bingj.com/cache.aspx?q=digitalocean+ssh+%e7%ab%af%e5%8f%a3centos&d=4594448595294139&mkt=zh-CN&setlang=zh-CN&w=iK1T0BovL4wpUD_uXKhmk51YkhJ6YVQ5

参考:http://www.cnblogs.com/smarterplanet/p/4330902.html
参考:https://blog.csdn.net/happyhuirong/article/details/41729911

参考:https://winscp.net/eng/docs/guide_digitalocean
参考:https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/to-account/
参考:https://winscp.net/eng/docs/guide_digitalocean#setting_up_public_key_authentication
参考:https://www.digitalocean.com/docs/droplets/how-to/add-ssh-keys/to-existing-droplet/

参考:https://winscp.net/eng/docs/ui_puttygen#generating