设为首页 收藏本站
查看: 4010|回复: 0

[经验分享] Ubuntu安装Apache + mod

[复制链接]

尚未签到

发表于 2017-12-24 17:39:10 | 显示全部楼层 |阅读模式
概述
  Trac是自带wiki的轻量级软件项目管理系统,遵循BSD开源协议的开源软件。项目主页是https://trac.edgewall.org, 源代码在Github上有镜像git://github.com/edgewall/trac.git
  Trac可以运行独立服务器,使用下面一行命令即可运行服务器。如果只有一个Trac实例,这种方式完全可以满足需求。
  

tracd path/to/trac --port=8080  

  Trac也可以使用Apache来运行,通过加载mod_wsgi模块来实现运行Python web服务器。本文主要介绍在Ubuntu系统上配置Trac。
  假设软件已经安装完毕,MySQL-python, Trac(v1.2)及相关依赖也通过pip安装成功。同时假设Trac实例为demo安装在/opt/trac/demo, deploy文件到/opt/trac-deploy

软件准备


  • Ubuntu
  

zhongw@s1:~$ lsb_release -a  
No LSB modules are available.

  
Distributor>  
Description:    Ubuntu
16.10  
Release:        
16.10  
Codename:       yakkety
  



  • Python2.7/PIP/MySQL5.7/Apache2
  

zhongw@s1:~$ python -V  
Python
2.7.13  
zhongw
@s1:~$ mysql -V  
mysql  Ver
14.14 Distrib 5.7.17, forLinux (i686) using  EditLine wrapper  
zhongw
@s1:~$ pip -V  
pip
9.0.1 from /home/zhongw/.local/lib/python2.7/site-packages (python 2.7)  
zhongw
@s1:~$ /usr/local/apache2/bin/apachectl -v  
Server version: Apache
/2.4.25 (Unix)  
Server built:   Mar
18 2017 15:51:58
  



  • mod_wsgi
  

Server:Apache/2.4.25 (Unix) mod_wsgi/4.5.15 Python/2.7  


编译mod_wsgi
  Apache, MySQL, Python都可以通过apt-get来安装,但mod_wsgi需要从源代码编译安装。
  从Github找到mod_wsgi的最新发布版本的源代码 https://github.com/GrahamDumpleton/mod_wsgi
  本文使用的版本是4.5.15


  • Configure
  

zhongw@s1:~/mod_wsgi-4.5.15$  ./configure --with-apxs=/usr/local/apache2/bin/apxs --with-python=/usr/local/bin/python  
checking
for gcc... gcc  
checking whether the C compiler works... yes
  
checking
for C compiler default output file name... a.out  
checking
for suffix of executables...  
checking whether we are cross compiling... no
  
checking
for suffix of object files... o  
checking whether we are using the GNU C compiler... yes
  
checking whether gcc accepts
-g... yes  
checking
for gcc option to accept ISO C89... none needed  
checking
for prctl... yes  
checking Apache version...
2.4.25  
configure: creating .
/config.status  
config.status: creating Makefile
  



  • Run make命令编译mod_wsgi
  如果出现编译问题,参考官方文档解决,常见的是找不到Python.h等问题,官方有详细说明。


  • make install
  

zhongw@s1:~/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.so  
libtool: install: install src
/server/.libs/mod_wsgi.lai /usr/local/apache2/modules/mod_wsgi.la  
libtool: install: install src
/server/.libs/mod_wsgi.a /usr/local/apache2/modules/mod_wsgi.a  
libtool: install: chmod
644 /usr/local/apache2/modules/mod_wsgi.a  
libtool: install: ranlib
/usr/local/apache2/modules/mod_wsgi.a  
libtool: 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 installed
in:  

/usr/local/apache2/modules  

  

If you ever happen to want to link against installed libraries  

in a given directory, LIBDIR, you must either use libtool, and  
specify the full pathname of the library, or use the `
-LLIBDIR'  
flag during linking and
do at 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  

- have your system administrator add LIBDIR to `/etc/ld.so.conf'  

  
See any operating system documentation about shared libraries
for  
more information, such as the ld(
1) and ld.so(8) manual pages.  

----------------------------------------------------------------------  
chmod
755 /usr/local/apache2/modules/mod_wsgi.so  
zhongw
@s1:~/mod_wsgi-4.5.15$  

  mod_wsgi.so模块已经安装到了apache的modules目录。
  验证一下mod_wsgi模块
  

zhongw@s1:/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)  


配置httpd.conf
  1. 在加载模块的位置增加对mod_wsgi的支持
  

LoadModule wsgi_module modules/mod_wsgi.so  

  2. 使用apache的htpasswd生成密码文件,Trac使用生成的密码文件来管理用户。
  

htpasswd -c /opt/trac.htpasswd admin  
New password:
  
Re
-type new password:  
Adding password
for user admin  

  3. 增加Directory和VirtualHost配置
  

<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>  

  4. 映射静态资源
  假设Trac的静态资源已经deploy到了/opt/trac-deploy
  

trac-admin /opt/trac/demo deploy /opt/trac-deploy  

  修改httpd.conf增加静态资源
  

Alias /chrome /opt/trac-deploy/htdocs  

<Directory "/opt/trac-deploy/htdocs">  
<IfModule mod_authz_core.c>
  
Require all granted
  
</IfModule>
  
</Directory>
  


重启Httpd服务后浏览Trac
DSC0000.png

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-427589-1-1.html 上篇帖子: apache shiro的工作流程分析 下篇帖子: Configure Apache Virtual Hosts
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表