[PYTHON] [Failure] Install Stack Overflow Clone Askbot on CentOS 6.4

I tried hard because I wanted to use a Stack Overflow-like service, but it failed. If you use PHP's Question2Answer instead, you'll succeed without much effort.

The following is a record that ended up in vain.

I wanted to run a Stack Overflow clone on Sakura's VPS CentOS, so I tried to put in Shapado, which is written in Rails and is also active in development, but failed, so this time I used AskBot written in Python framework Django. I decided to use it. I hope the installation will be successful this time.

Python package management

Apparently I use pip or ʻeasy_install` for installation, but I don't know that!

Both look like Python package management commands, but don't use easy_install or any other name you might have. Since pip is an extension of easy_install, it's best to use pip unless you have a specific reason.

Python has 2.7.3, but it doesn't seem to be included by default because nothing comes out even if I do $ which pip or $ which easy_install. So

$ wget http://peak.telecommunity.com/dist/ez_setup.py
$ sudo python ez_setup.py
$ sudo easy_install pip

Put easy_install and pip in.

Install Askbot

Now that you're ready, install Askbot.

$ sudo pip install askbot

If you think "Oh, this is easy. Yahoi (='▽` =) no "

Could not find a version that satisfies the requirement pytz (from askbot) (from versions: 2011h, 2010b, 2012f, 2010e, 2005m, 2011e, 2010l, 2011k, 2010e, 2009u, 2008c, 2006j, 2009f, 2005m, 2009j, 2009g, 2005k, 2010g, 2010h, 2007c, 2009i, 2007k, 2008g, 2008g, 2009j, 2007i, 2006g, 2008h, 2008i, 2009i, 2006p, 2009p, 2010k, 2007f, 2008i, 2009l, 2009i, 2008g, 2007d, 2010l, 2007k, 2007g, 2009g, 2007c, 2009n, 2009e, 2008c, 2007i, 2008a, 2010o, 2006g, 2009a, 2009p, 2009a, 2010l, 2007k, 2010h, 2007c, 2009r, 2006j, 2011c, 2011j, 2012h, 2009u, 2006g, 2009g, 2005r, 2010b, 2009n, 2009u, 2010g, 2005k, 2007i, 2006p, 2011b, 2013b, 2005k, 2005m, 2006p, 2005r, 2009r, 2009f, 2006j, 2009p, 2009n, 2009l, 2009j, 2008h, 2009e, 2009d, 2008b, 2010o, 2008b, 2008i, 2011k, 2009d, 2009a, 2009r, 2010k, 2010e, 2007f, 2008a, 2008a, 2009d, 2008h, 2012j, 2008b, 2009e, 2007f, 2010k, 2010g, 2011e, 2012h, 2011g, 2012g, 2011g, 2011c, 2013d, 2011e, 2011h, 2012j, 2011n, 2007d, 2012g, 2011j, 2008c, 2009f, 2013b, 2007g, 2005r, 2012c, 2012j, 2010b, 2009l, 2007g, 2012b, 2011c, 2011g, 2012c, 2011d, 2011d, 2012d, 2011k, 2012b, 2011n, 2012f, 2012f, 2010o, 2007d, 2012b, 2012c, 2011h, 2013d, 2013b, 2010h, 2011d, 2012d, 2011n, 2013d, 2011j, 2012g, 2012d, 2004b) Cleaning up... No distributions matching the version for pytz (from askbot)

I was angry at the strangely long error message and dented.

It seems that pip uses only stable packages by default, so

$ sudo pip install --pre askbot

Then it seems OK.

Install DB

The recommendation seems to be PostgreSQL. Since PostgreSQL is already included, install only python related packages

$ sudo pip install psycopg2

Then

UnicodeDecodeError: 'ascii' codec can't decode

I got an error, so when I looked it up, it seems that I have to insert python-devel.

$ sudo yum install python-devel

After that, I installed psycopg2 again and it succeeded.

Create database

psql -U username -d postgres

Log in with

postgres=> create database database_no_namae with owner=username;
CREATE DATABASE
postgres=> alter user username with password 'himitsu_no_pass';
postgres=> \q

Create a database for Askbot, and if you haven't decided on a password, set a password for the user.

And add the following description at the top of pg_hba.conf

local database_no_namae username md5

However, finding out where this pg_hba.conf is located seems to be quite annoying. It was in /var/lib/pgsql/9.2/data/pg_hba.conf in my environment, but it may be somewhere else. See the reference link for details.

Then restart postgresql

$ sudo /etc/init.d/postgresql-9.2 restart

Askbot initial settings

……tired. Well, this is the beginning of the setting of Askbot itself.

