1+X中级B卷:Shell脚本补全

来自CloudWiki
跳转至: 导航搜索

题目

下面有一段脚本,作用是自动配置nginx服务,由于工程师的失误,将脚本中的某些代码删除了,但注释还在,请根据注释,填写代码。最后将填写的代码按照顺序以文本形式提交至答题框。

nginx(){ cd #删除默认项目路径下的文件 rm -rf /usr/share/nginx/html/* #将提供的dist静态文件复制到nginx项目目录 cp -rvf /root/dist/* /usr/share/nginx/html #修改nginx配置文件如下 cat > /etc/nginx/conf.d/default.conf << EOF server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/host.access.log main; location / { root /usr/share/nginx/html; index index.html index.htm; } location /user { (此处需要填写) } location /shopping { proxy_pass http://127.0.0.1:8081; } location /cashier { proxy_pass http://127.0.0.1:8083; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } } EOF #启动nginx服务 systemctl start nginx #设置nginx开机自启 (此处需填写) #检查nginx服务是否成功启动 if [ $? -eq 0 ] then sleep 3 echo -e "\033[36m==========nginx启动成功==========\033[0m" else echo -e "\033[31m**********nginx启动失败,请检查**********\033[0m" exit 1 fi sleep 2 } 

答案

proxy_pass http://127.0.0.1:8082;

systemctl enable nginx