Installation guide for Centos6.8 installation CKAN2.5.2

Source: Internet
Author: User
Tags apache solr ini join postgresql solr iptables tomcat virtualenv
Pre-conditions

The basics of this tutorial are that Java and Python are already installed on your PC. The following three steps are required to ensure that the installation conditions are met. Step 1 confirms that the base package is installed

Using Command Rpm-qa | grep SELinux, Rpm-q policycoreutils and Rpm-qa | grep setroubleshoot to confirm that you have installed the SELinux package. If not, you need to install it first.

Confirm that you have installed the following: Selinux-policy-targeted, Selinux-policy, Libselinux, Libselinux-python, Libselinux-utils, Policycoreutils, Setroubleshoot, Setroubleshoot-server, Setroubleshoot-plugins.

As the root user of Linux, use the following command to install a package that you do not have installed in the above listed content.

Yum Install Package-name  

The following installation is optional: Policycoreutils-gui,selinux-policy-devel,mcstrans. Step 2 Open SELinux

Using the command/usr/sbin/getenforce or/usr/sbin/sestatus to check the status of SELinux, the command Getenforce returns enforcing, Permissive, or Disabled. If return enforcing indicates that SELinux is open (SELinux rules are executed):

#/usr/sbin/getenforce
Enforcing

If SELinux is a disabled state, you need to open it before installing Ckan.

Before you open SELinux, each file of the file system must be marked with the SELinux content. Prior to this, the restricted part may be defined as the allowed state, so that your system does not start correctly, to ensure that the/etc/selinux/config file is elinux=permissive:

[Root@localhost ~]# vi/etc/selinux/config # This file controls the state of the SELinux on the
system.
# selinux= can take one of the these three values:
#       Enforcing-selinux security policy is enforced.
#       Permissive-selinux Prints warnings instead of enforcing.
#       Disabled-no SELinux policy is loaded.
Selinux=permissive
# selinuxtype= can take one of these values:
#       targeted-targeted processes is prot ected,
#       Mls-multi level Security protection.
selinuxtype=targeted

Then, as the root of Linux, execute the command reboot to restart the computer so that the file system will be flagged during the next boot. Step 3 Install python-Required packages

In the 9th step of the installation, the defined WSGI file requires Python's Paste.deploy and paste.script packages, which you can use to determine whether to install:

# python
>>> from paste.deploy import Loadapp
>>> from Paste.script.util.logging_config Import Fileconfig

If you do not have an error after executing the command, you can skip the steps below, and if the prompt does not have the relevant package, and you install the PIP package, you can install both packages directly from the following two statements:

Pip install Pastedeploy
pip install Pastescript

Tip: Packages Paste.deploy and paste.script are not the same as paste packages. You can exit the Python environment by ctrl+d or exit instructions.

With these conditions, you can start installing Ckan! 1. Install the required packages

Install and activate the CentOS Release Library

# yum Install Centos-release

Update and restart your system

# Yum Update
# shutdown-r now

Install the wget and Policycoreutils-python we need to use later.

# yum Install wget Policycoreutils-python

Install and activate additional packages for Enterprise Linux (EPEL) libraries (maybe your PC is already installed)

# RPM-UVH http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

Install the following packages:

# yum Install xml-commons git subversion mercurial postgresql-server postgresql-devel \
PostgreSQL python-devel Libxs Lt libxslt-devel libxml2 libxml2-devel python-virtualenv \
gcc gcc-c++ make Java-1.7.0-openjdk-devel JAVA-1.7.0-OPENJDK tomcat tomcat-webapps \
Tomcat-admin-webapps xalan-j2 unzip Policycoreutils-python Mod_wsgi httpd 
2. Installing CKAN

First, create a CKAN user, CKAN user is created through/sbin/nologin, and mapped by directory/usr/lib/ckan, see file CKAN Deployment documentation.

# useradd-m-s/sbin/nologin-d/usr/lib/ckan-c "Ckan User" Ckan

The newly created directory is set to be readable and its contents will be executed through httpd.

# chmod 755/usr/lib/ckan

Modify the default values and content in the newly created directory so that their contents can be executed through httpd.

# semanage Fcontext--add--ftype----type httpd_sys_content_t "/usr/lib/ckan (/.*)?"
# semanage Fcontext--add--ftype-d--type httpd_sys_content_t "/usr/lib/ckan (/.*)?"
# Restorecon-vr/usr/lib/ckan

Convert to Ckan User

# su-s/bin/bash-ckan

Create a standalone Python environment named default

# virtualenv--no-site-packages Default

Activating the Python environment you just created

# . Default/bin/activate

Download and install CKAN 2.5.2

(default) # pip install--ignore-installed-e Git+https://github.com/okfn/ckan.git@ckan-2.5.2#egg=ckan

Download and install the required Python modules, allowing CKAN to run in a standalone Python environment

(default) # pip install--ignore-installed-r default/src/ckan/pip-requirements-docs.txt

Use the following command to return root identity

