开发者社区> 问答> 正文

ubuntu下nginx源码安装问题?报错

想在ubuntu12.04下安装 nginx1.52,找到一篇教程:http://cmzx3444.iteye.com/blog/1594709 按照其中的步骤进行安装,最后执行 /etc/init.d/nginx start 时报错:“

/etc/init.d/nginx: 第 17 行: [: =: 期待一元表达式

Starting nginx: 

/etc/init.d/nginx 中的内容为:

# start 

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
#              It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/var/run/nginx.pid
RETVAL=0
prog="nginx"


# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];then
   echo "nginx already running...."
   exit 1
fi
   echo -n $"Starting $prog: "
   $nginxd -c ${nginx_config}
   RETVAL=$?
   echo
   [ $RETVAL = 0 ]
   return $RETVAL
}
# Stop nginx daemons functions.
stop() {
        echo -n $"Stopping $prog: "
        $nginxd -s stop
        RETVAL=$?
        echo
        [ $RETVAL = 0 ]
}
# reload nginx service functions.
reload() {
    echo -n $"Reloading $prog: "
    #kill -HUP `cat ${nginx_pid}`
    killproc $nginxd -HUP
    RETVAL=$?
    echo
}
# See how we were called.
case "$1" in
start)
        start
        ;;
stop)
        stop
        ;;
reload)
        reload
        ;;
restart)
        stop
        start
        ;;
status)
        status $prog
        RETVAL=$?
        ;;
*)
        echo $"Usage: $prog {start|stop}"
        exit 1
esac
exit $RETVAL

# end

访问 localhost 时却能打开nginx默认主页,

想问下,我这个nginx算安装好了吗》?按我这个步骤安装好的nginx怎样修改其他配置(如:默认端口等)

详情各位拍砖指点。。。


展开
收起
爱吃鱼的程序员 2020-06-22 18:19:17 574 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    [${NETWORKING}="no"]&&exit0

    $NETWORKING这个变量哪来的?上面那个提示可能是因为这个而引起的,这句你可以去掉,不影响启动关闭重启。

    回复 @无糖咖啡:忽略tomcat吧。如果nginx要做集群,我这个配置还需要添加其他模块吗?httpproxy?回复 @helloming:没玩过tomcat,呵呵谢谢,我这个完全是默认配置,想问下怎样去做tomcat集群呀sbin/nginx-Vnginxversion:nginx/1.5.2builtbygcc4.6.3(Ubuntu/Linaro4.6.3-1ubuntu5)configurearguments:--prefix=/usr/local/nginx/当前配置nginx配置: #usernobody;worker_processes2;#error_loglogs/error.log;#error_loglogs/error.lognotice;#error_loglogs/error.loginfo;#pidlogs/nginx.pid;#工作模式及连接数上限events{#使用网络IO模型linux建议epoll,FreeBSD建议采用kqueueuseepoll;worker_connections65535;}#设定http服务器,利用它的反向代理功能提供负载均衡支持http{includemime.types;default_typeapplication/octet-stream;#log_formatmain'$remote_addr-$remote_user[$time_local]"$request"'#'$status$body_bytes_sent"$http_referer"'#'"$http_user_agent""$http_x_forwarded_for"';#access_loglogs/access.logmain;sendfileon;#tcp_nopushon;#keepalive_timeout0;keepalive_timeout65;#gzipon;upstreamlocalhost{ serverlocalhost:8081;serverlocalhost:80;}server{listen8080;server_namelocalhost;#charsetkoi8-r;#access_loglogs/host.access.logmain;location/{roothtml;indexindex.htmlindex.htmindex.jsp;#设定访问的默认首页地址}#error_page404/404.html;#redirectservererrorpagestothestaticpage/50x.html#error_page500502503504/50x.html;location=/50x.html{roothtml;}#proxythePHPscriptstoApachelisteningon127.0.0.1:80##location~\.php${#proxy_passhttp://127.0.0.1;#}#passthePHPscriptstoFastCGIserverlisteningon127.0.0.1:9000##location~\.php${#roothtml;#fastcgi_pass127.0.0.1:9000;#fastcgi_indexindex.php;#fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name;#includefastcgi_params;#}#denyaccessto.htaccessfiles,ifApache'sdocumentroot#concurswithnginx'sone##location~/\.ht{#denyall;#}}}
    2020-06-22 18:19:35
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载