Home

zhangyiqun

Thoughts, stories and ideas.

2014年以前 About Feed

12 Apr 2009
部署web服务器的随笔

PHP 5.2.8的库

主要是为了解决字符集问题。

libiconv

由于历史原因,国际化的文字常常由于语言或者国家的原因使用不同的编码。随着互联网时代的到来,通过互联网进行文字交流也逐渐增多:浏览外国的网站,这个时候字符编码的转换变得尤为重要。这带来了一个问题,就是许多字符在某一种编码方式中没有。为了解决这种混乱,Unicode的编码方式被建立。 Unicode是一种超级编码包含了所有这些编码的字符集,因此一些新的文本格式像XML的默认编码方式就是Unicode.

但是很多老式的计算机还在使用当地的传统的字符编码方式。而一些程序,例如邮件程序和浏览器必须能在这些不同的用户编码之间作转换。其他的一些程序则内置支持Unicode,以顺利支持国际化的处理,但是仍然有在Unicode和其他的传统编码之间转换的需求。GNU的libiconv就是为这两种应用设计的编码转换库。

libmcrypt

Libmcrypt is a library which provides a uniform interface to several symmetric encryption algorithms. It is intended to have a simple interface to access encryption algorithms in ofb, cbc, cfb, and ecb modes. The algorithms it supports are DES, 3DES, RIJNDAEL, Twofish, IDEA, GOST, CAST-256, ARCFOUR, SERPENT, SAFER+, and more. The algorithms and modes are also modular so you can add and remove them on the fly without recompiling the library.

mhash

Mhash is a free (under GNU Lesser GPL) library which provides a uniform interface to a large number of hash algorithms. These algorithms can be used to compute checksums, message digests, and other signatures.

mcrypt

mcrypt, and the accompanying libmcrypt, are intended to be replacements for the old Unix crypt, except that they are under the GPL and support an ever-wider range of algorithms and modes.

安装完所有库后必须执行/sbin/ldconfig

#ldconfig 命令的用途主要是在默认搜寻目录(/lib和/usr/lib)以及动态库配置文件/etc/ld.so.conf内所列的目录, 而当用户安装了一个新的动态链接库时,就需要手工运行这个命令。

开启output_buffering。#具体原理了解的不深,暂且不求甚解了。

sed -i ‘s#output_buffering = Off#output_buffering = On#’ /usr/local/webserver/php/etc/php.ini

MySQL 5.1.26 配置优化

./configure –prefix=/usr/local/webserver/mysql/ –enable-assembler –with-extra-charsets=complex –enable-thread-safe-client –with-big-tables –with-readline –with-ssl –with-embedded-server –enable-local-infile

MySQL 5.1 配置文件(my.cnf)优化

[client]

port    = 3306

socket  = /tmp/mysql.sock

[mysql]

prompt=”(\u:s135:)[\d]> ”

no-auto-rehash

[mysqld]

user    = mysql

port    = 3306

socket  = /tmp/mysql.sock

basedir = /usr/local/webserver/mysql

datadir = /usr/local/webserver/mysql/data

open_files_limit    = 600

back_log = 20

max_connections = 100

max_connect_errors = 200

table_cache = 60

external-locking = FALSE

max_allowed_packet = 16M

sort_buffer_size = 128K

join_buffer_size = 128K

thread_cache_size = 10

thread_concurrency = 8

query_cache_size = 0M

query_cache_limit = 2M

query_cache_min_res_unit = 2k

default_table_type = MyISAM

thread_stack = 192K

transaction_isolation = READ-UNCOMMITTED

tmp_table_size = 512K

max_heap_table_size = 32M

/usr/local/webserver/mysql/data/slow.log

/usr/local/webserver/mysql/data/error.log

long_query_time = 1

log_long_format

server-id = 1

#log-bin = /usr/local/mysql/data/binlog

binlog_cache_size = 2M

max_binlog_cache_size = 4M

max_binlog_size = 512M

expire_logs_days = 7

key_buffer_size = 4M

read_buffer_size = 1M

read_rnd_buffer_size = 2M

bulk_insert_buffer_size = 2M

myisam_sort_buffer_size = 4M

myisam_max_sort_file_size = 10G

myisam_max_extra_sort_file_size = 10G

myisam_repair_threads = 1

myisam_recover

[mysqldump]

quick

max_allowed_packet = 16M

/bin/sh /usr/local/webserver/mysql/bin/mysqld_safe –defaults-file=/usr/local/webserver/mysql/my.cnf &

/usr/local/webserver/mysql/bin/mysqladmin -u root password 123

PS:如果跑不起来就vi my.cnf,将其这个选项注解掉#–skip-federated

安装PHP5扩展模块

/usr/local/webserver/php/bin/phpize #phpize命令是用来准备 PHP 外挂模块的编译环境的

./configure –with-php-config=/usr/local/webserver/php/bin/php-config

关于php-config的解释

Tired of writing (and rewriting) code to manage your application’s configuration variables? Take a look at the PEAR Config class, a PHP toolkit designed specifically for manipulating configuration files and the data within them. This article demonstrates using the Config class to read and write configuration files in XML, PHP and INI formats, and use built-in methods to easily build Web-based application configuration modules.

细节

安装nginx前需要的PCRE是Perl Compatible Regular Expressions的缩写

/usr/local/nginx/sbin/nginx –t //验证nginx是否有配置语法错误.

配置完成虚拟主机以后,编辑php.ini把disable_functions里的phpinfo去掉,重启服务,利用Phpinfo函数查看环环配置。

定时与中国国家授时中心授时服务器同步

15 3 * * * /usr/sbin/ntpdate 210.72.145.44> /dev/null 2>&1

ulimit -SHn 51200

-H 设置硬件资源限制.

-S 设置软件资源限制.

-n size:设置内核可以同时打开的文件描述符的最大值.单位:n

#内核(kernel)利用文件描述符(file descriptor)来访问文件。文件描述符是非负整数。打开现存文件或新建文件时,内核会返回一个文件描述符。读写文件也需要使用文件描述符来指定待读写的文件。

参考文献

LEMP构建高性能WEB服务器(第三版)

Nginx 0.7.x + PHP 5.2.8(FastCGI)搭建胜过Apache十倍的Web服务器

1、除特别说明外,本博客内容皆为原创,可以自由转载传播,但请署名及注明出处,不尊重别人劳动成果的不欢迎;

2、本博客内容遵守“署名-非商业性使用-禁止演绎 2.5 中国大陆”协议;


zhangyiqun

scribble

2014年以前 About Feed