(default) # exit ()

or through Ctrl+d. 3. Configure PostgreSQL

Enable PostgreSQL to run automatically when the system starts

# chkconfig PostgreSQL on

Initializing the PostgreSQL database

# service PostgreSQL Initdb

Edit the file/var/lib/pgsql/data/pg_hba.conf so that it can either log on with a password or allow local Postgres users to manage by identifying login. The relevant parts of the file pg_hba.conf need to be modified are as follows:

Local   all         postgres                          ident
local   all                               MD5
# IPV4 local connections:
host    all         127.0.0.1/32          MD5
# IPV6 Local connections: Host all         :: 1/               MD5
start PostgreSQL
# service PostgreSQL Start

Open PostgreSQL:

Service PostgreSQL Start

Convert to Postgres User:

Su-postgres

List the databases that already exist:

# psql-l

Confirming that the data is encoded in UTF8, if not, internationalization can be a problem, because changing Postgresql's encoding requires deleting the previous database, so it's best to pin it before installing CKAN.

The next step is to create a database user, set up a new PostgreSQL database user, named Ckan_default, and then prompt for the user to enter a password password, you have to remember this password, in the following steps will be used

# createuser-s-d-r-P Ckan_default

Create a new PostgreSQL database, named Ckan_default, whose owner is the database user you just created:

# createdb-o Ckan_default ckan_default-e utf-8

To exit the Postgres user environment, you can use Ctrl+d or

# exit
4. Create a CKAN configuration

Convert back to the root user and create a directory file to store the configuration of the Web site:

# mkdir-p/etc/ckan/default
# chown-r ckan/etc/ckan/

Convert to Ckan user and create a profile for the site:

# su-s/bin/bash-ckan
# default/bin/activate
(default) # Cd/usr/lib/ckan/default/src/ckan
(default) # Paster Make-config Ckan/etc/ckan/default/development.ini

Edit the file Development.ini change the corresponding section:

Sqlalchemy.url = Postgresql://ckan_default:pass@localhost/ckan_default
ckan.site_url =/http default.yourdomain.com
ckan.site_id = default
Solr_url = Http://127.0.0.1:8080/solr/schema-2.0.xml

Replace the pass with the one you created in the 3rd step of the password .
Replace the "http://default.yourdomain.com" with the URL you want Ckan to upload data or use other features.

Exit Ckan user, you can use Ctrl+d or command exit. 5. Build Apache SOLR

CKAN cannot use the latest version of Apache SOLR and requires version 1.4.1.

Download and extract Apache SOLR

# Curl Http://archive.apache.org/dist/lucene/solr/1.4.1/apache-solr-1.4.1.tgz | Tar Xzf-

Create a directory to store multiple SOLR cores

# mkdir-p/usr/share/solr/core0/usr/share/solr/core1/var/lib/solr/data/core0 \
/var/lib/solr/data/core1/etc/ Solr/core0/etc/solr/core1

Copy the Apache SOLR War to the established location

# CP APACHE-SOLR-1.4.1/DIST/APACHE-SOLR-1.4.1.WAR/USR/SHARE/SOLR

Copy Apache SOLR configuration cases to the CORE0 directory

# Cp-r APACHE-SOLR-1.4.1/EXAMPLE/SOLR/CONF/ETC/SOLR/CORE0

Edit the configuration file/etc/solr/core0/conf/solrconfig.xml change the following section:

<dataDir>${dataDir}</dataDir>

Copy the configuration of CORE0 to Core1

# Cp-r/etc/solr/core0/conf/etc/solr/core1

Creating symbolic links between/etc and/USR configurations

# ln-s/etc/solr/core0/conf/usr/share/solr/core0/conf
# ln-s/etc/solr/core1/conf/usr/share/solr/core1/conf

Delete the schema provided in the configuration core and connect to the schema file in the Ckan

# rm-f/etc/solr/core0/conf/schema.xml
# ln-s/usr/lib/ckan/default/src/ckan/ckan/config/solr/schema.xml/etc/ Solr/core0/conf/schema.xml
# rm-f/etc/solr/core1/conf/schema.xml
# ln-s/usr/lib/ckan/default/src/ckan/ Ckan/config/solr/schema-1.4.xml/etc/solr/core1/conf/schema.xml

Create a new file, named/etc/tomcat6/catalina/localhost/solr.xml, with the following contents:

<context docbase= "/usr/share/solr/apache-solr-1.4.1.war" debug= "0" privileged= "true" allowlinking= "true" Crosscontext= "true" >
<environment name= "Solr/home" type= "java.lang.String" value= "/USR/SHARE/SOLR" Override= "true"/>
</Context>

Create a new file, named/usr/share/solr/solr.xml, with the following contents:

<SOLR persistent= "True" sharedlib= "Lib" >
    <cores adminpath= "/admin/cores" >
        <core name= " ckan-schema-2.0 "instancedir=" core0 ">
            <property name=" DataDir "value="/var/lib/solr/data/core0 "/>
        </core>
        <core name= "ckan-schema-1.4" instancedir= "Core1" >
            <property name= "DataDir" Value= "/var/lib/solr/data/core1"/>
        </core>
    </cores>
 </solr>

