问题描述
今天在复现尚硅谷Nginx教学的过程中,需要试用oneinstack安装ECS的环境。链接: 尚硅谷Nginx
oneinstack自动安装命令:
wget -c http://mirrors.oneinstack.com/oneinstack.tar.gz && tar xzf oneinstack.tar.gz && ./oneinstack/install.sh --nginx_option 1 --php_option 9 --db_option 2 --dbinstallmethod 1 --dbrootpwd oneinstack --firewall --reboot
在安装过程Nginx启动失败。
/usr/local下无nginx相关目录。
重新试用oneinstack命令安装:
./oneinstack/install.sh --nginx_option 1
发现报错信息:
Nginx installed successfully!
mv: cannot stat ‘/usr/local/nginx/conf/nginx.conf’: No such file or directory
/bin/cp: cannot create regular file ‘/usr/local/nginx/conf/nginx.conf’: No such file or directory
include/nginx.sh: line 60: /usr/local/nginx/conf/proxy.conf: No such file or directory
sed: can't read /usr/local/nginx/conf/nginx.conf: No such file or directory
sed: can't read /usr/local/nginx/conf/nginx.conf: No such file or directory
sed: can't read /usr/local/nginx/conf/nginx.conf: No such file or directory
Job for nginx.service failed because the control process exited with error code. See "systemctl status nginx.service" and "journalctl -xe" for details.
问题原因
在/oneinstack/include/nginx.sh
脚本处发现:
./configure --prefix=${nginx_install_dir} --user=${run_user} --group=${run_group} --with-http_stub_status_module --with-http_sub_module --with-http_v2_module --with-http_ssl_module --with-stream --with-stream_ssl_preread_module --with-stream_ssl_module --with-http_gzip_static_module --with-http_realip_module --with-http_flv_module --with-http_mp4_module --with-openssl=../openssl-${openssl11_ver} --with-pcre=../pcre-${pcre_ver} --with-pcre-jit --with-ld-opt='-ljemalloc' ${nginx_modules_options}
make -j ${THREAD} && make install
if [ -e "${nginx_install_dir}/conf/nginx.conf" ]; then
popd > /dev/null
# 问题原因:安装成功后仍然删除 ${nginx_install_dir}* 下的所有内容!
rm -rf pcre-${pcre_ver}* openssl-${openssl11_ver}* nginx-${nginx_ver}* ${nginx_install_dir}*
echo "${CSUCCESS}Nginx installed successfully! ${CEND}"
else
rm -rf pcre-${pcre_ver}* openssl-${openssl11_ver}* nginx-${nginx_ver}* ${nginx_install_dir}*
echo "${CFAILURE}Nginx install failed, Please Contact the author! ${CEND}"
kill -9 $$; exit 1;
fi
nginx_install_dir 的配置可以在/oneinstack/options.conf l里可以找到
nginx_install_dir=/usr/local/nginx
正是我们习惯安装的nginx目录。
因此断定问题原因:安装成功后仍然删除 ${nginx_install_dir}*
下的所有内容!导致后续脚本执行失败,找不到文件!严重怀疑作者摸鱼粘错了!没有检验!
解决方案
手动将安装脚本/oneinstack/include/nginx.sh
的错误行更换为:
rm -rf pcre-${pcre_ver}* openssl-${openssl11_ver}* nginx-${nginx_ver}*
取消目录的删除即可!
更换后重新执行:
./oneinstack/install.sh --nginx_option 1
安装成功!
总结
还是比较坑的!感觉像在帮作者改bug!作为一个这么多人知道的开源项目实在不应该犯这种错误,这增加了好多人的排错时间。官网上没有预留提问和反馈窗口!在这里先记录了,希望作者能知道或者有人能转告一下!毕竟还是挺花费时间的!选择oneinstack就是图省事,结果还花大量时间排错实在是南辕北辙!