apache配置记录
ubuntu默认安装apache的命令
apt-get install apache2
默认安装的prefork模式。其对应的配置
<IfModule mpm_prefork_module>
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 1000
StartServers 5
MinSpareServers 5
MaxSpareServers 10
MaxClients 150
MaxRequestsPerChild 1000
</
IfModule>
如果是worker模式,可以考虑如下配置
<IfModule mpm_worker_module>
ServerLimit 20
ThreadLimit 100
StartServers 3
MaxClients 2000
MinSpareThreads 50
MaxSpareThreads 200
ThreadsPerChild 100
MaxRequestsPerChild 0
ServerLimit 20
ThreadLimit 100
StartServers 3
MaxClients 2000
MinSpareThreads 50
MaxSpareThreads 200
ThreadsPerChild 100
MaxRequestsPerChild 0
</IfModule>
对于KeepAlive需要特别关注下,我的项目不需要KeepAlive
对单个虚拟站点的配置,配置信息写在了sites-available/default里面了
采用的django搭建的网站,配置虚拟站点对应的目录处理
特别注意:如果你单台机器搭建多个python站点,一定要使用pythoninterpreter ***这个命令
<Directory /opt/project/Mars/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory /opt/project/Mars/>
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonPath "['/opt/project/Mars'] + sys.path"
PythonInterpreter Mars
PythonDebug Off
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
<Directory /opt/project/Mars/>
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE settings
PythonPath "['/opt/project/Mars'] + sys.path"
PythonInterpreter Mars
PythonDebug Off
</Directory>
根目录在/opt/project/Mars,但是所有静态文件在
/opt/project/Mars .SO 如下配置,让apache伺服静态文件,不通过model_python解析
AliasMatch ^/(.*)\.(jpg|gif|png|txt|ico|css|js|html)$ /opt/project/Mars/public/$1.$2
<LocationMatch "(?i)\.(jpg|gif|png|txt|ico|css|js|html)$">
SetHandler None
Order allow,deny
Allow from all
SetEnv STATIC 1
<LocationMatch "(?i)\.(jpg|gif|png|txt|ico|css|js|html)$">
SetHandler None
Order allow,deny
Allow from all
SetEnv STATIC 1
</LocationMatch>
apache设置其日志记录为一天一份文件的形式,以及 对于静态文件的请求,不要记录access.log
特别注意:先在上面静态文件处理的地方加了一行命令
SetEnv STATIC 1
ErrorLog "|/usr/sbin/rotatelogs ${APACHE_LOG_DIR}/error.log 86400"
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog "|/usr/sbin/rotatelogs ${APACHE_LOG_DIR}/access.log 86400" combined env=!STATIC
其它地方,再续