Unknown directive "ELF"

906 views
Skip to first unread message

Niko Apostolidis

unread,
Mar 3, 2014, 12:06:31 PM3/3/14
to ngx-pagesp...@googlegroups.com
OS: CentOS v6.5 x64

Initially I installed nginx from the repo.


...and added some pagespeed EnableFilters

I then updated 

When I go to restart nginx via 
sudo service nginx restart

and get the following error:
nginx: [emerg] unknown directive "ELF" in /usr/local/nginx/sbin/nginx:4
nginx: configuration file /usr/local/nginx/sbin/nginx test failed


My /usr/local/nginx/conf/nginx.conf looks like this (edited site name /var/www directory for security reasons):
#
# The default server
#
server
{
    listen      
80 default_server;
    server_name  example
.com;


   
#charset koi8-r;


   
#access_log  logs/host.access.log  main;


    location
/ {
        root          
/var/www/blog;
        index  index
.php index.html index.htm;
   
}


    error_page  
404              /404.html;
    location
= /404.html {
        root   /
usr/share/nginx/html;
   
}


   
# redirect server error pages to the static page /50x.html
   
#
    error_page  
500 502 503 504  /50x.html;
    location
= /50x.html {
        root   /
usr/share/nginx/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          
/var/www/blog;
        fastcgi_pass  
127.0.0.1:9000;
        fastcgi_index  index
.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$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;
   
#}


   pagespeed on
;


   
# Needs to exist and be writable by nginx.
   pagespeed
FileCachePath /var/ngx_pagespeed_cache;


   
# Ensure requests for pagespeed optimized resources go to the pagespeed handler
   
# and no extraneous headers get set.
   location
~ "\.pagespeed\.([a-z]\.)?[a-z]{2}\.[^.]{10}\.[^.]+" {
       add_header
"" "";
   
}
   location
~ "^/ngx_pagespeed_static/" { }
   location
~ "^/ngx_pagespeed_beacon$" { }
   location
/ngx_pagespeed_statistics { allow 127.0.0.1; deny all; }
   location
/ngx_pagespeed_global_statistics { allow 127.0.0.1; deny all; }
   location
/ngx_pagespeed_message { allow 127.0.0.1; deny all; }


   pagespeed
EnableFilters combine_heads,outline_css,outline_javascript;
   pagespeed
EnableFilters move_css_above_scripts, move_css_to_head, prioritize_critical_css;
   pagespeed
EnableFilters combine_javascript, removes_quotes;
}

My /etc/init.d/nginx looks like this:
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig:   - 85 15
# description:  Nginx is an HTTP(S) server, HTTP(S) reverse \
#               proxy and IMAP/POP3 proxy server
# processname: nginx
# config:      /etc/nginx/nginx.conf
# config:      /etc/sysconfig/nginx
# pidfile:     /var/run/nginx.pid


# Source function library.
. /etc/rc.d/init.d/functions


# Source networking configuration.
. /etc/sysconfig/network


# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0


nginx
="/usr/sbin/nginx"
prog
=$(basename $nginx)


sysconfig
="/etc/sysconfig/$prog"
lockfile
="/var/lock/subsys/nginx"
pidfile
="/var/run/${prog}.pid"


NGINX_CONF_FILE
="/usr/local/nginx/conf/nginx.conf"


[ -f $sysconfig ] && . $sysconfig




start
() {
   
[ -x $nginx ] || exit 5
   
[ -f $NGINX_CONF_FILE ] || exit 6
    echo
-n $"Starting $prog: "
    daemon $nginx
-c $NGINX_CONF_FILE
    retval
=$?
    echo
   
[ $retval -eq 0 ] && touch $lockfile
   
return $retval
}


stop
() {
    echo
-n $"Stopping $prog: "
    killproc
-p $pidfile $prog
    retval
=$?
    echo
   
[ $retval -eq 0 ] && rm -f $lockfile
   
return $retval
}


restart
() {
    configtest_q
|| return 6
    stop
    start
}


reload
() {
    configtest_q
|| return 6
    echo
-n $"Reloading $prog: "
    killproc
-p $pidfile $prog -HUP
    echo
}


configtest
() {
    $nginx
-t -c $NGINX_CONF_FILE
}


configtest_q
() {
    $nginx
-t -q -c $NGINX_CONF_FILE
}


rh_status
() {
    status $prog
}


rh_status_q
() {
    rh_status
>/dev/null 2>&1
}


# Upgrade the binary with no downtime.
upgrade
() {
   
local oldbin_pidfile="${pidfile}.oldbin"


    configtest_q
|| return 6
    echo
-n $"Upgrading $prog: "
    killproc
-p $pidfile $prog -USR2
    retval
=$?
    sleep
1
   
if [[ -f ${oldbin_pidfile} && -f ${pidfile} ]];  then
        killproc
-p $oldbin_pidfile $prog -QUIT
        success $
"$prog online upgrade"
        echo
       
return 0
   
else
        failure $
"$prog online upgrade"
        echo
       
return 1
   
fi
}


# Tell nginx to reopen logs
reopen_logs
() {
    configtest_q
|| return 6
    echo
-n $"Reopening $prog logs: "
    killproc
-p $pidfile $prog -USR1
    retval
=$?
    echo
   
return $retval
}


case "$1" in
    start
)
        rh_status_q
&& exit 0
        $1
       
;;
    stop
)
        rh_status_q
|| exit 0
        $1
       
;;
    restart
|configtest|reopen_logs)
        $1
       
;;
    force
-reload|upgrade)
        rh_status_q
|| exit 7
        upgrade
       
;;
    reload
)
        rh_status_q
|| exit 7
        $1
       
;;
    status
|status_q)
        rh_$1
       
;;
    condrestart
|try-restart)
        rh_status_q
|| exit 7
        restart
           
;;
   
*)
        echo $
"Usage: $0 {start|stop|reload|configtest|status|force-reload|upgrade|restart|reopen_logs}"
   
*)
        echo $
"Usage: $0 {start|stop|reload|configtest|status|force-reload|upgrade|restart|reopen_logs}"
       
exit 2
esac

Thoughts?


Niko Apostolidis

unread,
Mar 3, 2014, 12:11:50 PM3/3/14
to ngx-pagesp...@googlegroups.com
Btw, /etc/sysconfig/nginx points to /usr/local/nginx/sbin/nginx


--
You received this message because you are subscribed to a topic in the Google Groups "ngx-pagespeed-discuss" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/ngx-pagespeed-discuss/_4YBZOh-Kdc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to ngx-pagespeed-di...@googlegroups.com.
Visit this group at http://groups.google.com/group/ngx-pagespeed-discuss.
For more options, visit https://groups.google.com/groups/opt_out.

Jeff Kaufman

unread,
Mar 3, 2014, 1:10:21 PM3/3/14
to ngx-pagesp...@googlegroups.com
On Mon, Mar 3, 2014 at 9:06 AM, Niko Apostolidis <wire...@gmail.com> wrote:
> nginx: [emerg] unknown directive "ELF" in /usr/local/nginx/sbin/nginx:4
> nginx: configuration file /usr/local/nginx/sbin/nginx test failed

It looks like you're giving nginx a binary where it expects a
configuration file. Somehow /usr/local/nginx/sbin/nginx is being
treated as the name of the configuration file instead of
/usr/local/nginx/conf/nginx.conf.

(The complaint about "ELF" is because a linux binary is generally in
"ELF" format and starts with a few bytes that include the ascii text
"ELF".)
Reply all
Reply to author
Forward
0 new messages