Author Topic: Home Automation gateway setup [SOLVED]  (Read 13592 times)

dakine7t9

  • NewMember
  • *
  • Posts: 2
Home Automation gateway setup [SOLVED]
« on: April 26, 2014, 12:24:03 AM »
I am currently trying to set up my raspberry pi with nginx and have run into a couple of problems. I am not too experienced with this however I have used linux before and know my way around the command line somewhat. I am getting two problems when setting things up. After editing the nginx.conf file and restarting the nginx service I get the following error.

Quote
Restarting nginx: nginx: [alert] could not open error log file: open() "/var/log/nginx/error.log" failed (13: Permission denied)
2014/04/25 21:03:15 [warn] 2239#0: the "user" directive makes sense only if the master process runs with super-user privileges, ignored in /etc/nginx/nginx.conf:1
2014/04/25 21:03:15 [emerg] 2239#0: "worker_processes" directive is duplicate in /etc/nginx/nginx.conf:30
nginx.

If I enter

Quote
sudo service nginx restart

I get the following:

Quote
Restarting nginx: nginx: [emerg] "worker_processes" directive is duplicate in /etc/nginx/nginx.conf:30
nginx.


My second problem occurs when creating the self signed ssl certificate.

I get the error

Quote
unknown option –days

to fix this I ended up switching the -days option and -nodes option like this:

Quote
sudo openssl req -new -x509 -days 365 -nodes -newkey rsa:2048 -out server.crt -keyout server.key

This seems to work however I have never done any of this so I am not sure if it is correct.


after setting up index.php  and entering my ip in my browser I don't get anything. I'm not sure if its the error in the nginx.conf file causing this but I can't seem to get it working. Any pointers would be greatly appreciated!

« Last Edit: July 25, 2014, 01:50:03 PM by Felix »

hexibot43

  • Jr. Member
  • **
  • Posts: 78
Re: Home Automation gateway setup
« Reply #1 on: April 26, 2014, 09:49:35 AM »
Could you post your nginx.conf for us to see?  I want to see everything at least up to line 30 of the file.  I'm sure anyone else that wants to help would be asking the same thing. 

dakine7t9

  • NewMember
  • *
  • Posts: 2
Re: Home Automation gateway setup
« Reply #2 on: April 26, 2014, 06:30:17 PM »
This is what it looks like (I put line 30 in bold to make it easier to find.)

Quote
user  www-data;
worker_processes  2;
 
