<\/span><\/h2>\nBefore we begin, we will need to install all the dependencies required by Askbot.<\/p>\n
First, install the “Development Tools” group of packages with the following command:<\/p>\n
yum group install 'Development Tools'<\/pre>\nNext, install the EPEL repository using the following command:<\/p>\n
yum install epel-release<\/pre>\nFinally, install Python packages by running the following command:<\/p>\n
yum install python-pip python-devel python-six<\/pre>\nNext, we will need to create a separate user for the Askbot installation. To create an Askbot user, run the following command:<\/p>\n
useradd -m -s \/bin\/bash askbot<\/pre>\nNext, set the user’s password with the following command:<\/p>\n
passwd askbot<\/pre>\nNext, we will need to add the askbot user to the wheel group for sudo command access. You can do this with the following command:<\/p>\n
usermod -a -G wheel askbot<\/pre>\n<\/span>Step 3: Install and Configure PostgreSQL Database<\/span><\/h2>\nNext, we will need to install PostgreSQL database server. Askbot uses PostgreSQL database to store their data. You can install the PostgreSQL database server along with other required packages by just running the following command:<\/p>\n
yum install postgresql-server postgresql-devel postgresql-contrib<\/pre>\nAfter installing PostgreSQL, initialize the database with the following command:<\/p>\n
postgresql-setup initdb<\/pre>\nNext, start the PostgreSQL service and enable it to start after system reboot with the following command:<\/p>\n
systemctl start postgresql\r\nsystemctl enable postgresql<\/pre>\nYou can also verify the status of PostgreSQL with the following command:<\/p>\n
systemctl status postgresql<\/pre>\nYou should get the following output:<\/p>\n
\u25cf postgresql.service - PostgreSQL database server\r\n Loaded: loaded (\/usr\/lib\/systemd\/system\/postgresql.service; disabled; vendor preset: disabled)\r\n Active: active (running) since Wed 2019-08-21 13:54:07 UTC; 8s ago\r\n Process: 15983 ExecStart=\/usr\/bin\/pg_ctl start -D ${PGDATA} -s -o -p ${PGPORT} -w -t 300 (code=exited, status=0\/SUCCESS)\r\n Process: 15978 ExecStartPre=\/usr\/bin\/postgresql-check-db-dir ${PGDATA} (code=exited, status=0\/SUCCESS)\r\n Main PID: 15986 (postgres)\r\n CGroup: \/system.slice\/postgresql.service\r\n \u251c\u250015986 \/usr\/bin\/postgres -D \/var\/lib\/pgsql\/data -p 5432\r\n \u251c\u250015987 postgres: logger process \r\n \u251c\u250015989 postgres: checkpointer process \r\n \u251c\u250015990 postgres: writer process \r\n \u251c\u250015991 postgres: wal writer process \r\n \u251c\u250015992 postgres: autovacuum launcher process \r\n \u2514\u250015993 postgres: stats collector process \r\n\r\nAug 21 13:54:05 centos systemd[1]: Starting PostgreSQL database server...\r\nAug 21 13:54:07 centos systemd[1]: Started PostgreSQL database server<\/pre>\nNext, we will need to create a new PostgreSQL database and user for the Askbot instance. To do so, first log in to PostgreSQL with the following command:<\/p>\n
su - postgres\r\n-bash-4.2$ psql\r\nOuput:\r\npsql (9.2.24)\r\nType \"help\" for help.<\/pre>\nOnce logged in, create a database and user with the following command:<\/p>\n
postgres=# create database askbot;\r\npostgres=# create user askbot with password 'password<\/span>';<\/pre>\nMake sure you replace “password<\/span>” with a unique, good password.<\/p>\nNext, grant all the privileges to the askbot database and exit from the PostgreSQL shell with the following command::<\/p>\n
postgres=# grant all privileges on database askbot to askbot;\r\npostgres=# \\q<\/pre>\nNext, we will need to configure local user authentication. You can achieve this by editing the pg_hba.conf<\/strong> configuration file:<\/p>\nnano \/var\/lib\/pgsql\/data\/pg_hba.conf<\/pre>\nReplace peer<\/strong><\/span> with md5<\/strong><\/span> to activate password authentication as shown below:<\/p>\n# \"local\" is for Unix domain socket connections only\r\nlocal all all md5<\/span> \r\n# IPv4 local connections:\r\nhost all all 127.0.0.1\/32 md5<\/span> \r\n# IPv6 local connections:\r\nhost all all ::1\/128 md5<\/span><\/pre>\nSave and close the file, then restart the PostgreSQL service to apply configuration changes:<\/p>\n
systemctl restart postgresql<\/pre>\nOnce you have done, you can proceed to the next step.<\/p>\n
<\/span>Step 4: Install and Configure Askbot<\/span><\/h2>\nBefore installing Askbot, we will need to upgrade the python-pip<\/strong> package to the latest version. Run the following command to upgrade python-pip<\/strong>:<\/p>\npip install --upgrade pip<\/pre>\nNext, run the following command to install python virtualenv<\/strong>:<\/p>\npip install virtualenv six<\/pre>\nOnce installed, log in with the askbot user and create a new python virtual environment named my-askbot<\/strong> using the following command:<\/p>\nsu - askbot\r\nvirtualenv my-askbot\r\nYou should get the following output:\r\nNo LICENSE.txt \/ LICENSE found in source\r\nNew python executable in \/home\/askbot\/my-askbot\/bin\/python2\r\nAlso creating executable in \/home\/askbot\/my-askbot\/bin\/python\r\nInstalling setuptools, pip, wheel...\r\ndone.<\/pre>\nNext, change the directory to my-askbot<\/code> and activate the virtual environment with the following command:<\/p>\ncd my-askbot\/\r\n[askbot@centos my-askbot]$ source bin\/activate\r\nOutput:\r\n(my-askbot) [askbot@centos my-askbot]$<\/pre>\nNext, let’s start to install Askbot with other dependencies:<\/p>\n
pip install six==1.10.0\r\npip install askbot psycopg2<\/pre>\nOnce installed, create a new directory for your project:<\/p>\n
mkdir testapp<\/pre>\nNext, change the directory to testapp<\/code> and set up AskBot with the following commands:<\/p>\ncd testapp\r\naskbot-setup<\/pre>\nYou will be asked to provide the directory path you want to deploy AskBot to, as shown below:<\/p>\n
Deploying Askbot - Django Q&A forum application\r\nProblems installing? -> please email admin@askbot.org\r\n\r\nTo CANCEL - hit Ctr-C at any time\r\n\r\nEnter directory path (absolute or relative) to deploy\r\naskbot. To choose current directory - enter \".\"\r\n> .<\/pre>\nType “.” and hit [Enter] to continue. You will be asked to select a database engine:<\/p>\n
Please select database engine:\r\n1 - for postgresql, 2 - for sqlite, 3 - for mysql, 4 - oracle\r\ntype 1\/2\/3\/4: 1<\/pre>\nType “1” and hit [Enter] for PostgreSQL database. Then, provide a database name, username, and password as shown below:<\/p>\n
Please enter database name (required)\r\n> askbot\r\n\r\nPlease enter database user (required)\r\n> askbot\r\n\r\nPlease enter database password (required)\r\n> password<\/span><\/pre>\nOnce the installation has been finished, you should see the following output:<\/p>\n
Copying files: \r\n* __init__.py \r\n* manage.py \r\n* urls.py \r\n* django.wsgi \r\nCreating settings file\r\nsettings file created\r\n\r\ncopying directories: * doc\r\n* cron\r\n* upfiles\r\nDone. Please find further instructions at Askbot documentation.<\/pre>\nNext, we will need to generate Askbot Django static files. You can do this using the following command:<\/p>\n
python manage.py collectstatic<\/pre>\nGenerate the database using the following command:<\/p>\n
python manage.py syncdb<\/pre>\nYou will need to provide your admin user name, password and email as shown below, as well as replacing mydomain.com<\/span> with your domain name:<\/p>\nYou have installed Django's auth system, and don't have any superusers defined.\r\nWould you like to create one now? (yes\/no): yes\r\nUsername (leave blank to use 'askbot'): \r\nEmail address: admin@mydomain.com<\/span>\r\nPassword: \r\nPassword (again): \r\nSuperuser created successfully.<\/pre>\nAskbot is now installed! You can test it with the following command:<\/p>\n
python manage.py runserver 0.0.0.0:8080<\/pre>\nNow, open your web browser and type the URL http:\/\/your-server-ip:8080<\/code>. You will be redirected to the Askbot dashboard as shown in the following screen:<\/p>\n<\/p>\n
<\/span>Step 5: Install and Configure uWSGI<\/span><\/h2>\nNext, we will need to install and configure uWSGI with Nginx to serve your Askbot application. uWSGI is a software tool that supports applications written in Python, Perl, and Ruby. It is typically used for running Python web applications.<\/p>\n
You can install uWSGI using the pip command as a root user:<\/p>\n
pip install uwsgi<\/pre>\nOnce installed, create a new directory for uWSGI:<\/p>\n
mkdir -p \/etc\/uwsgi\/sites<\/pre>\nNext, create a new uWSGI configuration file using the following command:<\/p>\n
nano \/etc\/uwsgi\/sites\/askbot.ini<\/pre>\nAdd the following lines:<\/p>\n
[uwsgi]\r\n\r\nchdir = \/home\/askbot\/my-askbot\/testapp\r\nhome = \/home\/askbot\/my-askbot\r\nstatic-map = \/m=\/home\/askbot\/my-askbot\/testapp\/static\r\nwsgi-file = \/home\/askbot\/my-askbot\/testapp\/django.wsgi\r\nmaster = true\r\nprocesses = 5\r\n# Askbot will running under the sock file\r\nsocket = \/run\/uwsgi\/askbot.sock\r\nchmod-socket = 664\r\nuid = askbot\r\ngid = nginx\r\nvacuum = true\r\n# uWSGI Log file\r\nogto = \/var\/log\/uwsgi.log<\/pre>\nSave and close the file, when you are finished.<\/p>\n
Next, create a systemd service file to manage uWSGI service.<\/p>\n
nano \/etc\/systemd\/system\/uwsgi.service<\/pre>\nAdd the following lines:<\/p>\n
[Unit]\r\nDescription=uWSGI service\r\n\r\n[Service]\r\nExecStartPre=\/bin\/bash -c 'mkdir -p \/run\/uwsgi; chown askbot:nginx \/run\/uwsgi'\r\nExecStart=\/bin\/uwsgi --emperor \/etc\/uwsgi\/sites\r\nRestart=always\r\nKillSignal=SIGQUIT\r\nType=notify\r\nNotifyAccess=all\r\n\r\n[Install]\r\nWantedBy=multi-user.target<\/pre>\nSave and close the file. Then, reload the systemd services with the following command:<\/p>\n
systemctl daemon-reload<\/pre>\n<\/span>Install and Configure Nginx as a reverse Proxy for Askbot<\/span><\/h2>\nNext, we will need to install and configure Nginx as a reverse proxy for the uWSGI application and Askbot.<\/p>\n
First, install the Nginx webserver with the following command:<\/p>\n
yum install nginx -y<\/pre>\nOnce installed, create a new virtual host configuration file for Askbot:<\/p>\n
nano \/etc\/nginx\/conf.d\/askbot.conf<\/pre>\nAdd the following lines:<\/p>\n
server {\r\n listen 80;\r\n server_name forum.mydomain.com<\/span>;\r\n location \/ {\r\n include uwsgi_params;\r\n uwsgi_pass\t unix:\/run\/uwsgi\/askbot.sock;\r\n }\r\n }<\/pre>\nMake sure to replace mydomain.com<\/span> with your registered domain name.<\/p>\nSave and close the file, when you are finished.<\/p>\n
Start Nginx and uWSGI services, and enable them to start after system reboot with the following command:<\/p>\n
systemctl start nginx\r\nsystemctl enable nginx\r\nsystemctl start uwsgi\r\nsystemctl enable uwsgi<\/pre>\nYou can now check the status of uWSGI service with the following command:<\/p>\n
systemctl status uwsgi<\/pre>\nIf everything goes fine, you should get the following output:<\/p>\n
\u25cf uwsgi.service - uWSGI Emperor service\r\n Loaded: loaded (\/etc\/systemd\/system\/uwsgi.service; disabled; vendor preset: disabled)\r\n Active: active (running) since Wed 2019-08-21 14:34:03 UTC; 16s ago\r\n Process: 28557 ExecStartPre=\/bin\/bash -c mkdir -p \/run\/uwsgi; chown askbot:nginx \/run\/uwsgi (code=exited, status=0\/SUCCESS)\r\n Main PID: 28560 (uwsgi)\r\n Status: \"The Emperor is governing 1 vassals\"\r\n CGroup: \/system.slice\/uwsgi.service\r\n \u251c\u250028560 \/bin\/uwsgi --emperor \/etc\/uwsgi\/sites\r\n \u251c\u250028562 \/usr\/bin\/uwsgi --ini askbot.ini\r\n \u251c\u250028570 \/usr\/bin\/uwsgi --ini askbot.ini\r\n \u251c\u250028571 \/usr\/bin\/uwsgi --ini askbot.ini\r\n \u251c\u250028572 \/usr\/bin\/uwsgi --ini askbot.ini\r\n \u251c\u250028573 \/usr\/bin\/uwsgi --ini askbot.ini\r\n \u2514\u250028574 \/usr\/bin\/uwsgi --ini askbot.ini\r\n\r\nAug 21 14:34:03 centos uwsgi[28560]: your processes number limit is 3854\r\nAug 21 14:34:03 centos uwsgi[28560]: your memory page size is 4096 bytes\r\nAug 21 14:34:03 centos uwsgi[28560]: detected max file descriptor number: 1024\r\nAug 21 14:34:03 centos uwsgi[28560]: *** starting uWSGI Emperor ***\r\nAug 21 14:34:03 centos systemd[1]: Started uWSGI Emperor service.\r\nAug 21 14:34:03 centos uwsgi[28560]: *** has_emperor mode detected (fd: 7) ***\r\nAug 21 14:34:03 centos uwsgi[28560]: [uWSGI] getting INI configuration from askbot.ini\r\nAug 21 14:34:03 centos uwsgi[28560]: [uwsgi-static] added mapping for \/m => \/home\/askbot\/my-askbot\/testapp\/static\r\nAug 21 14:34:04 centos uwsgi[28560]: Wed Aug 21 14:34:04 2019 - [emperor] vassal askbot.ini has been spawned\r\nAug 21 14:34:04 centos uwsgi[28560]: Wed Aug 21 14:34:04 2019 - [emperor] vassal askbot.ini is ready to accept requests<\/pre>\n