开发者社区> 问答> 正文

ubuntu下nginx源码安装问题 403.10 禁止访问:配置无效

想在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怎样修改其他配置(如:默认端口等)
详情各位拍砖指点。。。

展开
收起
kun坤 2020-05-27 21:29:20 720 0
1 条回答
写回答
取消 提交回答
  • [ ${NETWORKING} = "no" ] && exit 0
    $NETWORKING 这个变量哪来的? 上面那个提示可能是因为这个而引起的,这句你可以去掉,不影响启动关闭重启。 ######回复 @无糖咖啡 : 忽略tomcat吧。如果nginx要做集群,我这个配置还需要添加其他模块吗?http proxy?######回复 @helloming : 没玩过tomcat,呵呵######谢谢, 我这个完全是默认配置,想问下怎样去做tomcat集群呀 sbin/nginx -V nginx version: nginx/1.5.2 built by gcc 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) configure arguments: --prefix=/usr/local/nginx/######当前配置nginx配置:

    #user  nobody; worker_processes  2;

    #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info;

    #pid logs/nginx.pid;

    #工作模式及连接数上限 events { #使用网络IO模型linux建议epoll,FreeBSD建议采用kqueue
    use epoll; worker_connections 65535; }

    #设定http服务器,利用它的反向代理功能提供负载均衡支持 http { include mime.types; default_type application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';
    
    #access_log  logs/access.log  main;
    
    sendfile        on;
    #tcp_nopush     on;
    
    #keepalive_timeout  0;
    keepalive_timeout  65;
    
    #gzip  on;
    
    upstream localhost { <span></span> server localhost:8081; 
      server localhost:80; 
    }  
    
    server {
        listen       8080;
        server_name  localhost;
    
        #charset koi8-r;
    
        #access_log  logs/host.access.log  main;
    
        location / {
            root   html;
            index index.html index.htm index.jsp;#设定访问的默认首页地址
        }
    
        #error_page  404              /404.html;
    
        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    
        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}
    
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}
    
        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }
    

    }

    2020-05-28 14:53:40
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

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