1. Add the sync site in/etc/make. conf and use emerge for synchronization later.
Copy codeThe Code is as follows: SYNC = "rsync: // rsync.gentoo.org/gentoo-portage"
Execute emerge -- sync to synchronize the portage tree.
2. Upgrade the portage version. If you want to install mysql later, the old portage version will be prompted!Copy codeThe Code is as follows: emerge portage
Define USE first:Copy codeThe Code is as follows:/etc/portage/package. use
Dev-lang/php cli ming xml ftp curl pdo mysqli mysql sqlite json cgi ctype gd hash
Www-servers/nginx fastcgi
Edit/etc/portage/package. keywords
Www-servers/spawn-fcgi ~ X86
3. Install mysql nginx php spawn-fcgi pecl-apc pecl-memcache.Copy codeThe Code is as follows: emerge mysql nginx php spawn-fcgi pecl-apc pecl-memcache
4. Configure mysql.Copy codeThe Code is as follows: mkdir-p/data0/mysql/data
Mysql_install_db -- user = mysql -- basedir =/usr -- datadir =/data0/mysql/data
Configure my. cnfCopy codeThe Code is as follows: rm-f/etc/mysql/my. cnf
Vim/etc/mysql/my. cnf
[Client]
Port = 3306
Socket =/var/run/mysqld. sock
[Mysql]
Prompt = "(\ u: s135 [\ d]>"
No-auto-rehash
[Mysqld]
Bind-address = 173.252.207.109
User = mysql
Port = 3306
Socket =/var/run/mysqld. sock
Basedir =/usr
Datadir =/data0/mysql/data
Open_files_limit = 600
Back_log = 20
Max_connections = 100
Max_connect_errorrs = 200
Table_cache = 60
External-locking = FALSE
Max_allowed_packet = 16 M
Sort_buffer_size = 128 K
Join_buffer_size = 128 K
Thread_cache_size = 10
Thread_concurrency = 8
Query_cache_size = 0 M
Query_cache_limit = 2 M
Query_cache_min_res_unit = 2 k
Default_table_type = MyISAM
Thread_stack = 192 K
Transaction_isolation = READ-UNCOMMITTED
Tmp_table_size = 512 K
Max_heap_table_size = 32 M
/Var/log/slow. log
/Var/log/error. log
Long_query_time = 1
Log_long_format
Server-id = 1
# Log-bin =/usr/local/mysql/data/binlog
Binlog_cache_size = 2 M
Max_binlog_cache_size = 4 M
Max_binlog_size = 512 M
Expire_logs_days = 7
Key_buffer_size = 4 M
Read_buffer_size = 1 M
Read_rnd_buffer_size = 2 M
Bulk_insert_buffer_size = 2 M
Myisam_sort_buffer_size = 4 M
Myisam_max_sort_file_size = 10G
Myisam_max_extra_sort_file_size = 10G
Myisam_repair_threads = 1
Myisam_recover
[Mysqldump]
Quick
Max_allowed_packet = 16 M
Mysqladmin-uroot password ""
Start mysql
/Etc/init. d/mysql start
5. Configure nginx
Vim/etc/nginx. confCopy codeThe Code is as follows: user nginx;
Worker_processes 1;
Error_log/var/log/nginx/nginx_error.log crit;
Pid/var/run/nginx. pid;
# Specifies the value for maximum file descriptors that can be opened by this process.
Worker_rlimit_nofile 52100;
Events
{
Use epoll;
Worker_connections 52100;
}
Http
{
Include mime. types;
Default_type application/octet-stream;
# Charset gb2312;
Server_names_hash_bucket_size 128;
Client_header_buffer_size 32 k;
Large_client_header_buffers 4 32 k;
Client_max_body_size 8 m;
Sendfile on;
Tcp_nopush on;
Keepalive_timeout 70 20;
Tcp_nodelay on;
Server_tokens off;
Fastcgi_connect_timeout 300;
Fastcgi_send_timeout 300;
Fastcgi_read_timeout 300;
Fastcgi_buffer_size 64 k;
Fastcgi_buffers 4 64 k;
Fastcgi_busy_buffers_size 128 k;
Fastcgi_temp_file_write_size 128 k;
Gzip off;
Gzip_min_length 1 k;
Gzip_buffers 4 16 k;
Gzip_http_version 1.0;
Gzip_comp_level 2;
Gzip_types text/plain application/x-javascript text/css application/xml;
Gzip_vary on;
Server
{
Server_name www.freebsdsystem.org;
Root/data0/www/wwwroot /;
Index index.html index.htm index. php;
Location ~ . * \. Php? $
{
# Fastcgi_pass unix:/tmp/php-cgi.sock;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fcinclude gi. conf;
}
Location ~ . * \. (Gif | jpg | jpeg | png | bmp | swf) $
{
Expires 30d;
}
Location ~ . * \. (Js | css )? $
{
Expires 1 h;
}
Log_format blog '$ remote_addr-$ remote_user [$ time_local] "$ request "'
'$ Status $ body_bytes_sent "$ http_referer "'
'"$ Http_user_agent" $ http_x_forwarded_for ';
Access_log/var/log/nginx/blog. log blog;
}
}
Configure spawn-fcgiCopy codeThe Code is as follows: vim/usr/local/bin/php-fcgi
#! /Bin/sh
# Author: corzd
# Powered by www.freebsdsystem.org
Bin =/usr/bin/php-cgi
Case $1 in
Start)
Echo "starting php-cgi"
Spawn-fcgi-a 127.0.0.1-p 9000-C 8-u nginx-g nginx-f/usr/bin/php-cgi 2> & 1>/dev/null &
Echo "Done"
Stop)
Killall php-cgi
Echo "php-cgi stop"
*)
Echo "usage start | stop ";;
Esac
6. Start nginx mysql at startupCopy codeThe Code is as follows: rc-update add nginx default
Rc-update add mysql default
This configuration is complete!