2、python27編譯
./configure --prefix=/usr/local/python27 --enable-shared --with-ssl --with-zlib
make
make install
a、--with-ssl 由於openssl-devel版本問題,導致ssl加載不了,可以去掉這個選項編譯一遍
b、重命名 現有python 爲python2.66c、設置/usr/bin/python 軟連接到python27
ln -s /usr/local/python27/bin/python /usr/bin/python
d、libpython2.7.so.1.0的錯誤時的 解決辦法:
vi /etc/ld.so.conf 添加/usr/local/python27/lib/
/sbin/ldconfig
/sbin/ldconfig -v
3、安裝apache
源代碼安裝2.4
3.1、安裝apr-1.5.1
./configure --prefix=/usr/local/apr
make
make install
3.2、安裝apr-util-1.5.4
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
make
make install
3.2、安裝pcre-8.36
./configure --prefix=/usr/local/pcre
make
make install
3.3、安裝openssl
./config --prefix=/usr/local/openssl
make
make install
3.4 缺少expat-2.0.1.tar.gz
下載並安裝
./configure
make
make install
3.5 安裝httpd-2.4.12
./configure --prefix=/usr/local/apache2 --with-ssl=/usr/local/openssl/ssl/ --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/
make
make install
3.6 配置通過/etc/init.d/httpd 啓動
a、修改進程的ID號存儲的路徑
vim /usr/local/apache2/conf/httpd.conf
添加如下一條:
PidFile /var/run/httpd/httpd.pid
b、修改 啓動進程的用戶和組
User apache
Group apache
c、修改apache可執行文件的路徑
apachectl=/usr/local/apache2/bin/apachectl
httpd=${HTTPD-/usr/local/apache2/bin/httpd}
d、啓動時報錯 說找不到 /usr/local/apache/conf/httpd.conf
軟連接一下/usr/local/apache2 目錄到 /usr/local/apache
ln -s /usr/local/apache2 /usr/local/apache
a、禁止訪問問題
下述是 Apache 2.2 VS Apache 2.4 的設定檔有哪些變更差異
Deny All
2.2 configuration:
Order deny,allow
Deny from all
2.4 configuration:
Require all denied
Allow All
2.2 configuration:
Order allow,deny
Allow from all
2.4 configuration:
Require all granted
Allow Host
2.2 configuration:
Order Deny,Allow
Deny from all
Allow from example.org
2.4 configuration:
Require host example.org
Directory 用 Require all granted
<Directory /var/>
Options FollowSymLinks
AllowOverride None
Require all granted
</Directory>
FilesMatch 維持用 Order
<FilesMatch ".+\.phps$">
SetHandler application/x-httpd-php-source
Order Deny,Allow
Allow from all
</FilesMatch>
註釋掉:
#<Directory />
# AllowOverride none
# Require all denied
#</Directory>
WSGISocketPrefix run/wsgi
<VirtualHost *:8000>
DocumentRoot /var/www/test
ErrorLog logs/test-error_log
CustomLog logs/test-access_log common
Alias /media/ /var/www/test/media/
Alias /static/ /var/www/test/static/
LimitRequestLine 65535
WSGIDaemonProcess test processes=1 threads=25 display-name=%{GROUP}
WSGIProcessGroup test
WSGIChunkedRequest On
WSGIScriptAlias / /var/www/test/mysite/wsgi.py
<Directory "/var/www/test">
Options -Indexes +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
b、Couldn't bind unix domain socket '/usr/local/apache/run/wsgi.23685.0.1.sock'
是因爲缺少run目錄
cd /usr/local/apache/
創建run目錄
重啓apache就好了
c、/home/apache/.python-eggs, change the cache directory by setting the PYTHON_EGG_CACHE environment
創建 /home/apache/.python-eggs目錄
d、修改日誌目錄
ErrorLog "/var/log/httpd/error_log"
CustomLog "/var/log/httpd/access_log" common
e、安裝完報不能引入 django1.7.10+pthon2.7.9
==> /var/log/httpd/dx_anhui_hipi_game-error_log <==
[Thu Oct 08 22:01:56.744233 2015] [:error] [pid 5497:tid 140342038816512] [remote 58.60.159.119:30200] mod_wsgi (pid=5497): Target WSGI script '/var/www/dx_anhui_hipi_game/mysite/wsgi.py' cannot be loaded as Python module.
[Thu Oct 08 22:01:56.744250 2015] [:error] [pid 5497:tid 140342038816512] [remote 58.60.159.119:30200] mod_wsgi (pid=5497): Exception occurred processing WSGI script '/var/www/dx_anhui_hipi_game/mysite/wsgi.py'.
[Thu Oct 08 22:01:56.744276 2015] [:error] [pid 5497:tid 140342038816512] [remote 58.60.159.119:30200] Traceback (most recent call last):
[Thu Oct 08 22:01:56.744303 2015] [:error] [pid 5497:tid 140342038816512] [remote 58.60.159.119:30200] File "/var/www/dx_anhui_hipi_game/mysite/wsgi.py", line 16, in <module>
[Thu Oct 08 22:01:56.744337 2015] [:error] [pid 5497:tid 140342038816512] [remote 58.60.159.119:30200] application = get_wsgi_application()
[Thu Oct 08 22:01:56.744407 2015] [:error] [pid 5497:tid 140342038816512] [remote 58.60.159.119:30200] File "/usr/local/python27/lib/python2.7/site-packages/Django-1.7.10-py2.7.egg/django/core/wsgi.py", line 14, in get_wsgi_application
[Thu Oct 08 22:01:56.744439 2015] [:error] [pid 5497:tid 140342038816512] [remote 58.60.159.119:30200] django.setup()
[Thu Oct 08 22:01:56.744459 2015] [:error] [pid 5497:tid 140342038816512] [remote 58.60.159.119:30200] File "/usr/local/python27/lib/python2.7/site-packages/Django-1.7.10-py2.7.egg/django/__init__.py", line 21, in setup
[Thu Oct 08 22:01:56.744488 2015] [:error] [pid 5497:tid 140342038816512] [remote 58.60.159.119:30200] apps.populate(settings.INSTALLED_APPS)
[Thu Oct 08 22:01:56.744507 2015] [:error] [pid 5497:tid 140342038816512] [remote 58.60.159.119:30200] File "/usr/local/python27/lib/python2.7/site-packages/Django-1.7.10-py2.7.egg/django/apps/registry.py", line 78, in populate
[Thu Oct 08 22:01:56.744538 2015] [:error] [pid 5497:tid 140342038816512] [remote 58.60.159.119:30200] raise RuntimeError("populate() isn't reentrant")
[Thu Oct 08 22:01:56.744565 2015] [:error] [pid 5497:tid 140342038816512] [remote 58.60.159.119:30200] RuntimeError: populate() isn't reentrant
[Thu Oct 08 22:42:27.438088 2015] [:error] [pid 5268:tid 139970325456640]
[Thu Oct 08 22:42:27.438091 2015] [:error] [pid 5268:tid 139970325456640] The Python egg cache directory is currently set to:
[Thu Oct 08 22:42:27.438094 2015] [:error] [pid 5268:tid 139970325456640]
[Thu Oct 08 22:42:27.438097 2015] [:error] [pid 5268:tid 139970325456640] /sbin/.python-eggs
[Thu Oct 08 22:42:27.438101 2015] [:error] [pid 5268:tid 139970325456640]
[Thu Oct 08 22:42:27.438105 2015] [:error] [pid 5268:tid 139970325456640] Perhaps your account does not have write access to this directory? You can
[Thu Oct 08 22:42:27.438109 2015] [:error] [pid 5268:tid 139970325456640] change the cache directory by setting the PYTHON_EGG_CACHE environment
[Thu Oct 08 22:42:27.438113 2015] [:error] [pid 5268:tid 139970325456640] variable to point to an accessible directory.
[Thu Oct 08 22:42:27.438116 2015] [:error] [pid 5268:tid 139970325456640]
[Thu Oct 08 22:42:29.941013 2015] [:error] [pid 5268:tid 139970325456640] [remote 58.60.159.119:44288] mod_wsgi (pid=5268): Target WSGI script '/var/www/dx_anhui_hipi_game/mysite/wsgi.py' does not contain WSGI application 'application'.
應該是要設置下環境變量PYTHON_EGG_CACHE=
wsgi中修改application
import time
import traceback
import signal
try:
application = get_wsgi_application()
print 'WSGI without exception'
except Exception:
print 'handling WSGI exception'
# Error loading applications
if 'mod_wsgi' in sys.modules:
traceback.print_exc()
os.kill(os.getpid(), signal.SIGINT)
time.sleep(2.5)
重啓 在查看apache日誌
修改完相應的錯誤後,還原回來就OK了。
f、修改apache默認創建的權限以及刪除的字符編碼
vim /etc/sysconfig/httpd
umask 002
export LANG='en_US.UTF-8'
export LC_ALL='en_US.UTF-8'
4、編譯mod_wsgi
python重新安裝之後,mod_wsgi需要重新裝
cd mod_wsgi-3.4/
apxs的爲apache安裝後的目錄
./configure --with-apxs=/usr/sbin/apxs --with-python=/usr/bin/python
make
make install
apache2.4
./configure --with-apxs=/usr/local/apache2/bin/apxs --with-python=/usr/bin/python
make clean
make
make install
LoadModule wsgi_module modules/mod_wsgi.so
有時候,有些包是已經編譯過的,要重新編譯必須 make clean 否則會導致你怎麼安裝都安裝不上你想要的包
重啓apache報錯:
undefined symbol: apr_atomic_cas
找到
#endif
註釋掉:
/***
#if (APR_MAJOR_VERSION < 1)
#endif
**
5、mod_wsgi的配置
import sys
import os
p = os.path.abspath(os.path.dirname(__file__))
sys.path.insert(0, os.path.split(p)[0])
os.environ["DJANGO_SETTINGS_MODULE"] = "mysite.settings"
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
6、安裝subversion svn客戶端
7、安裝pysvn
8、安裝PIL插件,如果遇到下面錯誤的處理方法
不要去官方下載pil ,安裝 Pillow-2.0.0.zip 就OK了,這個插件包封裝了