基于gentoo 安装Nginx php mysql

来源:未知 责任编辑:智问网络 发表时间:2013-10-30 11:05 点击:

作者:coralzd             博客www.freebsdsystem.org                 转载注明出处

新买的VPS。在上面部署了nginx mysql php。
1、先在/etc/make.conf加入sync站点,待会儿要用emerge进行同步。
 

  1. SYNC="rsync://rsync.gentoo.org/gentoo-portage"  


在执行 emerge --sync 同步portage树。
2、升级portage 版本,要不待会儿安装mysql的时候会提示portage 版本旧的!
 

  1. emerge portage 


先定义USE:
 

  1. /etc/portage/package.use  
  2. dev-lang/php cli ming xml ftp curl pdo mysqli mysql sqlite json cgi ctype gd hash  
  3. www-servers/nginx fastcgi  
  4. 编辑/etc/portage/package.keywords  
  5. www-servers/spawn-fcgi ~x86 

3、安装 mysql nginx php spawn-fcgi pecl-apc pecl-memcache。

  1. emerge mysql nginx php spawn-fcgi pecl-apc pecl-memcache 


4、配置mysql。

 

  1. mkdir -p /data0/mysql/data  
  2. mysql_install_db --user=mysql --basedir=/usr --datadir=/data0/mysql/data  
  1. rm -f /etc/mysql/my.cnf  
  2. vim /etc/mysql/my.cnf  
  3. [client]  
  4. port    = 3306  
  5. socket  = /var/run/mysqld/mysqld.sock  
  6. [mysql]  
  7. prompt="(\u:s135[\d]> " 
  8. no-auto-rehash  
  9. [mysqld]  
  10. bind-address     = 173.252.207.109  
  11. user    = mysql  
  12. port    = 3306  
  13. socket  = /var/run/mysqld/mysqld.sock  
  14. basedir = /usr  
  15. datadir = /data0/mysql/data  
  16. open_files_limit    = 600  
  17. back_log = 20  
  18. max_connections = 100  
  19. max_connect_errors = 200  
  20. table_cache = 60  
  21. external-locking = FALSE  
  22. max_allowed_packet = 16M  
  23. sort_buffer_size = 128K  
  24. join_buffer_size = 128K  
  25. thread_cache_size = 10  
  26. thread_concurrency = 8  
  27. query_cache_size = 0M  
  28. query_cache_limit = 2M  
  29. query_cache_min_res_unit = 2k  
  30. default_table_type = MyISAM  
  31. thread_stack = 192K  
  32. transaction_isolation = READ-UNCOMMITTED  
  33. tmp_table_size = 512K  
  34. max_heap_table_size = 32M  
  35. /var/log/slow.log  
  36. /var/log/error.log  
  37. long_query_time = 1  
  38. log_long_format  
  39. server-id = 1  
  40. #log-bin = /usr/local/mysql/data/binlog  
  41. binlog_cache_size = 2M  
  42. max_binlog_cache_size = 4M  
  43. max_binlog_size = 512M  
  44. expire_logs_days = 7  
  45. key_buffer_size = 4M  
  46. read_buffer_size = 1M  
  47. read_rnd_buffer_size = 2M  
  48. bulk_insert_buffer_size = 2M  
  49. myisam_sort_buffer_size = 4M  
  50. myisam_max_sort_file_size = 10G  
  51. myisam_max_extra_sort_file_size = 10G  
  52. myisam_repair_threads = 1  
  53. myisam_recover  
  54. [mysqldump]  
  55. quick  
  56. max_allowed_packet = 16M 


 

启动mysql

  1. /etc/init.d/mysql start 

 

