#安装eaccelerator
cd /usr/local/src
tar xzvf eaccelerator.tar.gz
cd /usr/local/src/eaccelerator-eaccelerator-42067ac
/usr/local/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php/bin/php-config
make && make install
/usr/local/php/lib/php/extensions/no-debug-zts-20090626/
9)整合Apache与PHP及系统初化配置
vim /usr/local/apache/conf/httpd.conf
查找AddType application/x-gzip .gz .tgz,在该行下面添加
AddType application/x-httpd-php .php
查找DirectoryIndex index.html 把该行修改成
DirectoryIndex index.html index.htm index.php
找到
#Include conf/extra/httpd-mpm.conf
#Include conf/extra/httpd-info.conf
#Include conf/extra/httpd-vhosts.conf
#Include conf/extra/httpd-default.conf
去掉#
apache截断配置
找到 #ErrorLog "logs/error_log" 改为:
ErrorLog "|/usr/local/apache/bin/rotatelogs /usr/local/apache/logs/errorlog.%Y-%m-%d-%H_%M_%S 50M +480"
找到 #CustomLog "logs/access_log" common 改为
CustomLog "|/usr/local/apache/bin/rotatelogs /usr/local/apache/logs/accesslog.%Y-%m-%d-%H_%M_%S 50M +480" common
配置增加如下:
sudo vim /usr/local/php/etc/php.ini
zend_extension="/usr/local/php/lib/php/extensions/no-debug-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="512"
eaccelerator.cache_dir="/tmp/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
eaccelerator.keys = "disk_only"
eaccelerator.sessions = "disk_only"
eaccelerator.content = "disk_only"
新建一个虚拟主机
mkdir -p /website
然后把探针放到这个目录
vim /usr/local/apache/conf/httpd.conf
找到
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all //把这里的Deny改成Allow
</Directory>
找到
#ServerName www.example.com:80 在这一行后面加入下面一行
ServerName 127.0.0.1:80
找到
User httpd
Group httpd
把原来的daemon修改成httpd
Apache 运行账户 httpd:httpd
chown -R httpd:httpd /website
10)安全和性能优化
vim /usr/local/php/etc/php.ini
查找disable_functions =
等号后面加入以下参数,注意不能换行
passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,pfsockopen,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server
查找以下2项,把on改成off
expose_php = Off
display_errors = Off
vim /usr/local/apache/conf/extra/httpd-default.conf 修改后的内容如下
Timeout 15
KeepAlive Off
MaxKeepAliveRequests 50
KeepAliveTimeout 5
UseCanonicalName Off
AccessFileName .htaccess
ServerTokens Prod
ServerSignature off
HostnameLookups Off
vim /usr/local/apache/conf/extra/httpd-mpm.conf 修改一个模块后的内容如下
#查看使用哪种模式
/usr/local/apache/bin/httpd -l
例如出现 event.c
原来的配置如下:
<IfModule mpm_event_module>
StartServers 3
MinSpareThreads 75
MaxSpareThreads 250
ThreadsPerChild 25
MaxRequestWorkers 400
MaxConnectionsPerChild 0
</IfModule>
修改后配置如下
<IfModule mpm_event_module>
ServerLimit 2000
StartServers 200
MinSpareThreads 75
MaxSpareThreads 250
ThreadsPerChild 25
MaxRequestWorkers 400
MaxConnectionsPerChild 10000
MaxClients 2000
</IfModule>