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.
QuoteRestarting 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
Quotesudo service nginx restart
I get the following:
QuoteRestarting 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
Quoteunknown option –days
to fix this I ended up switching the -days option and -nodes option like this:
Quotesudo 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!
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.
This is what it looks like (I put line 30 in bold to make it easier to find.)
Quoteuser 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;
# }
#}
}
I have a working setup published.
See here: https://github.com/LowPowerLab/RaspberryPi-Gateway
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 \:
./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
So you're missing the PCRE stuff, did you run this line?
sudo apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
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.
Quote from: Felix on July 24, 2014, 08:07:05 AM
So you're missing the PCRE stuff, did you run this line?
sudo apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
Now I get an error when running "sudo make".
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
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:
#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 (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 (http://www.coderexception.com/CmNz3uzbPQWPyXPy/how-to-install-nginx-from-source-got-sslopmsiesslv2rsapadding-error)
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: sudo echo -e "USERNAME:`perl -le 'print crypt("PASSWORD","SALT")'`" > sudo /var/www/default/.htpasswd
I get a -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
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/.
Yup, that would work...if I didn't put a space in from of the username. Problem resolved. Thanks for the help Felix.
Quote from: Felix 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/.
And now this while trying to run "npm install serialport":
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
sudo npm install serialport
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
Quote from: Felix on July 26, 2014, 10:13:49 AM
sudo npm install serialport
I was able to get serialport to install using the below command but it doesn't install to the ~/moteino directory.
sudo $(which npm) install -g serialport
Source: http://stackoverflow.com/questions/13964173/npm-install-failing (http://stackoverflow.com/questions/13964173/npm-install-failing)
Good to know, thanks for logging your progress.
It might be that newer releases of the Pi distros have new issues with different versions of the software stack I presented earlier.
I will need to try this again on a newer Pi with the latest distro I can get.
I use the MVC shown at the bottom here.
All html with wsgi interface to python and sqlite database driven: http://interfaceinnovations.org/ccsoftware.html
Colin