Create authentication information

Make Tomcat the owner of the SOLR directory:

# Chown-r TOMCAT:TOMCAT/USR/SHARE/SOLR/VAR/LIB/SOLR

Open Tomcat

Configuring Tomcat Boot Auto-start

# Chkconfig Tomcat6 on

Turn on Tomcat

# service Tomcat6 Start

If the Tomcat installation succeeds, you will see the Tomcat Welcome screen when you enter the following URL in the browser:

http://localhost:8080/

If the Apache SOLR installation succeeds, you can see its website interface when you enter the following URL in the browser:

Http://localhost:8080/solr
6. Create the Database Tables

Convert to Ckan user, activate the standalone Python environment, and switch to the source directory of the Ckan:

Su-s/bin/bash-ckan
. Default/bin/activate
CD Default/src/ckan

Initialize the CKAN database:

Paster DB init-c/etc/ckan/default/development.ini

You may see some error hints, but will eventually show:

Initialising db:success.
7. Create Datastore (optional step)

Refer to the file Setting up the DataStore to create the required databases and users, set the correct authentication information, and configure your CKAN profile correctly.

Tip: You may need to run the command as root paster--plugin=ckan datastore set-permissions-c/etc/ckan/default/development.ini, as we have not yet for Ckan User to create a password.
Tip: Creating a DataStore is optional. 8. Connecting Who.ini

This step you need in a Python environment, if not, execute the following command:

Su-s/bin/bash-ckan
. Default/bin/activate
CD Default/src/ckan

Who.ini (repoze.who configuration file) needs to be accessible from the directory of your CKAN profile, so you need to create a link to it:

Ln-s/usr/lib/ckan/default/src/ckan/who.ini/etc/ckan/default/who.ini
9. Create a WSGI file

Create a WSGI script file/etc/ckan/default/apache.wsgi for your site, as follows:

Import os
activate_this = Os.path.join ('/usr/lib/ckan/default/bin/activate_this.py ')
execfile (activate_ This, Dict (__file__=activate_this)) from

paste.deploy import loadapp
Config_filepath = Os.path.join ( Os.path.dirname (Os.path.abspath (__file__)), ' Development.ini ') from
paste.script.util.logging_config Import Fileconfig
fileconfig (config_filepath)
application = Loadapp (' config:%s '% config_filepath)

This Modwsgi Apache module will point your Web server's requirements to this WSGI script file, and then this script file will handle these requirements by pointing them to your CKAN case (after initially configuring the Python environment for the CKAN run).

Use Ctrl+d or exit to exit the Ckan user. 10. Create an Apache configuration file

Create your Apache configuration file,/etc/httpd/conf.d/ckan_default.conf, with the following contents:

 wsgisocketprefix/var/run/wsgi <virtualhost 0.0.0.0:80> ServerName default.yourdomain.com serveralias H  ttp://default.yourdomain.com Wsgiscriptalias//ETC/CKAN/DEFAULT/APACHE.WSGI # Pass Authorization info on (needed
    for rest API).
    Wsgipassauthorization on # Deploy as a daemon (avoids conflicts between CKAN instances). Wsgidaemonprocess ckan_default display-name=ckan_default processes=2 threads=15 WSGIProcessGroup Ckan_default # Add this to avoid Apache show error: # ' ah01630:client denied by server configuration:/etc/ckan/default/apache.wsgi "<Directory/etc/ckan/default> Options Indexes followsymlinks allowoverride all Order allow,de NY allow from all </Directory> errorlog/var/log/httpd/ckan_default.error.log Customlog/var/lo G/httpd/ckan_default.custom.log combined </VirtualHost> 

Replace Default.yourdomain.com and www.default.yourdomain.com with the domain name you want to set for your site.

This file enables the Apache Modwsgi module to point the requirements of the Web server to the WSGI script file you just created, and your WSGI file is returned to point to your CKAN case.

Then use the following command to edit the/etc/hosts:

Vi/etc/hosts

Add a new line at the end of the file:

127.0.0.1    default.yourdomain.com

Replace default.yourdomain.com with the domain name of your site, which is the domain name you just set up in/etc/httpd/conf.d/ckan_default.conf. 11. Configure Apache

Open httpd to make the network connection

Setsebool-p Httpd_can_network_connect 1

Configure HTTPD boot automatically

Chkconfig httpd on

Open httpd

Service httpd Start 
12. Configure Iptables

Edit the file/etc/sysconfig/iptables and add the following to the file:

-A input-m state--state new-m tcp-p TCP--dport 80-j ACCEPT

Restart Iptables

Service Iptables Restart
13. Connecting CKAN

Open your browser and enter the URL of the domain you previously set up, and you will see that CKAN is running. For example, my domain name is default.yourdomain.com.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.