Chinaunix首页 | 论坛 | 博客
  • 博客访问: 585648
  • 博文数量: 151
  • 博客积分: 3330
  • 博客等级: 中校
  • 技术积分: 1686
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-08 02:41
文章存档

2011年(151)

分类: LINUX

2011-04-19 00:19:46

系统平台:RHEL6.0

软件版本:

libevent-1.4.13-1.i386.rpm

libevent-devel-1.4.13-1.i386.rpm

libiconv-1.9.2.tar.gz

libmcrypt-2.5.8.tar.gz

mcrypt-2.6.8.tar.gz

mhash-0.9.9.9.tar.bz2

mysql-community-5.1.56-1.rhel5.src.rpm

php-5.3.6.tar.bz2

nginx-1.0.0.tar.gz

imagemagick-6.6.9-5.tar.bz2

imagick-3.0.1.tar.gz

memcache-2.2.6.tar.gz

eaccelerator-0.9.6.1.tar.bz2

icu-4.2.1-7.el6.i686.rpm

icu-4.2.1-9.el6.i686.rpm

安装配置

1.install libiconv-1.9.2.tar.gz

tar -xzvf libiconv-1.9.2.tar.gz

cd libiconv

./configure --prefix=/usr/local

make && make install

2.install libmcrypt-2.5.8.tar.gz

tar -zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt

./configure

make && make install

cd libltdl/

./configure --enable-ltdl-install

make && make install

3.install mhash-0.9.9.9.tar.bz2

tar -xjvf mhash-0.9.9.9.tar.bz2

cd mhash

./configure

make && make install

4.将加密函数库链接到系统标准目录下

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.8 /usr/lib/libmcrypt.so.4.4.8
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

5. install mcrypt-2.6.8.tar.gz

tar -xzvf mcrypt-2.6.8.tar.gz

cd mcrypt

./configure

make && make install

6.  install mysql

rpm -ivh Mysql-community-5.1.56-src.rpm

cd rpmbuild

cd SOURCE

tar -xzvf mysq-5.1.56.tar.gz

cd mysql

groupadd mysql

useradd -g mysql -s /sbin/nologin -d /dev/null mysql

./configure --prefix=/usr/local/mysql
--localstatedir=/usr/local/mysql/data
--sysconfdir=/etc
--with-unix-socket-path=/usr/local/mysql/tmp/mysql.socket
--enable-assembler

--with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static

--with-pthread

--with-charset=utf8 

--with-extra-charsets=complex 

--enable-thread-safe-client
--with-big-tables
--with-readline
--with-ssl
--enable-local-infile
--with-plugins=all
--with-mysqld-user=mysql
--with-zlib-dir=/usr 
--enable-largefile
--without-debug
--without-comment
--with-mysqlmanager

make && make install

cp support/my-medium.cnf /etc/my.cnf

/usr/local/mysql/bin/mysql_install_db 初始化数据库文件和data目录

cd /usr/local/mysql

mkdir tmp   mysql的socket文件存放目录

chown -R root.mysql . 

chown  -R  mysql.mysql data 改变数据库的我数据目录权限

chown -R mysql.mysql tmp  改变socket目录权限

bin/mysqld_safe --user=mysql &  以mysql身份在后台启动mysql

bin/mysqladmin -u root -password 'password'  修改mysql 的root 帐号 密码

 7.添加mysql 到系统服务

 进入到mysql的源代码目录

cp support/mysql.server /etc/init.d/mysql

chmod +x /etc/init.d/mysql

chkconfig --add mysql

chkconfig mysql on

8.install php-5.3.6.tar.bz2

tar -xjvf php-5.3.6.tar.bz2

groupadd fpm

useradd -g fpm -s /sbin/nologin -d /dev/null fpm

