Linux+Python+Apahce+wsgi


step zero:安装python

wget https://www.python.org/ftp/python/3.6.0/Python-3.6.0.tar.xz

./configure –prefix=/usr/local/python3  --enable-shared

make

make  install

此时会出现的问题:

 error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
解决办法:

Add /usr/local/lib to /etc/ld.so.conf and run ldconfig. This is a system-wide setting of course.

我的centos 7 好像没有运行ldconfig自动已经配置到系统了

step one:安装apr

wget http://mirrors.hust.edu.cn/apache//apr/apr-1.6.2.tar.gz

./configure --prefix=/usr/local/apr

make -j8

make  install


step two:安装apr-util

wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.6.0.tar.gz

./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

make -j8

make install


step three:安装apache

wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.26.tar.gz

  ./configure --prefix=/usr/local/apache --enable-rewrite --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util 

make

make install

step four:安装mod_wsgi

wget https://codeload.github.com/GrahamDumpleton/mod_wsgi/zip/develop

./configure --with-apxs=/usr/local/apache/bin/apxs --with-python=/usr/bin/python

make

make install


注意:这里的依赖python编译工具是系统自带的版本,因为我的电脑里安装了两个版本的python,所以必须指定为系统自带的python版本。


step five: 配置Apache

打开配置文件,

vi /usr/local/apache/conf/httpd.conf文件

搜索LoadModule的位置,在末端加上

LoadModule wsgi_module modules/mod_wsgi.so

step six: 启动apache

/usr/local/apache/httpd -k start

之前我用下面这种方法启动Apache,结果启动的是系统自带的Apache

service httpd start 或者 (/usr/local/apache/bin/apachectl start)  


Linux 下安装 Apache 后启动提示 (98)Address already in use: make_sock: could not bind to address [::]:80


我是在Ubuntu下测试的,其他的系统参考,操作是一样的


看到这个提示了,就应该想到是端口占用


我们先 netstat -lnp|grep 80 看看有没有占用端口的程序(记得用root权限执行,不然显示不完全)

然后看命令的下一行,有没有 LISTEN (进程ID)/(进程名)


如果有,kill 掉那个进程 ID,再尝试启动 Apache


如果 kill 后还是报错,打开 httpd.conf 或 apache2.conf 文件(Ubuntu 通过 apt-get 安装的是这种)


删掉里面的 Listen 80 这行,因为在 apache2.conf 同级目录下,有一个 ports.conf 已被 Include


重复的监听端口号也会报此错误。最后再启动,应该没问题了


远程无法访问Apache服务器的端口:

原因是防火墙关闭了端口,需要开启需要访问的端口:

#/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT


如果碰到什么坑,欢迎留言交流


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值