技术头条 - 一个快速在微博传播文章的方式     搜索本站
您现在的位置首页 --> 系统运维 --> Centos yum 安装nginx+PHP-FPM+eAccelerator+mysql

Centos yum 安装nginx+PHP-FPM+eAccelerator+mysql

浏览:5454次  出处信息

    记录下我在linodeVPS 的Centos下安装配置nginx+PHP-FPM+eAccelerator+mysql的过程。

    添加安装源

     Centos 默认官方源中没有nginx 和 php-fpm 所以必须添加第三方源,不然就只能自己编译了。

    

     添加[CentALT]源

     在/etc/yum.repo.d 目下创建 alt.ru.repo 文件内容如下:

[CentALT]
name=CentALT Packages for Enterprise Linux 5 - $basearch
baseurl=http://centos.alt.ru/repository/centos/5/$basearch/
enabled=1
gpgcheck=0

    启用 EPEL

rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

    32系统的用下面命令

rpm -Uvhhttp://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

    安装 nginx +PHP-FPM +eAccelerator +mysql

yum update
 yum install nginx php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd 
php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator

    配置优化Nginx

     修改 /etc/nginx/nginx.conf,下面只列出修改的部分。

#根据CPU 核心processes,VPS下几个核心几个processes,独立服务器可x2
worker_processes  4;
 
#启用epoll
worker_rlimit_nofile 51200;
events {
    worker_connections  51200;
    use epoll;
}
#参数调整
    sendfile        on;
    tcp_nopush      on;
    tcp_nodelay     on;
    server_tokens   off;
    keepalive_timeout  50;
    server_names_hash_bucket_size 128;
    client_header_buffer_size 32k;
    large_client_header_buffers 4 32k;
    client_max_body_size 50m;
#fastcgi优化
    fastcgi_connect_timeout 300;
    fastcgi_send_timeout 300;
    fastcgi_read_timeout 300;
    fastcgi_buffer_size 64k;
    fastcgi_buffers 4 64k;
    fastcgi_busy_buffers_size 128k;
    fastcgi_temp_file_write_size 256k;
 
#开启gzip并优化
    gzip on;
    gzip_min_length  1k;
    gzip_buffers     4 16k;
    gzip_http_version 1.0;
    gzip_comp_level 2;
    gzip_types       text/plain application/x-javascript text/css application/xml;
    gzip_vary on;

    php-fpm 调整

     修改/etc/php-fpm.conf 将max_children 调为20

20

    mysql 调整

     修改/etc/my.conf [mysqld] 段加入如下指令

skip-network
skip-innodb
skip-locking
skip-bdb
 
key_buffer              = 16K
max_allowed_packet      = 3M
thread_stack            = 64K
thread_cache_size       = 8
table_cache             = 3
query_cache_limit       = 1M
query_cache_size        = 16M

    系统内核调整

     在/etc/sysctl.conf 加入

net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.ip_local_port_range = 5000    65000
net.ipv4.tcp_max_tw_buckets = 6000
echo “ulimit -SHn 65535” >> /etc/rc.local
styctl -p

    开启服务并设置系统启动默认启动

ulimit -SHn 65535
/etc/init.d/nginx  start
/etc/init.d/php-fpm start
/etc/init.d/mysqld start
chkconfig nginx on
chkconfig php-fpm on
chkconfig mysqld on

建议继续学习:

  1. 配置Nginx+uwsgi更方便地部署python应用    (阅读:105184)
  2. Linux 下 PHP 5.2.x 连接 SQL Server 数据库 FreeTDS 配置笔记    (阅读:9970)
  3. nginx的配置文件    (阅读:8577)
  4. Emacs安装配置    (阅读:7204)
  5. 如何查看Linux 硬件配置信息    (阅读:5689)
  6. Apache2中俩种设置PHP的异同    (阅读:5093)
  7. Linux(Ubuntu 10.04)上安装配置apache+php+mysql+phpmyadmin    (阅读:4850)
  8. 在FreeNAS/BSD搭建基于Nginx+FastCGI+MySQL+PHP的WebServer    (阅读:4594)
  9. 在Mac OS X中运行Apache + PHP + MySQL    (阅读:4224)
  10. apache+mod_wsgi+django在windows下的部署    (阅读:3925)
QQ技术交流群:445447336,欢迎加入!
扫一扫订阅我的微信号:IT技术博客大学习
© 2009 - 2024 by blogread.cn 微博:@IT技术博客大学习

京ICP备15002552号-1