三、编译安装A.M.P环境
1.下载软件编译安装
2) 安装MySQL
# tar xvf mysql-5.0.51b.tar.gz
——————-cut begin——————————————-
CHOST=”i686-pc-linux-gnu” CFLAGS=”-march=prescott -O2 -pipe -fomit-frame-pointer” CXXFLAGS=”${CFLAGS}” ./configure ”–prefix=/usr/local/mysql” ”–localstatedir=/data/mysql/data” ”–with-comment=Source” ”–with-server-suffix=-LinuxTone” ”–with-mysqld-user=mysql” ”–without-debug” ”–with-big-tables” ”–with-charset=gbk” ”–with-collation=gbk_chinese_ci” ”–with-extra-charsets=all” ”–with-pthread” ”–enable-static” ”–enable-thread-safe-client” ”–with-client-ldflags=-all-static” ”–with-mysqld-ldflags=-all-static” ”–enable-assembler” ”–without-isam” ”–without-innodb” ”–without-ndb-debug” make && make install mkdir -p /data/mysql/data useradd mysql -d /data/mysql -s /sbin/nologin /usr/local/mysql/bin/mysql_install_db –user=mysql cd /usr/local/mysql chown -R root:mysql . chown -R mysql /data/mysql/data cp share/mysql/my-huge.cnf /etc/my.cnf cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld chmod 755 /etc/rc.d/init.d/mysqld chkconfig –add mysqld /etc/rc.d/init.d/mysqld start cd /usr/local/mysql/bin for i in *; do ln -s /usr/local/mysql/bin/$i /usr/bin/$i; done
——————-cut end———————————————
#sh mysql.sh 即可开始编译.
3) 编译安装Apache
./configure
”–prefix=/usr/local/apache2″ ”–with-included-apr” ”–enable-so” ”–enable-deflate=shared” ”–enable-expires=shared” ”–enable-rewrite=shared” ”–enable-static-support” ”–disable-userdir” make make install echo ‘/usr/local/apache2/bin/apachectl start ‘ >> /etc/rc.local
4.)编译安装PHP
./configure
”–prefix=/usr/local/php” ”–with-apxs2=/usr/local/apache2/bin/apxs” ”–with-config-file-path=/usr/local/php/etc” ”–with-mysql=/usr/local/mysql” ”–with-libxml-dir=/usr/local/libxml2″ ”–with-gd=/usr/local/gd2″ ”–with-jpeg-dir” ”–with-png-dir” ”–with-bz2″ ”–with-freetype-dir” ”–with-iconv-dir” ”–with-zlib-dir ” ”–with-openssl=/usr/local/openssl” ”–with-mcrypt=/usr/local/libmcrypt” ”–enable-soap” ”–enable-gd-native-ttf” ”–enable-ftp” ”–enable-mbstring” ”–enable-exif” ”–disable-ipv6″ ”–disable-cgi” ”–disable-cli” #禁掉ipv6,禁掉cli模式,提升速度和安全性.请根据具体需求定制相关的编译数. make make install mkdir /usr/local/php/etc cp php.ini-dist /usr/local/php/etc/php.ini
5)Xcache的安装.
#/usr/local/php/bin/phpize
./configure –enable-xcache –enable-xcache-coverager –with-php-config=/usr/local/php/bin/php-config –enable-inline-optimization –disable-debug
#vi /usr/local/php/etc/php.ini (将以下内容加入php.ini最后面)
——————-cut begin——————————————-
[xcache-common] zend_extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/xcache.so [xcache.admin] xcache.admin.user = “admin” ;如何生成md5密码: echo -n “password”| md5sum xcache.admin.pass = “035d849226a8a10be1a5e0fec1f0f3ce” #密码为52netseek
[xcache]
[xcache.coverager]
6) 安装Zend Optimizer
2. 整合Apache与PHP及系统初化配置.
找到:
找到:
修改完成后保存退出。
2)查看确认L.A.M.P环境信息、提升 PHP 安全性
3)脚本自动完成初始化配置(以上配置可以用脚本自动化完成)
——————-cut begin——————————————-
#!/bin/bash #Written by :NetSeek http://www.linuxtone.org #init_httpd.conf http_cf=”/usr/local/apache2/conf/httpd.conf” sed -i -e “s/User daemon/User www/” -i -e “s/Group daemon/Group www/” $http_cf sed -i -e ’121 s/^/#/’ -i -e ’122 s/^/#/’ $http_cf sed -i ‘s#DirectoryIndex index.html# DirectoryIndex index.php index.html index.htm#/g’ $http_cf sed -i -e ’374 s/^#//g’ -i -e ’389 s/^#//g’ -i -e ’392 s/^#//g’ -i -e ’401 s/^#//g’ $http_cf #init_php(PHP安全设置及隐藏PHP版本) php_cf=”/usr/local/php/etc/php.ini” sed -i ’205 s#;open_basedir =#open_basedir = /data/www/wwwroot:/tmp#g’ $php_cf sed -i ’210 s#disable_functions =#disable_functions = phpinfo,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#g’ $php_cf sed -i ‘/expose_php/s/On/Off/’ $php_cf sed -i ‘/display_errors/s/On/Off/’ $php_cf ——————-cut end——————————————-
三、配置虚拟主机及基本性能调优
NameVirtualHost *:80
ServerAdmin cnseek@gmail.com
2).基本性能调优参考:(更多的调优相关文章请关注:http://bbs.linuxtone.org/index.html 性能调优相关的贴子)
Timeout 15
KeepAlive Off MaxKeepAliveRequests 50 KeepAliveTimeout 5 UseCanonicalName Off AccessFileName .htaccess ServerTokens Prod ServerSignature Off HostnameLookups Off
#vi /usr/local/apache2/conf/extra/httpd-mpm.conf
ServerLimit 2000
StartServers 10 MinSpareServers 10 MaxSpareServers 15 MaxClients 2000 MaxRequestsPerChild 10000
3).Apache日志处理相关问题汇总贴(http://bbs.linuxtone.org/thread-102-1-1.html )
忽略不需要的日志配置参考具体请据据具体问题分析:
# filter the localhost visit
SetEnvIf Remote_Addr “127.0.0.1″ dontlog # filter some special directories SetEnvIf Request_URI “^ZendPlatform.*[code] # filter the localhost visit SetEnvIf Remote_Addr "127.0.0.1" dontlog # filter some special directories SetEnvIf Request_URI "^ZendPlatform.*[ DISCUZ_CODE_9 ]quot; dontlog SetEnvIf Request_URI .healthcheck.html$ dontlog SetEnvIf Remote_Addr "::1" dontlog SetEnvIf Request_URI ".getPing.php[ DISCUZ_CODE_9 ]quot; dontlog SetEnvIf Request_URI "^/error.html[ DISCUZ_CODE_9 ]quot; dontlog SetEnvIf Request_URI ".gif[ DISCUZ_CODE_9 ]quot; dontlog SetEnvIf Request_URI ".jpg[ DISCUZ_CODE_9 ]quot; dontlog SetEnvIf Request_URI ".css[ DISCUZ_CODE_9 ]quot; dontlog
quot; dontlog
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$ RewriteCond %{HTTP_REFERER} !^http://(www.)?mydomain.com/.*$ [NC] RewriteRule .(gif|jpg)$ http://网站域名/nolink.png [R,L]
四、基本安全设置
原文链接:http://bbs.linuxtone.org/thread-122-1-1.html IT运维专家网–”自由平等,互助分享!”
(责任编辑:IT) |