Ubuntu Install Apache + mod_wsgi + Trac + Python 2.7

Source: Internet
Author: User


TRAC is a lightweight software project management system with its own wiki, which adheres to the BSD open source Protocol's open source software. The project homepage is https://trac.edgewall.org, and the source code is mirrored on GitHub git://github.com/edgewall/trac.git

TRAC can run a standalone server and run the server with the following line of commands. If there is only one TRAC instance, this is a way to meet the requirements.

TRACD Path/to/trac--port=8080

Trac can also be run using Apache, which is implemented by loading the MOD_WSGI module to run the Python Web server. This article mainly describes the configuration of TRAC on Ubuntu systems.

Assuming the software has been installed, Mysql-python, Trac (v1.2) and related dependencies are also successfully installed via PIP. Also assume that the TRAC instance is demo installed on/opt/trac/demo, deploy file to/opt/trac-deploy

Software preparation
    • Ubuntu
[Email protected]:~$ lsb_release-aNo LSB modules is available. Distributor id:ubuntudescription:    16.10Release:        16.10codename:       Yakkety
    • Python2.7/pip/mysql5.7/apache2
[Email protected]:~$ python-v2.7.13zhongw@s1: ~$ mysql-vMySQL    for  Linux (i686) using  editline wrapperzhongw@s1: ~$ pip-V   9.0.1 from/home/zhongw/.local/lib/python2.7/site-packages (python 2.7) Zhongw@s1: ~$/usr/local/apache2/bin/apachectl-vServer version:apache/2.4.25 (Unix) Server built:    15:51:58
    • Mod_wsgi
server:apache/2.4.25 (Unix) mod_wsgi/4.5.15 python/2.7
Compiling MOD_WSGI

Apache, MySQL, and Python can all be installed through Apt-get, but Mod_wsgi need to be installed from source code.

Find the source code for the latest released version of Mod_wsgi from GitHub Https://github.com/GrahamDumpleton/mod_wsgi

The version that this article uses is 4.5.15

    • Configure
[Email protected]:~/mod_wsgi-4.5.15$./configure--with-apxs=/usr/local/apache2/bin/apxs--with-python=/usr/local/ bin/pythonchecking forgcc ... gccchecking whether the C compiler works ... yeschecking forC compilerdefaultoutput file name ... a.outchecking forsuffix of executables...checking whether we is cross compiling ... nochecking forsuffix of object files ... ochecking whether we are using the GNU C compiler ... yeschecking whether GCC accepts-g ... yeschecking forgcc option to accept ISO C89 ... none neededchecking forprctl ... yeschecking Apache version ...2.4.25configure:creating./config.statusconfig.status:creating Makefile
    • Run make command to compile Mod_wsgi

If there is a compilation problem, refer to the official document to solve, the common is not found Python.h and other issues, the official detailed description.

    • Make install
[Email protected]:~/mod_wsgi-4.5.15$sudo make install/usr/local/apache2/bin/apxs-i-S libexecdir=/usr/local/apache2/modules-n ' Mod_wsgi ' src/server/mod_wsgi.la/usr/local/apache2/build/instdso.sh sh_libtool= '/usr/local/apr/build-1/libtool ' src/server/mod_wsgi.la/usr/local /apache2/Modules/usr/local/apr/build-1/libtool--mode=install Install src/server/mod_wsgi.la/usr/local/apache2/modules/libtool:install:install src/server/.libs/mod_wsgi.so/usr/local/apache2/modules/mod_wsgi.solibtool:install:install src/server/.libs/mod_wsgi.lai/usr/local/apache2/modules/mod_wsgi.lalibtool:install:install src/server/.libs/mod_wsgi.a/usr/local/apache2/modules/Mod_wsgi.alibtool:install:chmod644/usr/local/apache2/modules/Mod_wsgi.alibtool:install:ranlib/usr/local/apache2/modules/Mod_wsgi.alibtool:finish:PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin:/sbin"Ldconfig-n/usr/local/apache2/Modules----------------------------------------------------------------------Libraries have been installedinch:   /usr/local/apache2/ModulesIfYou ever happen to want to link against installed librariesincha given directory, Libdir, you must either use Libtool, andspecify the full pathname of the library, or use the ' -llibdir ' flag during linking and DoAt least one of the following:-add Libdir to the ' ld_library_path ' environment variable during execution-add Libdir to the ' Ld_run_path ' environment variable during linking-Use the '-wl,-rpath-WL,LIBDIR ' linker flag-Your system administrator add Libdir to '/etc/ld.so.conf ' See all operating system documentation about shared libraries forMore information, such as the LD (1) and ld.so (8) manual pages.----------------------------------------------------------------------chmod755/usr/local/apache2/modules/Mod_wsgi.sozhongw@s1: ~/mod_wsgi-4.5.15$

The Mod_wsgi.so module is already installed in the Apache modules directory.

Verify the Mod_wsgi module

[Email protected]:/usr/local/apache2/modules$ ldd mod_wsgi.so        linux-gate.so.1 =  (0xb7735000 )        Libpython2. 7.so.1.0 =/usr/local/lib/libpython2.7.so.1.0 (0xb74ba000)        libpthread.so. 0 =/lib/i386-linux-gnu/libpthread.so.0 (0xb749d000)        libc.so. 6 =/lib/i386-linux-gnu/libc.so.6 (0xb72e1000)        libdl.so. 2 =/lib/i386-linux-gnu/libdl.so.2 (0xb72dc000)        libutil.so. 1 =/lib/i386-linux-gnu/libutil.so.1 (0xb72d8000)        libm.so. 6 =/lib/i386-linux-gnu/libm.so.6 (0xb7282000)        /lib/ld-linux.so.2 (0x80065000)
Configure httpd.conf

1. Add support for MOD_WSGI in the location of the loading module

LoadModule Wsgi_module modules/mod_wsgi.so

2. Using Apache's htpasswd to generate a password file, TRAC uses the generated password file to manage the user.

Htpasswd-c/opt/trac.htpasswd adminnew password:re- for user admin

3. Add directory and VirtualHost configuration

<Directory/opt/trac-deploy/cgi-bin>Wsgiapplicationgroup%{GLOBAL} <ifmodule mod_authz_core.c>Require All granted </ifmodule></directory><virtualhost*:80>ServerName localhost documentroot"/opt/trac-deploy/htdocs"Wsgiscriptalias//opt/trac-deploy/cgi-bin/Trac.wsgi <locationmatch"/login">authtype Basic AuthName"Trac"AuthUserFile/opt/trac.htpasswd Require Valid-User </locationmatch></virtualhost>

Browse TRAC after restarting service

Ubuntu Install Apache + mod_wsgi + Trac + Python 2.7

Related Article

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.