Closed aoyawale closed 8 years ago
Getting started my have to become a general jump point to specific OS's -> web daemons -> etc
As this grows I expect the documentation to evolve but I don't know how much more can be stuffed into getting-started.md
before people using it get overwhelmed
that is fine. Which ever way works as long we have it documented. I'll try to lsit the packages that I think we might need for RHEL/CENTOS it might be a longer list since I use the minimal_install.iso
Yes I agree, as I normally use CentOS. I hit some roadblocks, so I followed the getting started in Ubuntu for now. I'm also working on this list as well. I'll be happy to contribute and edit as you develop this guide.
for the moment I did yum install openssl* setuptools python-de* libxml* libxs* libffi* and the pip install -r requirements.txt worked after a few tries. I'll have to try to identify which exactly it is or the RHEL/CENTOS correct name.
OS or distro-specific setup guides do sound good, but indeed, getting-started.md
is already pretty lengthy. It might make sense to begin splitting it into a few different guides and have getting-started.md
link to OS or distro-specific guides instead.
I can get started on the RHEL/CENTOS specific and do a pull request when I'm done if they are no issues.
@ryanmerolle have you been able to successfully install on centos? I'm using centos 7 and I run into issues later on when trying to reach the webserver.
Nope. I plan to work on it after the holiday weekend.
Sent from my iPhone
On Jul 2, 2016, at 4:00 PM, chagara notifications@github.com wrote:
@ryanmerolle have you been able to successfully install on centos? I'm using centos 7 and I run into issues later on when trying to reach the webserver.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
@chagara - I've been able to get it running on RHEL7 with no issues, other than the noted differences in package names and a couple of quirks around the configuration of Gunicorn/Supervisor.
@bradpeczka I was able to make a list of the rpms needed but, I think I started having problems with the nginx gunicorn/supervisor part. Its not working. What steps did you have to take to make that work? if you do not mind sharing.
@chagara I found this blog (https://rayed.com/wordpress/?p=1496) to be quite useful. I had issues getting the config includes to work, so just pasted the example Supervisor config from the getting-started.md
documentation there instead, though you'll need to modify the user to 'apache' or whatever nginx uses.
I also slightly edited gunicorn_config.py
by changing the command path to '/bin/gunicorn'
and the user to 'apache'.
@bradpeczka thank you for the information. I'll try to see if I can make it work. So you used nginx or apache?
@chagara We're currently using Centos 6 with netbox and no issues. I configured apache initially and switched everything to nginx for other reasons. Both worked with no apparent issues. What problems are you having?
Well in Centos 7 the problem I'm having at the moment that it seems that nginx is not passing the config and just lands into the "It works !" page. At first I had issues with the packages but, I figured out the needed packages. Now I'm getting an error after I restart supervisord " ImportError: no module named netbox.wsgi" On centos 6 since it needs python 2.7 I need to install that. Do you mind sharing the steps you took or the commands? I must be missing something so simple that I'm over looking it.
Hmm, sounds like a problem with your nginx configuration, and your gunicorn configuration, possibly your supervisord config. It may also be a permissions issue. I'd be happy to look at any of them if you can put them in a gist. Our steps are a bit convoluted because we're running netbox in a subdirectory, so a lot of the configuration looks a little different.
I installed all the configs like described in the getting started guide. The only difference was the names of the packages and creating the sites-available since that is not on centos. Let me look at the config and post it. What other steps did you had to take?
Just like the starting guide: server { listen 80;
server_name netbox-centos7;
access_log off;
location /static/ {
alias /opt/netbox/netbox/static/;
}
location / {
proxy_pass http://127.0.0.1:8001;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
command = '/bin/gunicorn' pythonpath = '/opt/netbox/netbox' bind = '127.0.0.1:8001' workers = 3 user = 'apache'
[program:netbox] command=gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi directory=/opt/netbox/netbox/ user=apache
Ah, that's one issue. Your nginx configurations ought to go in /etc/nginx/conf.d/ (Assuming you are using an up-to-date nginx from the nginx repository http://nginx.org/packages/centos/$releasever/$basearch/
)
Also, in the gunicorn configuration file, I used: bind = '0.0.0.0:8001'
, not sure if this will make a difference for you or not. (I believe it will depend on your server setup)
What error is gunicorn yielding when you try to start it?
I do have the netbox.conf in /etc/nginx/conf.d/ I just paste it all together in there so you can see it together sorry for the confusion. It looks like now the gunicorn error has gone away since I binded to 0.0.0.0 like you mentioned but, its not showing all the page completely.
Getting this errors: 14:07:52 [error] 11000#0: 1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:07:52 [error] 11000#0: 1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:07:52 [error] 11000#0: *1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:07:52 [error] 11000#0: 1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:07:52 [error] 11000#0: 1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:07:52 [error] 11000#0: *1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:20:25 [error] 11092#0: 1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:20:27 [error] 11092#0: 1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:20:57 [error] 11127#0: *1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:20:58 [error] 11127#0: 1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:20:58 [error] 11127#0: 1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:20:59 [error] 11127#0: *1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:20:59 [error] 11127#0: 1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:25:17 [error] 11199#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:25:18 [error] 11199#0: *1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:25:18 [error] 11199#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:28:06 [error] 11199#0: 2 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:37:46 [error] 11312#0: *1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:37:47 [error] 11312#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:07 [error] 11409#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:07 [error] 11409#0: *1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:08 [error] 11409#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:08 [error] 11409#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:08 [error] 11409#0: *1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:08 [error] 11409#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:08 [error] 11409#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:09 [error] 11409#0: *1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:09 [error] 11409#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:09 [error] 11409#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:09 [error] 11409#0: *1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:09 [error] 11409#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:09 [error] 11409#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:09 [error] 11409#0: *1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:10 [error] 11409#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:10 [error] 11409#0: 1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:14 [error] 11409#0: *1 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:25 [error] 11411#0: 2 opendir() "/opt/netbox/netbox/static" failed (13: Permission denied), client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 14:39:25 [error] 11411#0: 2 open() "/opt/netbox/netbox/static/favicon.ico" failed (2: No such file or directory), client: 192.168.5.70, server: , request: "GET /favicon.ico HTTP/1.1", host: "192.168.5.59", referrer: "http://192.168.5.59/" 2016/07/02 14:39:25 [error] 11411#0: *2 open() "/opt/netbox/netbox/static/404.html" failed (2: No such file or directory), client: 192.168.5.70, server: , request: "GET /favicon.ico HTTP/1.1", host: "192.168.5.59", referrer: "http://192.168.5.59/" 2016/07/02 15:10:11 [error] 11411#0: 4 "/opt/netbox/netbox/static/index.html" is not found (2: No such file or directory), client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 15:10:11 [error] 11411#0: 4 open() "/opt/netbox/netbox/static/404.html" failed (2: No such file or directory), client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 15:28:56 [error] 11833#0: *1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 15:31:29 [emerg] 11901#0: unexpected end of file, expecting "}" in /etc/nginx/nginx.conf:48 2016/07/02 15:32:06 [error] 11943#0: 1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 15:36:12 [error] 11998#0: 1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 15:37:45 [error] 12047#0: *1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 15:37:46 [error] 12047#0: 1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: _, request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 15:37:46 [error] 12047#0: 1 directory index of "/opt/netbox/netbox/static/" is forbidden, client: 192.168.5.70, server: , request: "GET / HTTP/1.1", host: "192.168.5.59" 2016/07/02 15:39:36 [error] 12082#0: *1 "/opt/netbox/netbox/static/site/index.html" is not found (2: No such file or directory), client: 192.168.5.70, server: , request: "GET /site/ HTTP/1.1", host: "192.168.5.59" 2016/07/02 15:51:25 [emerg] 12250#0: directive "location" has no opening "{" in /etc/nginx/nginx.conf:38 2016/07/02 15:53:06 [emerg] 12286#0: "location" directive is not allowed here in /etc/nginx/nginx.conf:54 2016/07/02 15:53:26 [emerg] 12320#0: unexpected "}" in /etc/nginx/nginx.conf:56 2016/07/02 15:53:53 [emerg] 12357#0: unexpected end of file, expecting "}" in /etc/nginx/nginx.conf:55 2016/07/02 15:54:21 [crit] 12397#0: 1 connect() to 127.0.0.1:8001 failed (13: Permission denied) while connecting to upstream, client: 192.168.5.70, server: netbox-centos7, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8001/", host: "192.168.5.59", referrer: "http://192.168.5.59/" 2016/07/02 15:54:22 [crit] 12397#0: 1 connect() to 127.0.0.1:8001 failed (13: Permission denied) while connecting to upstream, client: 192.168.5.70, server: netbox-centos7, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:8001/", host: "192.168.5.59", referrer: "http://192.168.5.59/"
Trying to figure out where the permission issue is. I have nginx permission for the files but, not sure if that is the correct way or not.
Odd. Can you show the output of ls -la /opt/netbox/netbox/static
?
root@netbox-centos7 ~]# ls -la /opt/netbox/netbox/static/ total 16 drwxr-xr-x. 12 nginx nginx 4096 Jul 2 15:25 . drwxr-xr-x. 13 nginx nginx 4096 Jul 2 15:25 .. drwxr-xr-x. 6 nginx nginx 47 Jul 2 15:25 admin drwxr-xr-x. 5 nginx nginx 37 Jul 2 15:25 bootstrap-3.3.6-dist drwxr-xr-x. 2 nginx nginx 21 Jul 2 15:25 css drwxr-xr-x. 5 nginx nginx 35 Jul 2 15:25 debug_toolbar drwxr-xr-x. 3 nginx nginx 39 Jul 2 15:25 django_tables2 drwxr-xr-x. 6 nginx nginx 72 Jul 2 15:25 font-awesome-4.6.3 drwxr-xr-x. 4 nginx nginx 4096 Jul 2 15:25 jquery-ui-1.11.4 drwxr-xr-x. 2 nginx nginx 100 Jul 2 15:25 js drwxr-xr-x. 6 nginx nginx 47 Jul 2 15:25 rest_framework drwxr-xr-x. 5 nginx nginx 4096 Jul 2 15:25 rest_framework_swagger
Did you run python2.7 ./manage.py collectstatic
?
yes and I re-ran it again
You have requested to collect static files at the destination location as specified in your settings:
/opt/netbox/netbox/static
This will overwrite existing files! Are you sure you want to do this?
Type 'yes' to continue, or 'no' to cancel: yes
0 static files copied to '/opt/netbox/netbox/static', 212 unmodified.
I see, looks like a permissions issue then. What are the permissions on /opt/netbox/
and /opt/netbox/netbox/
?
[vagrant@netbox-centos7 ~]$ ls -laht /opt/netbox/ total 68K drwxr-xr-x. 7 nginx nginx 4.0K Jul 5 16:34 . -rw-rw-r-- 1 nginx nginx 109 Jul 5 16:34 gunicorn_config.py drwxr-xr-x. 13 nginx nginx 4.0K Jul 2 15:25 netbox drwxr-xr-x. 8 nginx nginx 4.0K Jul 2 15:10 .git -rwxr-xr-x. 1 nginx nginx 318 Jul 2 15:10 requirements.txt drwxr-xr-x. 2 nginx nginx 23 Jul 2 15:10 scripts -rwxr-xr-x. 1 nginx nginx 849 Jul 2 15:10 upgrade.sh drwxr-xr-x. 2 nginx nginx 4.0K Jul 2 15:10 docs -rwxr-xr-x. 1 nginx nginx 3.4K Jul 2 15:10 CONTRIBUTING.md drwxr-xr-x. 2 nginx nginx 75 Jul 2 15:10 docker -rwxr-xr-x. 1 nginx nginx 1.6K Jul 2 15:10 docker-compose.yml -rwxr-xr-x. 1 nginx nginx 589 Jul 2 15:10 Dockerfile -rwxr-xr-x. 1 nginx nginx 58 Jul 2 15:10 .gitignore -rwxr-xr-x. 1 nginx nginx 10K Jul 2 15:10 LICENSE.txt -rwxr-xr-x. 1 nginx nginx 4.4K Jul 2 15:10 README.md -rwxr-xr-x. 1 nginx nginx 134 Jul 2 15:10 .travis.yml drwxr-xr-x. 3 nginx nginx 19 Jul 2 15:10 ..
drwxr-xr-x. 7 nginx nginx 4.0K Jul 5 16:34 .. drwxr-xr-x. 3 nginx nginx 4.0K Jul 2 15:26 utilities drwxr-xr-x. 2 nginx nginx 4.0K Jul 2 15:26 netbox drwxr-xr-x. 12 nginx nginx 4.0K Jul 2 15:25 static drwxr-xr-x. 13 nginx nginx 4.0K Jul 2 15:25 . drwxr-xr-x. 6 nginx nginx 4.0K Jul 2 15:25 secrets drwxr-xr-x. 2 nginx nginx 4.0K Jul 2 15:25 users drwxr-xr-x. 5 nginx nginx 4.0K Jul 2 15:25 ipam drwxr-xr-x. 6 nginx nginx 4.0K Jul 2 15:25 dcim drwxr-xr-x. 4 nginx nginx 4.0K Jul 2 15:25 circuits drwxr-xr-x. 6 nginx nginx 4.0K Jul 2 15:25 extras drwxr-xr-x. 9 nginx nginx 4.0K Jul 2 15:10 templates drwxr-xr-x. 7 nginx nginx 100 Jul 2 15:10 project-static -rwxr-xr-x. 1 nginx nginx 249 Jul 2 15:10 manage.py -rwxr-xr-x. 1 nginx nginx 313 Jul 2 15:10 generate_secret_key.py
BTW I was able to get it to work on Ubuntu right away but, no one at work is exposed to Ubuntu so I'm trying to get it to work on Centos.
Interesting. Your permissions are odd, but they shouldn't break anything. README's are usually not executable.
I believe I know what the issue could be though...CentOS ships with SELinux set to enforcing by default.
To check, you can do # getenforce
If you want to fix it quickly you can do # setenforce Permissive
Or if you want to fix it correctly, use # chcon -Rt httpd_sys_content_t /opt/netbox/netbox/static
Alternately, if you really don't like SELinux, you can # setenforce Disabled
To make SELinux state changes permanent, edit /etc/sysconfig/selinux
started from scratch and I'm getting this page. Turned selinux off.
Did you make and run migrations?
yes, I did the ./manage migrate and ./manage collectstatic
ok, so the page loads but, like before not completely.
Alright, I spun up a VM to try and reproduce your issue. Here's my steps to get it working: (You can even run it as a script if you're brave :smile: ) CENTOS 7 - Centos 6 is similar, but slightly different
# Disable SELinux (you can use setsebool or chcon if you'd rather keep it Enforcing)
setenforce Permissive
# Install postgresql repository
yum localinstall https://download.postgresql.org/pub/repos/yum/9.5/redhat/rhel-7-x86_64/pgdg-centos95-9.5-2.noarch.rpm
# Install posgresql
yum install postgresql95-server postgresql95-devel python-psycopg2 -y
# Enable the service
systemctl enable postgresql-9.5
# Initialize the database
/usr/pgsql-9.5/bin/postgresql95-setup initdb
# Allow password login for users
sed -i -e 's/ident/md5/' /var/lib/pgsql/9.5/data/pg_hba.conf
# Start the service
service postgresql-9.5 start
# Create our user/database
sudo -u postgres psql <<EOL
CREATE DATABASE netbox;
CREATE USER netbox WITH PASSWORD 'J5brHrAXFLQSif0K';
GRANT ALL PRIVILEGES ON DATABASE netbox TO netbox;
\q
EOL
yum install epel-release
yum install -y gcc openssl-devel python python-devel git python-pip libxml2-devel libxslt-devel libffi-devel graphviz
# I chose to clone, but you could pull stable
mkdir -p /opt/netbox
cd /opt/netbox
git clone -b master https://github.com/digitalocean/netbox.git .
pip install -r requirements.txt
sed -i -e "s/'USER': ''/'USER': 'netbox'/" /opt/netbox/netbox/netbox/configuration.py
sed -i -e "s/'PASSWORD': ''/'PASSWORD': 'J5brHrAXFLQSif0K'/" /opt/netbox/netbox/netbox/configuration.py
sed -i -e "s/ALLOWED_HOSTS = \[\]/ALLOWED_HOSTS = \['\*'\]/" /opt/netbox/netbox/netbox/configuration.py
key=`python2.7 /opt/netbox/netbox/generate_secret_key.py`
sed -i -e "s/SECRET_KEY = ''/SECRET_KEY = '$key'/" /opt/netbox/netbox/netbox/configuration.py
python2.7 /opt/netbox/netbox/manage.py migrate
python2.7 /opt/netbox/netbox/manage.py collectstatic
# You should probably createsuperuser too, but django doesn't like heredocs
# You can also test your install at this point using python2.7 manage.py runserver 0.0.0.0:8080
# Up-to-date nginx is better...
echo "[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1" > /etc/yum.repos.d/nginx.repo
yum install -y nginx python-gunicorn supervisor
# nginx config copied from getting-started
echo 'server {
listen 80;
server_name netbox.example.com;
access_log off;
location /static/ {
alias /opt/netbox/netbox/static/;
}
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
add_header P3P \'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"\';
}
}' > /etc/nginx/conf.d/netbox.conf
rm /etc/nginx/conf.d/default
# Don't want to run as root
useradd -M netbox
# gunicorn-config from getting started, bind ip replaced
echo "command = '/usr/bin/gunicorn'
pythonpath = '/opt/netbox/netbox'
bind = '0.0.0.0:8001'
workers = 3
user = 'netbox'" > /opt/netbox/gunicorn_config.py
# supervisor config from getting started
echo "[program:netbox]
command = gunicorn -c /opt/netbox/gunicorn_config.py netbox.wsgi
directory = /opt/netbox/netbox/
user = netbox" >> /etc/supervisord.conf
service nginx restart
service supervisord restart
I'm not completely sure what/if anything you missed, but the above seems to work for me on a clean vm. If you still have issues let me know!
@dinoocch I did everything but, there is something not letting the page stuff load. I ran the server from manage and get this:
[06/Jul/2016 02:54:00] "GET /static/bootstrap-3.3.6-dist/css/bootstrap.min.css HTTP/1.1" 404 123 [06/Jul/2016 02:54:00] "GET /static/font-awesome-4.6.3/css/font-awesome.min.css HTTP/1.1" 404 124 [06/Jul/2016 02:54:00] "GET /static/css/base.css HTTP/1.1" 404 93 [06/Jul/2016 02:54:00] "GET /static/jquery-ui-1.11.4/jquery-ui.css HTTP/1.1" 404 111 [06/Jul/2016 02:54:00] "GET /static/jquery-ui-1.11.4/jquery-ui.min.js HTTP/1.1" 404 114 [06/Jul/2016 02:54:00] "GET /static/js/jquery-2.1.4.min.js HTTP/1.1" 404 103 [06/Jul/2016 02:54:00] "GET /static/bootstrap-3.3.6-dist/js/bootstrap.min.js HTTP/1.1" 404 121 [06/Jul/2016 02:54:00] "GET /static/js/forms.js HTTP/1.1" 404 92 [06/Jul/2016 02:54:00] "GET /static/jquery-ui-1.11.4/jquery-ui.min.js HTTP/1.1" 404 114 [06/Jul/2016 02:54:00] "GET /static/bootstrap-3.3.6-dist/js/bootstrap.min.js HTTP/1.1" 404 121 [06/Jul/2016 02:54:00] "GET /static/js/forms.js HTTP/1.1" 404 92 [06/Jul/2016 02:54:02] "GET / HTTP/1.1" 200 15831 [06/Jul/2016 02:54:03] "GET /static/bootstrap-3.3.6-dist/css/bootstrap.min.css HTTP/1.1" 404 123 [06/Jul/2016 02:54:03] "GET /static/font-awesome-4.6.3/css/font-awesome.min.css HTTP/1.1" 404 124 [06/Jul/2016 02:54:03] "GET /static/jquery-ui-1.11.4/jquery-ui.css HTTP/1.1" 404 111 [06/Jul/2016 02:54:03] "GET /static/css/base.css HTTP/1.1" 404 93 [06/Jul/2016 02:54:03] "GET /static/js/jquery-2.1.4.min.js HTTP/1.1" 404 103 [06/Jul/2016 02:54:03] "GET /static/bootstrap-3.3.6-dist/js/bootstrap.min.js HTTP/1.1" 404 121 [06/Jul/2016 02:54:03] "GET /static/jquery-ui-1.11.4/jquery-ui.min.js HTTP/1.1" 404 114 [06/Jul/2016 02:54:03] "GET /static/js/forms.js HTTP/1.1" 404 92 [06/Jul/2016 02:54:03] "GET /static/jquery-ui-1.11.4/jquery-ui.min.js HTTP/1.1" 404 114 [06/Jul/2016 02:54:03] "GET /static/bootstrap-3.3.6-dist/js/bootstrap.min.js HTTP/1.1" 404 121 [06/Jul/2016 02:54:03] "GET /static/js/forms.js HTTP/1.1" 404 92 [06/Jul/2016 02:54:16] "GET / HTTP/1.1" 200 15831 [06/Jul/2016 02:54:16] "GET /static/bootstrap-3.3.6-dist/css/bootstrap.min.css HTTP/1.1" 404 123 [06/Jul/2016 02:54:16] "GET /static/font-awesome-4.6.3/css/font-awesome.min.css HTTP/1.1" 404 124 [06/Jul/2016 02:54:16] "GET /static/jquery-ui-1.11.4/jquery-ui.css HTTP/1.1" 404 111 [06/Jul/2016 02:54:16] "GET /static/css/base.css HTTP/1.1" 404 93 [06/Jul/2016 02:54:16] "GET /static/js/jquery-2.1.4.min.js HTTP/1.1" 404 103 [06/Jul/2016 02:54:16] "GET /static/jquery-ui-1.11.4/jquery-ui.min.js HTTP/1.1" 404 114 [06/Jul/2016 02:54:16] "GET /static/bootstrap-3.3.6-dist/js/bootstrap.min.js HTTP/1.1" 404 121 [06/Jul/2016 02:54:16] "GET /static/js/forms.js HTTP/1.1" 404 92 [06/Jul/2016 02:54:16] "GET /static/jquery-ui-1.11.4/jquery-ui.min.js HTTP/1.1" 404 114 [06/Jul/2016 02:54:16] "GET /static/bootstrap-3.3.6-dist/js/bootstrap.min.js HTTP/1.1" 404 121 [06/Jul/2016 02:54:16] "GET /static/js/forms.js HTTP/1.1" 404 92
most of this are in red.
alright so I restarted and its good to go. I think the main problem could had been what user to run the services as. I used the netbox user u added in your instructions. I'm going to try this in a couple of servers and see how it goes :+1: I really appreciate it all the help. Do you mind If I use this to put it in a doc and make a pull request ?
@dinoocch thank you for your very detailed instructions. I did run into a problem along the way with pip install and it appears that it might be stemmed from "yum install python-dev" instead of the correct "yum install python-devel". Hope this helps some other people.
Also, I needed to run "setsebool httpd_can_network_connect 1" to keep selinux from denying the connections.
@chagara Sure, go ahead! Glad I could help. @nichols-356 Thanks, fixed those and added a bit about SELinux. Glad I could help!
@dinooch thanks so much for the help. What do you think is the problem when the pages do not load right?
@chagara I'm not completely sure. It could have been a lot of things, and without spending time with the broken installation, I'm not sure I can give you a definitive answer. Are you still having any issues?
@dinoocch I tried to deploy it at work so we can use it and I'm stuck in that part where the pages do not load. I followed ur guide and everything. I apologize I never used django or python so I'm still learning this.
is the python-gunicorn from the epel repo or pip?
Either should work.
This is very odd. Are there any nginx errors (/var/log/nginx/errors.log) and does django work correctly when run using python2.7 manage.py runserver 0.0.0.0:8080
?
If run it with manage the same thing happens. Its like its not loading the html and all those files correctly.
ok so I finally got it working. I got ownership of netbox to nginx but, ran the supervisord config and gunicorn as root. After restarting everything it seemed to work. Dont know how since this has been the strangest thing I ever seen.
The getting started guide can be followed almost completely but, it looks like the packages have diff names. Will have to figure out then update docs.