events {
    worker_connections  1024;
}
 
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;
 
    include /etc/nginx/sites-enabled/*;
}

#user  nobody;
worker_processes  1;

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

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


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;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #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;
        #}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}


Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Home Automation gateway setup
« Reply #3 on: April 26, 2014, 07:50:29 PM »
I have a working setup published.
See here: https://github.com/LowPowerLab/RaspberryPi-Gateway

ekoelle

  • NewMember
  • *
  • Posts: 16
Re: Home Automation gateway setup
« Reply #4 on: July 24, 2014, 01:48:02 AM »
Just started following the blog post to get my home automation gateway setup and I'm running into an error when installing NGINX. I'm a noob when it comes to linux so I'm not sure if I can bypass the rewrite module or not. Safe to do so?

Here's the error I get when running sudo ./configure \:
Code: [Select]
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

Thank you,

Eric

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Home Automation gateway setup
« Reply #5 on: July 24, 2014, 08:07:05 AM »
So you're missing the PCRE stuff, did you run this line?

Code: [Select]
sudo apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev

ekoelle

  • NewMember
  • *
  • Posts: 16
Re: Home Automation gateway setup
« Reply #6 on: July 24, 2014, 11:33:21 AM »
Turns out I misspelled "zlib1g-dev" and didn't realize that the command didn't execute. Re-ran the command and now I'm not getting the PCRE error anymore.

So you're missing the PCRE stuff, did you run this line?

Code: [Select]
sudo apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev

Now I get an error when running "sudo make".
Code: [Select]
make[1]: *** [objs/src/event/ngx_event_openssl.o] Error 1
make[1]: Leaving directory `/home/pi/sources/nginx-1.4.2'
make: *** [build] Error 2

ekoelle

  • NewMember
  • *
  • Posts: 16
Re: Home Automation gateway setup
« Reply #7 on: July 24, 2014, 12:54:56 PM »
A little searching reveals that this is an issue with OpenSSL v1.02 or later. I had to add the following to ngx_event_openssl.c located in nginx/src/event:

Code: [Select]
#ifndef SSL_OP_MSIE_SSLV2_RSA_PADDING
# define SSL_OP_MSIE_SSLV2_RSA_PADDING 0
#endif

Source1:http://stackoverflow.com/questions/24027327/how-to-install-nginx-from-source-got-ssl-op-msie-sslv2-rsa-padding-error
Source2:http://www.coderexception.com/CmNz3uzbPQWPyXPy/how-to-install-nginx-from-source-got-sslopmsiesslv2rsapadding-error

ekoelle

  • NewMember
  • *
  • Posts: 16
Re: Home Automation gateway setup
« Reply #8 on: July 24, 2014, 03:30:27 PM »
Now I have everything for nginx setup and I get the SSL cert prompt and then get the UN/PW prompt however the credentials I entered in .htpasswd aren't working. I've gone through all the steps again and everything seems to be correct yet I can't get past the login credentials.

The only step that doesn't process normally is:
Code: [Select]
sudo echo -e "USERNAME:`perl -le 'print crypt("PASSWORD","SALT")'`" > sudo /var/www/default/.htpasswd
I get a
Code: [Select]
-bash: sudo: Permission denied
message so I just run the first part of the command and then copy the un:pw into .htpasswd manually.

Any ideas?

Thank you,

Eric
« Last Edit: July 24, 2014, 03:33:46 PM by ekoelle »

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Home Automation gateway setup
« Reply #9 on: July 24, 2014, 11:04:56 PM »
Hm that should work, if you set everything up the same. You should have credentials USERNAME and PASSWORD.
You should have them in the .htpasswd like this (dummy encrypted password):

USERNAME:SXOa3dKuTTk/.

ekoelle

  • NewMember
  • *
  • Posts: 16
Re: Home Automation gateway setup
« Reply #10 on: July 25, 2014, 01:17:06 PM »
Yup, that would work...if I didn't put a space in from of the username. Problem resolved. Thanks for the help Felix.

Hm that should work, if you set everything up the same. You should have credentials USERNAME and PASSWORD.
You should have them in the .htpasswd like this (dummy encrypted password):

USERNAME:SXOa3dKuTTk/.

ekoelle

  • NewMember
  • *
  • Posts: 16
Re: Home Automation gateway setup [SOLVED]
« Reply #11 on: July 25, 2014, 05:11:24 PM »
And now this while trying to run "npm install serialport":
Code: [Select]
npm http GET https://registry.npmjs.org/serialport
npm http 304 https://registry.npmjs.org/serialport
npm ERR! Error: EACCES, mkdir '/home/pi/moteino/node_modules'
npm ERR!  { [Error: EACCES, mkdir '/home/pi/moteino/node_modules']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '/home/pi/moteino/node_modules',
npm ERR!   fstream_type: 'Directory',
npm ERR!   fstream_path: '/home/pi/moteino/node_modules/serialport',
npm ERR!   fstream_class: 'DirWriter',
npm ERR!   fstream_stack:
npm ERR!    [ '/opt/node/lib/node_modules/npm/node_modules/fstream/lib/writer.js:171:23',
npm ERR!      '/opt/node/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53',
npm ERR!      'Object.oncomplete (fs.js:107:15)' ] }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.12.22+
npm ERR! command "/opt/node/bin/node" "/opt/node/bin/npm" "install" "serialport"
npm ERR! cwd /home/pi/moteino
npm ERR! node -v v0.10.12
npm ERR! npm -v 1.2.32
npm ERR! path /home/pi/moteino/node_modules
npm ERR! fstream_path /home/pi/moteino/node_modules/serialport
npm ERR! fstream_type Directory
npm ERR! fstream_class DirWriter
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, mkdir '/home/pi/moteino/node_modules'
npm ERR! fstream_stack /opt/node/lib/node_modules/npm/node_modules/fstream/lib/writer.js:171:23
npm ERR! fstream_stack /opt/node/lib/node_modules/npm/node_modules/mkdirp/index.js:37:53
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Error: EACCES, open 'npm-debug.log'
npm ERR!  { [Error: EACCES, open 'npm-debug.log'] errno: 3, code: 'EACCES', path: 'npm-debug.log' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.12.22+
npm ERR! command "/opt/node/bin/node" "/opt/node/bin/npm" "install" "serialport"
npm ERR! cwd /home/pi/moteino
npm ERR! node -v v0.10.12
npm ERR! npm -v 1.2.32
npm ERR! path npm-debug.log
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, open 'npm-debug.log'
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     /home/pi/moteino/npm-debug.log
npm ERR! not ok code 0

Felix

  • Administrator
  • Hero Member
  • *****
  • Posts: 6866
  • Country: us
    • LowPowerLab
Re: Home Automation gateway setup [SOLVED]
« Reply #12 on: July 26, 2014, 10:13:49 AM »
sudo npm install serialport

ekoelle

  • NewMember
  • *
  • Posts: 16
Re: Home Automation gateway setup [SOLVED]
« Reply #13 on: July 26, 2014, 11:25:19 AM »
Code: [Select]
pi@KoLo-Automation ~/moteino $ sudo npm install serialport
sudo: npm: command not found

I tried "npm sudo install serialport" also but it just brings up the help screen for the npm command

sudo npm install serialport
« Last Edit: July 26, 2014, 11:28:44 AM by ekoelle »

ekoelle

  • NewMember
  • *
  • Posts: 16
Re: Home Automation gateway setup [SOLVED]
« Reply #14 on: July 28, 2014, 01:33:26 PM »
I was able to get serialport to install using the below command but it doesn't install to the ~/moteino directory.

Code: [Select]
sudo $(which npm) install -g serialport

Source: http://stackoverflow.com/questions/13964173/npm-install-failing
« Last Edit: July 28, 2014, 01:40:16 PM by ekoelle »