最后更新时间: 2025年6月23日
最新的 lnmp 版本为 v2.2 发布于@2025.04月,今天尝试安装在 aws ec2上,使用下来遇到些问题,记录如下。
我编辑安装的时候选择的配置如下:
- mysql 版本8.0.37,不使用 Generic Binaries 安装,from source 安装
- php 版本8.2.19
- mysql 开启 Innodb 引擎
- 安装 Jemalloc 内存管理模块
整体编辑安装时间大概50分钟,比较慢了,因为服务器配置不低,并且安装过程中 mysql 还报了些警告⚠️,虽然这个不影响使用
In function ‘copysign_impl’, inlined from ‘copysign’ at /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/core/cmath.hpp:190:46, inlined from ‘negate’ at /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/spirit/home/qi/numeric/detail/real_impl.hpp:131:38, inlined from ‘parse’ at /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/spirit/home/qi/numeric/detail/real_impl.hpp:337:45, inlined from ‘parse’ at /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/spirit/home/qi/numeric/real.hpp:168:34, inlined from ‘call’ at /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp:42:27, inlined from ‘operator()’ at /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/spirit/home/qi/nonterminal/detail/parser_binder.hpp:53:24, inlined from ‘invoke’ at /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/function/function_template.hpp:137:22: /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/core/cmath.hpp:178:30: warning: ‘n’ may be used uninitialized [-Wmaybe-uninitialized] 178 | return __builtin_copysign( x, y ); | ^ /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/spirit/home/qi/numeric/detail/real_impl.hpp: In function ‘invoke’: /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/spirit/home/qi/numeric/detail/real_impl.hpp:209:15: note: ‘n’ was declared here 209 | T n; | ^ In function ‘memcpy’, inlined from ‘move_assign’ at /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/function/function_template.hpp:1008:24, inlined from ‘swap’ at /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/function/function_template.hpp:862:22, inlined from ‘operator=’ at /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/function/function_template.hpp:1139:22, inlined from ‘define’ at /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/spirit/home/qi/nonterminal/rule.hpp:191:19, inlined from ‘operator=’ at /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/spirit/home/qi/nonterminal/rule.hpp:229:32, inlined from ‘__ct ’ at /root/lnmp2.2/src/mysql-8.0.37/sql/gis/srs/wkt_parser.cc:156:12, inlined from ‘parse_wkt’ at /root/lnmp2.2/src/mysql-8.0.37/sql/gis/srs/wkt_parser.cc:257:17: /usr/include/x86_64-linux-gnu/bits/string_fortified.h:29:33: warning: ‘MEM <unsigned char[24]> [(char * {ref-all})&D.49716 + 8B]’ may be used uninitialized [-Wmaybe-uninitialized] 29 | return __builtin___memcpy_chk (__dest, __src, __len, | ^ /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/function/function_template.hpp: In function ‘parse_wkt’: /root/lnmp2.2/src/mysql-8.0.37/boost/boost_1_77_0/boost/function/function_template.hpp:1139:5: note: ‘<anonymous>’ declared here 1139 | self_type(f).swap(*this);
然后在使用 lnmp vhost add
添加虚拟主机的时候遇到如下错误
Invalid response from http://www.xxx.com/.well-known/acme-challenge/CBxaWCHHvcGReia6MijG3nd6P0az4KZv7KZYCdy5zac: 522
这是因为 EC2默认没有开放 80 和 443 端口,需要 到aws 后台找到 Network & Security 找到 Security Groups 添加 http 和 https 的 Inbound rules,然后重新添加即可成功 ✅✅✅
另外在生成证书的时候还有一个错误,这是 lnmp 的问题,会报如下错误
https://soft.vpser.net/lib/acme.sh/latest.tar.gz Resolving soft.vpser.net (soft.vpser.net)... failed: Name or service not known. wget: unable to resolve host address ‘soft.vpser.net’ tar (child): latest.tar.gz: Cannot open: No such file or directory
即连接不上 soft.vpser.net,这是因为这里的源已经切换为 soft.lnmp.com , 解决方案为
打开/usr/bin/lnmp,在1180行左右,将其中的 https://soft.vpser.net/lib/acme.sh/latest.tar.gz 替换为 https://soft.lnmp.com/lib/acme.sh/latest.tar.gz 即可
附:如何301强制 http -> https
#强制 http -> https location / { return 301 https://$host$request_uri; }
附: 如何强制 yourdomain.com -> www.yourdomain.com
server_name www.yourdomain.com youdomain.com; if ($host != 'www.yourdomain.com') { rewrite ^/(.*)$ http://www.yourdomain.com/$1 permanent; }