./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-mysql-sock=/usr/local/mysql/tmp/mysql.socket --enable-ftp --with-zlib-dir --with-bz2 --enable-zip --with-iconv-dir=/usr/local/ --with-freetype-dir --with-jpeg-dir --with-png-dir --with-gd --enable-gd-native-ttf --with-gettext --enable-bcmath --enable-exif --enable-calendar --enable-intl --with-mhash --with-mcrypt=/usr/lib --enable-fpm --enable-xml --with-xsl --enable-xmlwriter --with-libxml-dir=/usr/ --disable-rpath --enable-safe-mode --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-zend-multibyte --with-curl --with-curlwrappers --enable-mbregex --enable-mbstring --with-pcre-regex --with-openssl --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-pear --enable-soap --enable-pdo --enable-phar --with-xmlrpc --with-fpm-user=fpm --with-fpm-group=fpm

make  ZEND_EXTRA_LIBS='-liconv' (不加后面的参数会报错)

make install

cp php.ini-prodution /usr/local/php/etc/php.ini  (PHP配置文件)

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm (拷贝php-fpm系统启动目录随机启动)

/sbin/chkconfig --add php-fpm (添加到开机服务列表)
/sbin/chkconfig php-fpm on

 

安装PHP扩展库

9. install memcache-2.2.6.tar.gz

tar -xzvf memcache-2.2.6.tar.gz

cd memcache

/usr/local/php/bin/phpize (先执行此添加扩展库文件的命令)

./configure --enable-memcache --with-php-config=/usr/local/php/bin/php-config  

                    --with-zlib-dir

make && make install

10. install imagemagick-6.6.9-5.tar.gz

tar -xzvf imagemagick-6.6.9-5.tar.gz

cd imagemagick

./configure --preix=/usr/local/imagemagick

make && make install

11.install imagick-3.0.1.tar.gz

tar -xzvf imagick-3.0.1.tar.gz

cd imagick

./configure --with-php-config=/usr/local/php/bin/php-config --with-imagick=/usr/local/imagemagick/
make && make install

12. install eaccelerator-0.9.6.1.tar.fz

tar -xzvf eaccelerator-0.9.6.1.tar.gz

cd eaccelerator

 ./configure --enable-eaccelerator --with-php-config=/usr/local/php/bin/php-config
make && make install

13. 修改php.ini ,添加扩展库文件的目录及扩展库

vim /usr/local/php/etc/php.ini    找到“   ; extension_dir = "./"  ”  这一行,在此行下面添加:

extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/"
extension = "memcache.so"
extension = "imagick.so"

然后保存退出

14. 配置eaccelerator 加速PHP

mkdir -p /usr/local/php/eaccelerator_cache_dir 建立加速缓存目录

chmod 777 /usr/local/php/eaccelerator_cache_dir

vi /usr/local/php/etc/php.ini  在文件末尾添加如下

[eaccelerator]
zend_extension = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size = "16"
eaccelerator.cache_dir = "/usr/local/php/eaccelerator_cache_dir"
eaccelerator.enable = "1"
eaccelerator.optimizer = "1"
eaccelerator.check_mtime = "1"
eaccelerator.debug = "0"
eaccelerator.filter = ""
eaccelerator.shm_max = "0"
eaccelerator.shm_ttl = "0"
eaccelerator.shm_prune_period = "0"
eaccelerator.shm_only = "0"
eaccelerator.compress = "1"
eaccelerator.compress_level = "9"

保存退出

以上参数只修改了缓存和扩展库的的路径,其他相关参数可自行参考修改

15. 测试 eaccelerator 是否成功

php -v  执行此命令,显示如下,即表示成功

PHP 5.3.6 (cli) (built: Apr 18 2011 22:50:21)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
    with eAccelerator v0.9.6.1, Copyright (c) 2004-2010 eAccelerator, by eAccelerator

