Installation

Installation

Isso是一个用Python编写的Web应用程序。如果pip和virtualenv对您来说没有任何意义,请继续从Pypi安装(Install from PyPi)。如果您正在运行Debian/Ubuntu、Gentoo、Archlinux或Fedora,则可以使用预编译软件包(Prebuilt Packages)。如果没有,请仔细阅读下一节。

Interludium: Python is not PHP

如果您认为托管用Python编写的Web应用程序与使用PHP编写的Web应用程序一样容易,那您就错了。与PHP不同,许多Linux发行版都使用Python作为内部工具。您的软件包管理器已经提供了几个python库,但是Isso可能并不需要全部。

That’s why most Python developers use the Python Package Index to get their dependencies. The most important rule to follow is to never install anything from PyPi as root. Not because of malicious software, but because you will break your system. easy_install is one tool to mess up your system. Another package manager is pip. If you ever searched for an issue with Python/pip and Stackoverflow is suggesting you easy_install pip or pip install --upgrade pip (as root of course!), you are doing it wrong. Why you should not use Python’s easy_install carelessly on Debian is worth the read.

幸运的是,Python提供了一种安装软件包(以root身份和以普通用户身份)而不干扰您全局安装的软件包的方法: virtualenv 。如果您要安装自己喜欢的软件包管理器中没有的软件,请 始终 使用此方法。

# for Debian/Ubuntu
~> sudo apt-get install python-setuptools python-virtualenv python-dev

# Fedora/Red Hat
~> sudo yum install python-setuptools python-virtualenv python-devel

后续步骤应以普通用户而非root用户的身份进行(虽然可以,但不建议):

~> virtualenv /opt/isso
~> source /opt/isso/bin/activate

调用 source 之后,您现在可以从PyPi安装软件包到该虚拟环境中。如果您不再喜欢Isso,则只需 rm -rf 该文件夹(/opt/isso)。在此虚拟环境中,您还可以执行上方示例命令以升级Python软件包管理器(pip),它完全独立于全局系统。

要在虚拟环境外使用安装到虚拟环境里的Isso,只需要将 /opt/isso/bin 添加到 PATH 环境变量中,或直接执行 /opt/isso/bin/isso 。它会从虚拟环境中启动Isso。

在激活virtualenv的情况下,您现在可以继续从PyPi安装(Install from PyPi)!当然,在运行专用虚拟机或共享主机(例如Uberspace.de)时,您可能不需要virtualenv。

Install from PyPi

要求

  • Python 2.7 or 3.4+ (+ devel headers)

  • SQLite 3.3.8 or later

  • C编译器

对于Debian/Ubuntu,只需 复制并粘贴 到您的终端:

~> sudo apt-get install python-dev sqlite3 build-essential

与Fedora(及其衍生产品)类似:

~> sudo yum install python-devel sqlite
~> sudo yum groupinstall "Development Tools"

Installation

pip 安装Isso:

~> pip install isso  # 安装国内增强版:pip install isso-cn

Don’t have pip?

~> easy_install isso  # cross your fingers; or easy_install isso-cn

为了更容易执行,您可以将可执行文件符号链接到 PATH 中的某个位置。

~> ln -s /opt/isso/bin/isso /usr/local/bin/isso

Upgrade

要升级Isso,请再次激活您的虚拟环境,然后运行

~> source /opt/isso/bin/activate  # optional
~> pip install --upgrade isso # 更新国内增强版:pip install -U isso-cn

Prebuilt Packages

Build a Docker image

您可以通过运行 docker build . -t isso 生成Docker镜像。假设您在 /opt/isso 中进行了配置,则可以使用以下命令生成Docker容器:

~> docker run -d --rm --name isso -p 127.0.0.1:8080:8080 -v /opt/isso:/config -v /opt/isso:/db isso

然后,您可以使用反向代理来公开8080端口。

Install from Source

如果您想破解Isso或查找问题,可以使用另一种方法来设置Isso。它需要更多的依赖和精力:

  • Python 2.7 or 3.4+ (+ devel headers)

  • Virtualenv

  • SQLite 3.3.8 or later

  • C编译器

  • Node.js, NPM and Bower

取得Isso的新副本:

~> git clone https://github.com/posativ/isso.git # 国内版:git clone https://github.com/staugur/isso-cn.git isso
~> cd isso/

要创建虚拟环境(推荐),请运行:

~> virtualenv .
~> source ./bin/activate

安装Isso及其依赖项:

~> python setup.py develop  # or `install`
~> isso run

安装JavaScript模块:

~> npm install -g bower # or `yarn global add bower`
~> make init

未优化下的集成:

<script src="/js/config.js"></script>
<script data-main="/js/embed" src="/js/components/requirejs/require.js"></script>

优化:

~> npm install -g requirejs uglify-js jade # or `yarn global add requirejs uglify-js jade`
~> make js

Init scripts

如果您不使用FastCGi或uWSGI,那么可以用Init scripts将Isso作为服务运行(检查您的发行版文档以了解您的init-system,例如Debian使用SysVinit、Fedora使用systemd):

If you’re writing your own init script, you can utilize start-stop-daemon to run Isso in the background (Isso runs in the foreground usually). Below you will find a very basic SysVinit script which you can use for inspiration:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          isso
# Required-Start:    $local_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Description:       lightweight Disqus alternative
### END INIT INFO

EXEC=/opt/isso/bin/isso
EXEC_OPTS="-c /etc/isso.cfg run"

RUNAS=isso
PIDFILE=/var/run/isso.pid

start() {
  echo 'Starting service…' >&2
  start-stop-daemon --start --user "$RUNAS" --background --make-pidfile --pidfile $PIDFILE \
                    --exec $EXEC -- $EXEC_OPTS
}

stop() {
  echo 'Stopping service…' >&2
  start-stop-daemon --stop --user "$RUNAS" --pidfile $PIDFILE --exec $EXEC
}

case "$1" in
  start)
    start
    ;;
  stop)
    stop
    ;;
  restart)
    stop
    start
    ;;
  *)
    echo "Usage: $0 {start|stop|restart}"
esac