5、配置nginx


 

  1. user  nginx nginx;  
  2.  
  3. worker_processes 1;  
  4. error_log  /var/log/nginx/nginx_error.log  crit;  
  5.  
  6. pid        /var/run/nginx.pid;  
  7.  
  8. #Specifies the value for maximum file descriptors that can be opened by this process.  
  9. worker_rlimit_nofile 52100;  
  10.  
  11. events  
  12. {  
  13.   use epoll;  
  14.   worker_connections 52100;  
  15. }  
  16.  
  17. http  
  18. {  
  19.   include       mime.types;  
  20.   default_type  application/octet-stream;  
  21.  
  22.   #charset  gb2312;  
  23.  
  24.   server_names_hash_bucket_size 128;  
  25.   client_header_buffer_size 32k;  
  26.   large_client_header_buffers 4 32k;  
  27.   client_max_body_size 8m;  
  28.  
  29.   sendfile on;  
  30.   tcp_nopush     on;  
  31.  
  32.   keepalive_timeout 70 20;  
  33.  
  34.   tcp_nodelay on;  
  35.   server_tokens off;  
  36.   fastcgi_connect_timeout 300;  
  37.   fastcgi_send_timeout 300;  
  38.   fastcgi_read_timeout 300;  
  39.   fastcgi_buffer_size 64k;  
  40.   fastcgi_buffers 4 64k;  
  41.   fastcgi_busy_buffers_size 128k;  
  42.   fastcgi_temp_file_write_size 128k;  
  43.  
  44.   gzip off;  
  45.   gzip_min_length  1k;  
  46.   gzip_buffers     4 16k;  
  47.   gzip_http_version 1.0;  
  48.   gzip_comp_level 2;  
  49.   gzip_types       text/plain application/x-javascript text/css application/xml;  
  50.   gzip_vary on;  
  51.     
  52.   server  
  53.    {  
  54.       server_name www.freebsdsystem.org;  
  55.      root /data0/www/wwwroot/;  
  56.      index index.html index.htm index.php;  
  57.     location ~ .*\.php?$  
  58.     {  
  59.       #fastcgi_pass  unix:/tmp/php-cgi.sock;  
  60.       fastcgi_pass  127.0.0.1:9000;  
  61.       fastcgi_index index.php;  
  62.       include fcgi.conf;  
  63.     }  
  64. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$  
  65.     {  
  66.       expires      30d;  
  67.     }  
  68.  
  69.     location ~ .*\.(js|css)?$  
  70.     {  
  71.       expires      1h;  
  72.     }  
  73.  
  74.     log_format  blog  '$remote_addr - $remote_user [$time_local] "$request" ' 
  75.               '$status $body_bytes_sent "$http_referer" ' 
  76.               '"$http_user_agent" $http_x_forwarded_for';  
  77.     access_log  /var/log/nginx/blog.log  blog;  
  78.       }  
  79.  
  80.  
  81.  


 

vim /usr/local/bin/php-fcgi

  1. #!/bin/sh  
  2. # author:coralzd  
  3. # powered by www.freebsdsystem.org  
  4.  
  5. bin=/usr/bin/php-cgi  
  6. case $1 in  
  7.  
  8. start)  
  9.       echo "starting php-cgi" 
  10.        spawn-fcgi -a 127.0.0.1 -p 9000 -C 8 -u nginx -g nginx -f /usr/bin/php-cgi 2>&1 >/dev/null  &  
  11.         echo "Done" 
  12. ;;  
  13. stop)  
  14.  
  15.  
  16.    killall php-cgi  
  17.    echo "php-cgi stop" 
  18. ;;  
  19.  
  20. *)  
  21.  
  22. echo "usage start|stop";;  
  23.  
  24. esac 

 

6、开机启动 nginx mysql


 



rc-update add nginx default
rc-update add mysql default
至此配置完成!

 

本文出自 “崔晓辉的博客” 博客,请务必保留此出处http://coralzd.blog.51cto.com/90341/486465

    发表评论
    请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
    用户名: 验证码:点击我更换图片
    最新评论 更多>>

    推荐热点

    • Request.ServerVariables 参数大全
    • 执行全文索引时出现权限不足的解决方法
    • 导入excel文件处理流程节点的解决方案
    • 查看sql修改痕迹(SQL Change Tracking on Table)
    • App数据层设计及云存储使用指南
    • PostgreSQL启动过程中的那些事三:加载GUC参数
    • MongoDB安装为Windows服务方法与注意事项
    • Percolator与分布式事务思考(二)
    • 写给MongoDB开发者的50条建议Tip1
    网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
    Copyright © 2008-2015 计算机技术学习交流网. 版权所有

    豫ICP备11007008号-1