16.php-fpm配置  php的安装路径为/usr/local/php,已下配置文件路径都是以此路径为根路径,

  1. [global]
  2. pid = run/php-fpm.pid

  3. error_log = log/php-fpm.log

  4. log_level = notice

  5. emergency_restart_threshold = 10

  6. emergency_restart_interval = 1m

  7. process_control_timeout = 5s

  8. daemonize = yes



  9. [fpmpool] /*自定义的pool*/

  10. prefix = /usr/local/php

  11. listen = 127.0.0.1:9000

  12. listen.backlog = -1
  13.  
  14. listen.allowed_clients = 127.0.0.1


  15. user = nginx  /*php-fpm运行的用户和组*/
  16. group = nginx

  17. pm = dynamic

  18. pm.max_children = 50

  19. pm.start_servers = 20

  20. pm.min_spare_servers = 5

  21. pm.max_spare_servers = 35
  22.  
  23. pm.max_requests = 500

  24.  

  25.  
  26. request_terminate_timeout = 0s
  27.  
  28. request_slowlog_timeout = 0s
  29.  
  30. slowlog = log/$pool.log.slow
  31.  
  32. rlimit_files = 512000
  33.  
  34. rlimit_core = 0
  35.  
  36.  
  37.  
  38. catch_workers_output = yes
  39.  
  40. env[HOSTNAME] = $HOSTNAME
  41. env[PATH] = /usr/local/bin:/usr/bin:/bin
  42. env[TMP] = /tmp
  43. env[TMPDIR] = /tmp
  44. env[TEMP] = /tmp




  45. php_flag[display_errors] = on
  46. php_admin_value[error_log] = /var/log/fpm-php.
  47. php_admin_flag[log_errors] = on
  48. php_admin_value[memory_limit] = 32M

17. php-fpm  启动命令

 /usr/local/php/sbin/php-fpm (start|stop|reload)等命令,需要使用信号控制:
master进程可以理解以下信号:
SIGINT, SIGTERM 立刻终止
SIGQUIT 平滑终止
SIGUSR1 重新打开日志文件
SIGUSR2 平滑重载所有worker进程并重新载入配置和二进制模块

php-fpm 关闭:
kill -SIGINT `cat /usr/local/php/var/run/php-fpm.pid`
php-fpm 重启:
kill -SIGUSR2 `cat /usr/local/php/var/run/php-fpm.pid`


18.install nginx 1.0.0.tar.gz

tar -xzvf nginx-1.0.0.tar.gz

groupadd nginx

useradd -g nginx -s /sbin/nologin -d /dev/null nginx

cd nginx

./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module --with-http_xslt_module --with-http_gzip_static_module --without-http_uwsgi_module --with-http_ssl_module --with-pcre --with-http_perl_module

/*本来想用自己安装perl 和 pcre模块,可是装上了后,一直configure 不过去,可能还是路径问题,只好用了RHEL6.0自带的Perl 和pcre*/

make && make install

