源码包下载:
1、php(版本:5.4.8)下载地址:http://cn2.php.net/get/php-5.4.8.tar.bz2/from/this/mirror
2、Nginx(版本:nginx-1.3.8)下载地址:http://nginx.org/download/nginx-1.3.8.tar.gz
?
3、eAccelerator下载地址:http://eaccelerator.net/
4、ImageMagick(版本:6.8.0-4)下载地址:ftp://ftp.kddlabs.co.jp/graphics/ImageMagick/ImageMagick-6.8.0-4.tar.bz2
5、imagick(版本:3.0.1)下载地址:http://pecl.php.net/get/imagick-3.0.1.tgz
6、libconv(版本:1.14)下载地址:http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
7、libmcrypt(版本:)下载地址:ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz
8、mcrypt(版本:2.6.8)下载地址:http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fmcrypt%2F&ts=1353402942&use_mirror=nchc
9、memcached(版本:1.4.15)下载地址:http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
10、pcre(版本:8.31)下载地址:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.bz2
11、mhash(版本:0.9.9.9)下载地址:http://sourceforge.net/projects/mhash/files/latest/download?source=files
?
二、安装编译包
yum install gcc glibc make
三、解压包并开始安装
1、解压libiconv-1.14.tar.gz?
? ? ? tar xvzf libiconv-1.14.tar.gz?
? ? ? cd libiconv-1.14
? ? ? ?./configure --prefix=/usr/local && make && make install
? 2、解压libmcrypt-2.5.7.tar.gz
tar xvzf libmcrypt-2.5.7.tar.gz
cd libmcrypt-2.5.7
? ? ? ? ./configure && make && make install
? ? ? ?/sbin/ldconfig
? ? ? ?cd libltdl/
? ? ? ?./configure --enable-ltdl-install
make && make install
? 3、解压mhash-0.9.9.9.tar.bz2
tar xvjf mhash-0.9.9.9.tar.bz2
? ? ?cd mhash-0.9.9.9
? ? ?./configure && make && make install
? ? 创建以下快捷连接
? ? ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
? ? ln -s /usr/local/lib/libmcrypt.so.4.4.7 /usr/lib/libmcrypt.so.4.4.7
? ? ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
? ? ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
? ? ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
? ? ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
? ? ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
? ? ?/sbin/ldconfig
?4、解压mcrypt-2.6.8.tar.gz
? ? tar xvzf mcrypt-2.6.8.tar.gz
? ? cd mcrypt-2.6.8
? ? ?./configure && make && make install
5、安装数据库(通过yum来安装)
yum install postgresql-server postgresql postgresql-devel postgresql-libs
6、安装如下包
? ?yum install libjpeg libpng libjpeg-devel libpng-devel
yum install libxml2-devel openssl-devel libcurl-devel freetype freetype-devel openldap-devel
? ?cp -frp /usr/lib64/libldap* /usr/lib/
7、 ? 安装php-5.4.8
? ?./configure --prefix=/usr/local/php-5.4.8/ --with-config-file-path=/usr/local/php-5.4.8/etc --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm ?--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear
? ?make ZEND_EXTRA_LIBS='-liconv'
? make install
#创建php.ini
? cp php.ini-production /usr/local/php-5.4.8/etc/php.ini
#测试php ?
?curl http://pear.php.net/go-pear |/usr/local/php-5.4.8/bin/php
执行/usr/local/php-5.4.8/bin/phpize,出现如下错误?
Cannot find config.m4.
[root@AY1211191025228124935 memcached-1.4.15]# /usr/local/php-5.4.8/bin/phpize?
Cannot find config.m4.?
Make sure that you run '/usr/local/php-5.4.8/bin/phpize' in the top level source directory of the module
?
?
在/usr/local/src/soft/php-5.4.8/ext下找到这个工具
?
来建立一个php扩展的一个框架
?
[root@AY1211191025228124935 src]]#cd /usr/local/src/soft/php-5.4.8/ext
?
[root@AY1211191025228124935 ext]# ./ext_skel --extname=sdomain
Creating directory sdomain
Creating basic files: config.m4 config.w32 .svnignore sdomain.c php_sdomain.h CREDITS EXPERIMENTAL tests/001.phpt sdomain.php [done].
?
To use your new extension, you will have to execute the following steps:
?
1. ?$ cd ..
2. ?$ vi ext/sdomain/config.m4
3. ?$ ./buildconf
4. ?$ ./configure --[with|enable]-sdomain
5. ?$ make
6. ?$ ./php -f ext/sdomain/sdomain.php
7. ?$ vi ext/sdomain/sdomain.c
8. ?$ make
?
Repeat steps 3-6 until you are satisfied with ext/sdomain/config.m4 and
step 6 confirms that your module is compiled into PHP. Then, start writing
code and repeat the last two steps as often as necessary.
[root@AY1211191025228124935 ext]# cd sdomain/
?
[root@AY1211191025228124935 sdomain]# ls
?
config.m4 ? CREDITS ? ? ? php_sdomain.h ?sdomain.php
config.w32 ?EXPERIMENTAL ?sdomain.c ? ? ?tests
?
然后我们要修改文件顺序是
?
configue.m4
?
sdomain.c
?
php_sdomain.h
使用文本编辑器打开config.m4文件,修改文件内容:
?
dnl PHP_ARG_WITH(my_module, for my_module support,
?
dnl Make sure that the comment is aligned:
?
dnl [ --with-my_module Include my_module support])
?
修改成
?
PHP_ARG_WITH(my_module, for my_module support,
?
[ --with-my_module Include my_module support])
?
或者将
?
? ? ? ? (其实就是将这部分的dnl去掉,在这个文件里dnl就是注释的意思,相当于我们PHP里面的#或// 另外把他中间的一句描术也去掉)
?
然后保存退出
?
然后在编辑
?
Vi sdomain.c
?
将文件其中的下列代码进行修改
?
/* Every user visible function must have an entry in my_module_functions[].
*/
function_entry my_module_functions[] = {
PHP_FE(say_hello, NULL) /* ?添加着一行代码 */
PHP_FE(confirm_my_module_compiled, NULL) /* For testing, remove later. */
{NULL, NULL, NULL} /* Must be the last line in my_module_functions[] */
};
?
在文件的最后添加下列代码
?
PHP_FUNCTION(say_hello)
{
zend_printf("hello sdomain!");
}
?
?
?
再修改:php_sdomain.h
?
vi php_sdomain.h
?
在PHP_FUNCTION(confirm_my_module_compiled); /* For testing, remove later. */ 这行的下面添加一行:
?
PHP_FUNCTION(say_hello); /* For testing, remove later. */
?
保存文件退出
?
然后我们就可以在这个目录下使用上面的命令了
?
/usr/local/php-5.4.8/bin/phpize?
?
8、解压memcached-1.4.15.tar.gz
tar xvzf memcached-1.4.15.tar.gz
cd memcached-1.4.15
./configure --with-php-config=/usr/local/php-5.4.8/bin/php-config
checking for libevent directory... configure: error: libevent is required. ?You can get it from http://www.monkey.org/~provos/libevent/
执行:yum install libevent-devel libevent
? 再次执行
./configure --with-php-config=/usr/local/php-5.4.8/bin/php-config&& make && make install
?
9、解压cd eaccelerator-eaccelerator-42067ac.tar.gz
tar xvzf eaccelerator-eaccelerator-42067ac.tar.gz
? ?cd eaccelerator-eaccelerator-42067ac
/usr/local/php-5.4.8/bin/phpize
? ? ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/php-5.4.8/bin/php-config?
? ? ?make && make install
?
10、解压ImageMagick-6.8.0-4.tar.bz2
tar xvjf ImageMagick-6.8.0-4.tar.bz2
? ? ?cd ImageMagick-6.8.0-4
? ? ? ./configure && make && make install
11、解压imagick-3.0.1.tgz
? ? ? yum install ImageMagick-devel
? ? ? tar xvzf imagick-3.0.1.tgz
? ? ? cd imagick-3.0.1
? ? ? ?/usr/local/php-5.4.8/bin/phpize?
? ? ? ?./configure --with-php-config=/usr/local/php-5.4.8/bin/php-config?
? ? ? ?make && make install
?
12、将在/usr/local/php-5.4.8/etc/php.ini中的extension_dir="./"修改为extension_dir = “extension_dir=/usr/local/php-5.4.8/lib/php/extensions/no-debug-non-zts-20100525"
? ? ?将在此后加入
? ? ?extension = "memcache.so"
? ? ?extension = "imagick.so"
? ? ? 配置eAccelerator加速PHP
? ? ?mkdir /usr/local/eaccelerator_cache
? ? 编辑 vim /usr/local/php-5.4.8/etc/php.ini?
在最后输入如下内容:
[eaccelerator]
zend_extension="/usr/local/php-5.4.8/lib/php/extensions/no-debug-non-zts-20100525"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
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"
?
13、vi /etc/profile
? ? ? 在最后增加如下:
export PATH=$PATH:/usr/local/php-5.4.8/bin/:/usr/local/php-5.4.8/sbin
保存退出,并输入source /etc/profile
?
14、解压并编译nginx-1.3.8.tar.gz
? ? ? tar xvzf nginx-1.3.8.tar.gz
? ? ? ?cd nginx-1.3.8
? ? ? ?yum install pcre-devel
? ? ?./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module?
? ? ? make && make install
安装nginx完成
vim /etc/rc.local,加入如下内容:
ulimit -SHn 65535
/usr/local/php-5.4.8/sbin/php-fpm
/usr/local/nginx/sbin/nginx
?
?
vi /etc/profile
? ? ? 在最后增加如下:
export PATH=$PATH:/usr/local/php-5.4.8/bin/:/usr/local/php-5.4.8/sbin:/usr/local/nginx/sbin/nginx
? ? ? ?最后保存退出后执行source /etc/profile
?
?
15、优化内核参数
vi /etc/sysctl.conf
? ?在此文件的最后加入如下内容
net.ipv4.neigh.default.gc_stale_time=120
net.ipv4.tcp_max_syn_backlog = 65536
net.core.netdev_max_backlog = 32768
net.core.somaxconn = 32768
net.core.wmem_default = 8388608
net.core.rmem_default = 8388608
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_timestamps = 0
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse =1
net.ipv4.tcp_mem =9450000 915000000 927000000
net.ipv4.tcp_max_orphans = 3276800
net.ipv4.ip_local_port_range = 1024 65535
保存并退出,执行sysctl -p,使之生效