First, create a directory to put Askbot. Be careful not to include . at this time. (Because it violates Python's module name rules.)

In my case, I created it like / home / username / apps / askbotnobasyo.

Go to the directory you created and hit $ askbot-setup there.

Then a file for setting up will be created, so use the install command collectstatic.

$ python manage.py collectstatic

And database initialization

$ python manage.py syncdb

Then again, Type Error: Item in from list'' not a string came out and I was about to break my heart.

I found information that I should update to 1.4.2 in the Deller that says Django version is 1.4, but I don't even know how to update or even find out the Django version.

How to find out the version of Django

$ python
Python 2.6.6 (r266:84292, Jul 10 2013, 22:48:45) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import django
>>> django.get_version()
'1.5.2'

If this was 1.4 at least, I could have tried the update ...

-- Time elapsed --

Apparently 1.5 is too new to use, so downgrade to 1.4. However, when I researched it, it seems common sense to use a module that builds a Python environment in a specific directory called virtualenv, and only answers based on that are given.

Reinsert Askbot in the virtualenv environment

Since there is no help for it, I will create an environment with virtualenv and re-install Askbot there. First install virtualenv

$ sudo pip install virtualenv

Create a virtual environment, activate the virtual environment, then install Django 1.4.5

$ virtualenv askbotnobasyo
$ cd askbotnobasyo
$ . /bin/activate
$ pip install django==1.4.5

Create an initialization file for askbot

$ askbot-setup

It ends when you answer what you are asked. And

$ python manage.py collectstatic

Then all static files such as .css and .js are generated in one folder ...

... No! !! It's an error again! Fake! !!

Retry

After all, let's stop using virtualenv. There is only one environment anyway. So escape from virtualenv with $ deactivate.

I didn't know how to downgrade Django, so I used virtualenv, but when I thought about it, I noticed that "uninstall-> install is ok."

$ sudo pip uninstall django
$ sudo pip install django==1.4.5

So create a project folder and move to it

$ askbot-setup
$ python manage.py collectstatic
$ python manage.py syncdb

Until now, I had stumbled on an error, but I finally got it! !! !! Yay! !!

Publish on Nginx and uWSGI

First, take a domain and register Sakura's VPS in that domain. If you don't understand here, please refer to other sites.

So, Nginx is already working in my environment, so it's through. For the time being, set the domain so that it can access the server running on Nginx.

It seems that pypi can be used to install uWGSI. I think the command for pypi is pip.

$ sudo pip install uwgsi

And of course the UnicodeDecodeError that comes back

UnicodeDecodeError: 'ascii' codec can't decode byte 0xe3 in position 17: ordinal not in range(128)

It seems that this happens because the * -devel package is missing, but if so, please write the error message like that.

It seems that uwgsi needs libevent-devel as well as python-devel, so put it in.

$ yum install libevent-devel

So, I tried $ sudo pip install uwgsi, but it still works. According to the information on other sites, there are also libxml2-devel and python-pip, so try using $ sudo yum install libxml2-devel python-pip.

Finally succeeded with the third $ sudo pip install uwsgi!

Create Nginx settings /etc/nginx/site-available/example.com.conf with $ sudo ln -s /etc/nginx/site-available/example.com.conf /etc/nginx/site-enabled/exsample.com.conf

Then open the config file with $ sudo vi exsample.com.conf

server {
  listen 80;
  server_name exmaple.com; 
  access_log /var/log/nginx/example.com.access.log;
  error_log /var/log/nginx/exmaple.com.error.log info;
  location / {
    include uwsgi_params;
    uwsgi_pass localhost:44863
    #uwsgi_param UWSGI_PYHOME /path/to/your/virtualenv;
    uwsgi_param UWSGI_SCRIPT wsgi; #this is the name of the script 
    uwsgi_param UWSGI_CHDIR /home/username/apps/appname;
  }
  location /m/ {
    #use this for askbot <= 0.7.39
    #alias /path/to/your/virtualenv/lib/python2.7/site-packages/askbot/skins/;
    alias /home/username/apps/appname/static/;
    autoindex off;
  }
  location /upfiles/ {
    alias /home/username/apps/appname/askbot/upfiles/;
    autoindex off;
  }
  location /admin/media {
    alias /home/username/apps/appname/static/admin; #or path to admin media in <= 0.7.39
    autoindex off;
  }
}

Then restart with $ sudo service nginx restart. If there is a mistake in the setting, an error will occur here.

Rename django.wsgi in the project folder to wsgi.py and then start uwsgi with various options.

$ sudo uwsgi --chdir=/home/username/apps/appname \
--module='appname.wsgi:application' \
--env DJANGO_SETTINGS_MODULE=appname.settings \
--master --pidfile=/tmp/project-master.pid \
--socket=127.0.0.1:44863 \
--processes=5 \
--harakiri=20 \
--limit-as=128 \
--max-requests=5000 \
--vacuum --daemonize=/var/log/uwsgi/appname.log

reference

python - Why is pip not listed in easy_install on CentOS 6? Where to get it? - Super User http://superuser.com/questions/407926/why-is-pip-not-listed-in-easy-install-on-centos-6-where-to-get-it

python - Could not find a version that satisfies the requirement pytz - Stack Overflow http://stackoverflow.com/questions/18230956/could-not-find-a-version-that-satisfies-the-requirement-pytz

Create database for Askbot — Askbot 0.7.48 documentation http://askbot.org/doc/create-database.html

virtualenv - How to install psycopg2 with "pip" on Python? - Stack Overflow http://stackoverflow.com/questions/5420789/how-to-install-psycopg2-with-pip-on-python

python - can't install psycopg2 on centos - Stack Overflow http://stackoverflow.com/questions/12908807/cant-install-psycopg2-on-centos

postgresql - How do I find the path to pg_hba.conf from the shell? - Ask Ubuntu http://askubuntu.com/questions/256534/how-do-i-find-the-path-to-pg-hba-conf-from-the-shell

Re: I need to know password for postgres http://www.postgresql.org/message-id/1029274812.1353.648.camel@linda

Trying AGAIN to install askbot on a clean server and getting TypeError - Askbot: Open Source Q&A Forum http://askbot.org/en/question/11071/trying-again-to-install-askbot-on-a-clean-server-and-getting-typeerror/

python - How to know what django version i use? is it 1.0, 1.1, or 1.2? - Stack Overflow http://stackoverflow.com/questions/4151788/how-to-know-what-django-version-i-use-is-it-1-0-1-1-or-1-2?answertab=votes#tab-top

On syncdb getting TypeError: Item in ``from list'' not a string - Askbot: Open Source Q&A Forum http://askbot.org/en/question/10153/on-syncdb-getting-typeerror-item-in-from-list-not-a-string/

Generics 3.0: Downgrade the pip installed package http://generics7.blogspot.jp/2013/05/downgrade-pip-installed-package.html

About Python: VIRTUALENV Today http://blog1.erp2py.com/2011/07/virtualenv.html

virtualenv 1.10.1 : Python Package Index https://pypi.python.org/pypi/virtualenv

How to leave a python virtualenv? - Stack Overflow http://stackoverflow.com/questions/990754/how-to-leave-a-python-virtualenv

How to Step by Step Deploy Askbot uWSGI Nginx on CentOS 6 64bit? - Askbot: Open Source Q&A Forum http://askbot.org/en/question/7829/how-to-step-by-step-deploy-askbot-uwsgi-nginx-on-centos-6-64bit/

How to deploy on nginx webserver using uwsgi? - Askbot: Open Source Q&A Forum http://askbot.org/en/question/7492/how-to-deploy-on-nginx-webserver-using-uwsgi/

python - 'ascii' codec can't decode error when use pip to install uwsgi - Stack Overflow http://stackoverflow.com/questions/17931726/ascii-codec-cant-decode-error-when-use-pip-to-install-uwsgi

Django + uWSGI + NGINX environment construction memo on Ubuntu 12.04 | A certain Vimmer blog http://shu-b10g.blogspot.jp/2012/08/django-uwsgi-nginx-on-ubuntu-1204.html

Recommended Posts

[Failure] Install Stack Overflow Clone Askbot on CentOS 6.4
Install Faiss on CentOS 7
Install numba on CentOS 7.2
Install Python3.4 on CentOS 6.6
Install mecab-python on CentOS
Install awscli on centos7
Install Chainer on CentOS 6.7
Install ImageMagick-6.2.x series on CentOS7.7
Install Python 3.8 on CentOS 7 (SCL)
Install Chrome on CentOS 7 series
Install Python 3.8 on CentOS 8 (AppStream)
Steps to install MySQL 8.0 on CentOS 8.1
raspberry pi 4 centos7 install on docker
Steps to install VirtualBox on CentOS
How to install PyPy on CentOS
How to install TensorFlow on CentOS 7
Install pip on CentOS7. Also iPython.
Install VirtualBox on CentOS 7 on VirtualBox (mac + vagrant)
How to install Maven on CentOS
Study Note 9_Install Jenkins on CentOS7
Install Python on CentOS using pyenv
Enable sar command on CentOS (install sysstat)
Install Mecab on Linux (CentOS) with brew
How to install Eclipse GlassFish 5.1.0 on CentOS 7
How to install Apache (httpd) on CentOS8
Install PostgreSQL from source code on CentOS
Install pyenv and rbenv on CentOS system-wide
CentOS8 --Install --Django
CentOS8 --Install --Python3