lnmp配置情况

回复 收藏


第一步,配置php-fpm.conf
[root@lnmp-109 etc]# > /usr/local/php/etc/php-fpm.conf
清空配置文件
[root@lnmp-109 etc]# vi /usr/local/php/etc/php-fpm.conf
复制配置文件
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
[www]
listen = /tmp/xin.sock
user = php-fpm
group = php-fpm
listen.owner = nobody
listen.group = nobody
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024

[root@lnmp-109 etc]# /usr/local/php/sbin/php-fpm -t
测试脚本
[13-Apr-2016 01:36:52] NOTICE: configuration file /usr/local/php/etc/php-fpm.conf test is successful
[root@lnmp-109 etc]# /etc/init.d/php-fpm restart
启动服务
[root@lnmp-109 etc]# ps aux |grep php-fpm
检测进程
root      1305  0.0  0.5  29684  3132 ?        Ss   Apr12   0:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
php-fpm   1306  0.0  0.4  29684  2640 ?        S    Apr12   0:00 php-fpm: pool www                  
php-fpm   1307  0.0  0.4  29684  2644 ?        S    Apr12   0:00 php-fpm: pool www                  
php-fpm   1308  0.0  0.4  29684  2644 ?        S    Apr12   0:00 php-fpm: pool www                  
[root@lnmp-109 etc]# ll /tmp/xin.sock
srw-rw----. 1 nobody nobody 0 4月  13 01:39 /tmp/xin.sock
[root@lnmp-109 etc]# ps aux |grep nginx
root      1297  0.0  0.1   5300   660 ?        Ss   Apr12   0:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody    1302  0.0  0.3   6552  2160 ?        S    Apr12   0:01 nginx: worker process               
nobody    1303  0.0  0.3   6552  2336 ?        S    Apr12   0:00 nginx: worker process               
root      1887  0.0  0.1   5984   768 pts/1    S+   01:44   0:00 grep nginx

第二步配置nginx.conf
[root@lnmp ~]# vim /usr/local/nginx/conf/nginx.conf
user nobody nobody;
worker_processes 2;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile 51200;

events
{
    use epoll;
    worker_connections 6000;
}

http
{
    include mime.types;
    default_type application/octet-stream;
    server_names_hash_bucket_size 3526;
    server_names_hash_max_size 4096;
    log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
    '$host "$request_uri" $status'
    '"$http_referer" "$http_user_agent"';
    sendfile on;
    tcp_nopush on;
    keepalive_timeout 30;
    client_header_timeout 3m;
    client_body_timeout 3m;
    send_timeout 3m;
    connection_pool_size 256;
    client_header_buffer_size 1k;
    large_client_header_buffers 8 4k;
    request_pool_size 4k;
    output_buffers 4 32k;
    postpone_output 1460;
    client_max_body_size 10m;
    client_body_buffer_size 256k;
    client_body_temp_path /usr/local/nginx/client_body_temp;
    proxy_temp_path /usr/local/nginx/proxy_temp;
    fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
    fastcgi_intercept_errors on;
    tcp_nodelay on;
    gzip on;
    gzip_min_length 1k;
    gzip_buffers 4 8k;
    gzip_comp_level 5;
    gzip_http_version 1.1;
    gzip_types text/plain application/x-javascript text/css text/htm application/xml;
   include vhosts/*.conf;
}
第三步,配置vhosts
[root@lnmp-109 ~]# vi /usr/local/nginx/conf/vhosts/defaule.conf
server
{
    listen 80  default_server;
    server_name localhost;
    index index.html index.htm index.php;
    root /tmp/xin;
    deny all;
}
[root@lnmp-109 ~]# vi /usr/local/nginx/conf/vhosts/xin.conf
server
{
    listen 80;
    server_name www.xin.com;
    index index.html index.htm index.php;
    root /data/www;

    location ~ \.php$ {
        include fastcgi_params;
        fastcgi_pass unix:/tmp/xin.sock;
       # fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
    }

}

[root@lnmp-109 ~]# /usr/local/nginx/sbin/nginx -t
检测脚本
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
[root@lnmp-109 ~]# /usr/local/nginx/sbin/nginx -s reload
加载配置文件
[root@lnmp vhosts]# service nginx configtest
重新载入 Nginx:                                           [确定]
2016-08-21 14:29 举报
已邀请:

回复帖子,请先登录注册

退出全屏模式 全屏模式 回复
评分
可选评分理由: