http://httpd.apache.org/download.cgi#apache22
name:httpd-2.4.25.tar.bz2
tar jxf httpd-2.4.25.tar.bz2
./configure --prefix=/usr/local/apache --enable-module=most --enable-shared=max
说明:配置Apache。这里我把默认可以生成的"httpd"改成了"apache"的目录,目的为了便于查找)
解决办法:
a. 下载所需软件包:
wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz
wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip
b. 分别编译它们:
tar -zxf apr-1.4.5.tar.gz
cd apr-1.4.5
./configure --prefix=/usr/local/apr
make && make install
**********************************
tar -zxf apr-util-1.3.12.tar.gz
cd apr-util-1.3.12
./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
make && make install
**********************************
unzip -o pcre-8.10.zip
cd pcre-8.10
./configure --prefix=/usr/local/pcre
make && make install
./configure --prefix=/usr/local/apache --enable-module=most --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
make && make install
vi /usr/local/apache/conf/httpd.conf
打开注释 #ServerName www.example.com:80
修改为 ServerName localhost:80
/usr/local/apache/bin/apachectl start
注,如果报错:make_sock: could not bind to address 0.0.0.0:80 no listening sockets available
那么一般是80端口已经被占用了, 可以使用下面两个命令来检查:
1. sudo lsof -i:80
2. netstat -plant
3. kill即可, 重新启动
显示 It Works
整体内容为 Apache + mod_wsgi + flask + python 实现网站建设
Apache HTTP服务器的mod_wsgi扩展模块,实现了Python WSGI标准,可以支持任何兼容Python WSGI标准的Python应用。
tar xvfz mod_wsgi-4.5.14.tar.gz
./configure
make && make install
此时, 在/usr/local/apache/modules下面就有了文件mod_wsgi.so
vi /usr/local/apache/conf/httpd.conf:
添加如下语句:LoadModule wsgi_module modules/mod_wsgi.so
apt-get install python-flask
vi /usr/local/apache/test/test.py
#!/usr/bin/env python
# coding=utf-8
from flask import Flask
app = Flask(__name__)
@app.route('/')
def index():
return "Hello Flask"
if __name__ == "__main__":
app.run(host="0.0.0.0", port=8080)
vi /usr/local/apache/test/test.wsgi
import sys
sys.path.insert(0, "/usr/local/apache/test/")
from test import app as application
WSGIScriptAlias / "/usr/local/apache/test/test.wsgi"
<Directory /usr/local/apache/test>
Require all granted
Allow from all
</Directory>
/usr/local/apache/bin/apachectl restart
即可显示 "Hello Flask"