19.配置Nginx

  1. user nginx;
  2. worker_processes 1;

  3. error_log logs/error.log;
  4. #error_log logs/error.log notice;
  5. #error_log logs/error.log info;

  6. pid logs/nginx.pid;

  7. worker_rlimit_nofile 65535;
  8. events {
  9.     use epoll;
  10.     worker_connections 65535;
  11. }


  12. http {
  13.     include mime.types;
  14.     default_type application/octet-stream;

  15.     log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  16.                       '$status $body_bytes_sent "$http_referer" '
  17.                       '"$http_user_agent" "$http_x_forwarded_for"';

  18.     access_log logs/access.log main buffer=32k;
  19.     server_names_hash_bucket_size 128;
  20.     client_header_buffer_size 32k;
  21.     large_client_header_buffers 4 32k;
  22.     client_max_body_size 8m;
  23.     sendfile on;
  24.     tcp_nopush on;
  25.     tcp_nodelay on;
  26.     keepalive_timeout 65;

  27.     gzip on;
  28.     gzip_min_length 1k;
  29.     gzip_buffers 4 16k;
  30.     gzip_http_version 1.0;
  31.     gzip_comp_level 2;
  32.     gzip_types text/plain application/x-javascript text/css application/xml;
  33.     gzip_vary on;
  34.     
  35.     fastcgi_connect_timeout 300;
  36.     fastcgi_send_timeout 300;
  37.     fastcgi_read_timeout 300;
  38.     fastcgi_buffer_size 64k;
  39.     fastcgi_buffers 4 64k;
  40.     fastcgi_busy_buffers_size 128k;
  41.     fastcgi_temp_file_write_size 128k;

  42.     server {
  43.         listen 80;
  44.         server_name localhost;

  45.         #charset koi8-r;

  46.         #access_log logs/host.access.log main;

  47.         location / {
  48.             root html;
  49.             index index.html index.htm index.php;
  50.         }

  51.         #error_page 404 /404.html;

  52.         # redirect server error pages to the static page /50x.html
  53.         #
  54.         error_page 500 502 503 504 /50x.html;
  55.         location = /50x.html {
  56.             root html;
  57.         }

  58.         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  59.         #
  60.         #location ~ .*\.(php|php5)?$ {
  61.         # proxy_pass
  62.         #}

  63.         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  64.         #
  65.         location ~* \.(php|php5)$ {
  66.             root html;
  67.             fastcgi_pass 127.0.0.1:9000;
  68.             fastcgi_index index.php;
  69.             fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  70.             include /usr/local/nginx/conf/fastcgi.conf;
  71.         }

  72.         # deny access to .htaccess files, if Apache's document root
  73.         # concurs with nginx's one
  74.         #
  75.         #location ~ /\.ht {
  76.         # deny all;
  77.         #}
  78.     }


  79.     # another virtual host using mix of IP-, name-, and port-based configuration
  80.     #
  81.     #server {
  82.     # listen 8000;
  83.     # listen somename:8080;
  84.     # server_name somename alias another.alias;

  85.     # location / {
  86.     # root html;
  87.     # index index.html index.htm;
  88.     # }
  89.     #}


  90.     # HTTPS server
  91.     #
  92.     #server {
  93.     # listen 443;
  94.     # server_name localhost;

  95.     # ssl on;
  96.     # ssl_certificate cert.pem;
  97.     # ssl_certificate_key cert.key;

  98.     # ssl_session_timeout 5m;

  99.     # ssl_protocols SSLv2 SSLv3 TLSv1;
  100.     # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
  101.     # ssl_prefer_server_ciphers on;

  102.     # location / {
  103.     # root html;
  104.     # index index.html index.htm;
  105.     # }
  106.     #}

  107. }

20.启动Nginx

cd /usr/local/nginx/sbin

./nginx  (不用带参数即可启动)

浏览器访问    出现如下图,nginx 安装成功



21. 查看PHP extension 库文件命令

php -m

22.查看PHP.INI配置文件

php -i /usr/local/php/etc/php.ini

23.测试php 的fastcgi 是否运行正常

从网上下载一个php probe:test.php文件 放入/usr/local/nginx/html (网站根目录下)

访问:  我截图如下

 

 




 测试php 于 mysql 的连接


 

 

 

 

 

 

 


 

 

 

 

 

 

 

 

 

阅读(3042) | 评论(3) | 转发(0) |
给主人留下些什么吧!~~

htckiller20102011-04-19 16:58:28

小雅贝贝: 加油啊,要坚持写博客啊,这篇文章上首页了哦~~.....
你有没有认识的高手,PHP LINUX NGINX MYSQL,高手,我遇到点问题

htckiller20102011-04-19 12:05:01

小雅贝贝: 加油啊,要坚持写博客啊,这篇文章上首页了哦~~.....
呵呵,谢谢啊,我一直在努力

小雅贝贝2011-04-19 09:45:53

加油啊,要坚持写博客啊,这篇文章上首页了哦~~