mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo wget http://mirrors.kernel.org/fedora-epel/5/x86_64/epel-release-5-4.noarch.rpmrpm -ivh epel-release-5-4.noarch.rpm yum -y install lrzszchkconfig --list | awk '{print $1}'for i in `chkconfig --list | awk '{print $1}'`;do chkconfig $i off;donefor i in sshd syslog network crond;do chkconfig $i on;doneyum -y install *vim*vim /etc/ssh/sshd_configcat /sys/block/sda/queue/schedulerelevator=deadlinevim /etc/grub.confyum list | grep xfsyum -y install *xfs*yum -y install @Base 还是用下面这种 个人不喜欢这种写法yum -y groupinstall "Base"yum -y install gcc gcc-c++ autoconf libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers libtool libtool-libs gmp-devel unzip libcap fontconfig fontconfig-devel libXpm libXpm-develyum install libXpm.i686 libXpm-devel.i686 libjpeg.i686 libjpeg-devel.i686 libpng.i686 libpng-devel.i686 freetype.i686 freetype-devel.i686 -yyum install libXpm.i386 libXpm-devel.i386 libjpeg.i386 libjpeg-devel.i386 libpng.i386 libpng-devel.i386 freetype.i386 freetype-devel.i386 -yvim /etc/ld.so.conf.d/lnmp.conf/usr/local/lib/usr/local/lib64ldconfigtar -xf libevent-2.0.22-stable.tar.gz./configure && make && make installtar -xf libiconv-1.14.tar.gz./configure && make && make installtar -xf libmcrypt-2.5.8.tar.gz./configure && make && make installcd libltdl/./configure --enable-ltdl-install && make && make installtar -xf mhash-0.9.9.9.tar.gz./configure && make && make installtar -xf mcrypt-2.6.8.tar.gz./configure && make && make install/data0 nginx 目录tar -xf nginx-0.8.55.tar.gz./configure --prefix=/usr/local/nginx \--with-pcre \--with-http_ssl_module \--with-http_flv_module \--with-http_stub_status_module \--with-http_gzip_static_module make && make installmkdir -p /data0chmod a+w /data0/mkdir -pv /data0/webvim /etc/profile.d/nginx.shexport PATH=$PATH:/usr/local/nginx/sbinchmod +x /etc/profile.d/nginx.shMySQL# groupadd -r mysql# useradd -g mysql -r -s /sbin/nologin -M mysqltar -xf mysql-5.5.45-linux2.6-x86_64.tar.gzln -sv mysql-5.5.45-linux2.6-x86_64 mysqlcd mysqlchown -R mysql.mysql .chown -R mysql.mysql /data1mkdir etccp ~/my.cnf .chown -R mysql.mysql .scripts/mysql_install_db --defaults-file=/usr/local/mysql/etc/my.cnf/usr/local/mysql/bin/mysqld_safe --defaults-file=/usr/local/mysql/etc/my.cnf &vim /etc/man.configMANPATH /usr/local/mysql/manln -sv /usr/local/mysql/include /usr/include/mysqlvim /etc/ld.so.conf.d/mysql.conf/usr/local/mysql/libvim /etc/profile.d/mysql.shexport PATH=$PATH:/usr/local/mysql/binchmod +x /etc/profile.d/mysql.shsource /etc/profile.d/mysql.sh格式化XFSmkfs.xfs -f /dev/sdb1/dev/sdb1 /data1 xfs defaults,noatime,nodiratime,nobarrier 1 2PHPtar -xf php-5.4.45.tar.bz2./configure --prefix=/usr/local/php \--with-mysql=mysqlnd \--with-mysqli=mysqlnd \--with-pdo-mysql=mysqlnd \--with-zlib \--with-zlib-dir \--with-openssl \--with-curl \--enable-ftp \--with-gd \--enable-gd-native-ttf \--with-jpeg-dir \--with-png-dir \--with-xpm-dir \--with-freetype-dir \--enable-mbstring \--with-mcrypt \--with-mhash \--with-iconv-dir=/usr \--enable-zip \--enable-fpm \--with-config-file-scan-dir=/etc/php.d \--with-config-file-path=/usr/local/php/lib/ \--with-bz2 \--enable-xml \--with-libxml-dir=/usr \--enable-sysvshm \--enable-sockets \--enable-sysvsem \--enable-bcmath \--enable-shmop \--enable-inline-optimization \--with-curlwrappers \--enable-mbregex \--enable-pcntl \--enable-soap \--with-xmlrpc \--enable-maintainer-zts make ZEND_EXTRA_LIBS='-liconv'make installcp php.ini-development /usr/local/php/lib/php.inicd /usr/local/php/etc/cp php-fpm.conf.default php-fpm.confcp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpmchmod a+x /etc/rc.d/init.d/php-fpmchkconfig --add php-fpmchkconfig php-fpm onvim /usr/local/php/etc/php-fpm.confpm.max_children = 150pm.start_servers = 8pm.min_spare_servers = 5pm.max_spare_servers = 10pid = /usr/local/php/var/run/php-fpm.pid vim /usr/local/php/lib/php.inicgi.fix_pathinfo=0wget http://pecl.php.net/get/pthreads-0.0.45.tgzcd pthreads-0.0.45/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake installwget http://pecl.php.net/get/memcache-2.2.7.tgztar -xf memcache-2.2.7.tgzcd memcache-2.2.7/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmake && make installtar -xf eaccelerator-eaccelerator-42067ac.tar.gzcd eaccelerator-eaccelerator-42067ac/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmake && make installtar -xf ImageMagick-6.9.0-1.tar.bz2cd ImageMagick-6.9.0-1./configuremake && make installtar -xf imagick-3.2.0b2.tgz cd imagick-3.2.0b2ls -l/usr/local/php/bin/phpize ./configure --with-php-config=/usr/local/php/bin/php-config make && make installvim /usr/local/php/lib/php.iniextension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/"extension = memcache.soextension = imagick.so[eaccelerator]zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/eaccelerator.so"eaccelerator.shm_size="64"eaccelerator.cache_dir="/tmp/eaccelerator"eaccelerator.enable="1"eaccelerator.optimizer="1"eaccelerator.check_mtime="1"eaccelerator.debug="0"eaccelerator.filter=""eaccelerator.shm_max="0"eaccelerator.shm_ttl="3600"eaccelerator.shm_prune_period="3600"eaccelerator.shm_only="0"eaccelerator.compress="1"eaccelerator.compress_level="9"mkdir /tmp/eacceleratorchmod 0777 /tmp/eaccelerator/usr/local/php/bin/php -mchmod -R a+w /data0mkdir -pv /data0/web/www.test155.com隐藏nginx php 版本信息nginxserver_tokens off;fastcgi_param SERVER_SOFTWARE nginx;phpexpose_php = Off重启nginx php-fpm可以改动内核参数 :net.ipv4.ip_forward = 0net.ipv4.conf.default.rp_filter = 1net.ipv4.conf.default.accept_source_route = 0kernel.sysrq = 0kernel.core_uses_pid = 1net.ipv4.tcp_syncookies = 1kernel.msgmnb = 65536kernel.msgmax = 65536kernel.shmmax = 68719476736kernel.shmall = 4294967296net.ipv4.tcp_max_tw_buckets = 6000net.ipv4.tcp_sack = 1net.ipv4.tcp_window_scaling = 1net.ipv4.tcp_rmem = 4096 87380 4194304net.ipv4.tcp_wmem = 4096 16384 4194304net.core.wmem_default = 8388608net.core.rmem_default = 8388608net.core.rmem_max = 16777216net.core.wmem_max = 16777216net.core.netdev_max_backlog = 262144net.core.somaxconn = 262144net.ipv4.tcp_max_orphans = 3276800net.ipv4.tcp_max_syn_backlog = 262144net.ipv4.tcp_timestamps = 0net.ipv4.tcp_synack_retries = 1net.ipv4.tcp_syn_retries = 1net.ipv4.tcp_tw_recycle = 1net.ipv4.tcp_tw_reuse = 1net.ipv4.tcp_mem = 94500000 915000000 927000000net.ipv4.tcp_fin_timeout = 1net.ipv4.tcp_keepalive_time = 30net.ipv4.ip_local_port_range = 1024 65000------------------------------------------------避免Too many open files in system这个问题:ulimit -SHn 65535vim /etc/security/limits.conf* soft nproc 65535* hard nproc 65535* soft nofile 65535* hard nofile 65535------------------------------------------------php支持多线程:--enable-maintainer-zts编译必须加上上面参数在扩展这个:pthreads-master.zip 和memcache 一样的扩展方式wget http://pecl.php.net/get/pthreads-0.0.45.tgzcd pthreads-0.0.45/usr/local/php/bin/phpize./configure --with-php-config=/usr/local/php/bin/php-configmakemake installmy.cnf 配置[root@localhost ~]# cat my.cnf #这个MySQL配置原版来源于MySQL管理之道一书作者书中所写#此配置有几个目录需要先建立起来#这个是datadir /data1/data /data1/tmp #二进制日志目录 /data1/logs#错误日志 慢查询日志 等/data1/logs#从72G 内存到1G 内存 改小了innodb_buffer_pool_size innodb_buffer_pool_instances#innodb_read_io_threads innodb_write_io_threads 此2个参数一般为cpu核数的2倍#myisam_max_sort_file_size = 1G 改为和内存一样大小[client]port = 3306socket = /data1/mysql.sock[mysqld]server_id = 22port = 3306user = mysql#MySQL安装目录basedir = /usr/local/mysql#MySQL数据目录datadir = /data1/datatmpdir = /data1/datasocket = /data1/mysql.sockskip_external_lockingskip_name_resolve#默认存储引擎default_storage_engine = innodb#服务器字符集character_set_server = utf8wait_timeout = 100connect_timeout = 20interactive_timeout = 100back_log = 500myisam_recoverevent_scheduler = ON###############binlog###############log-bin = /data1/logs/mysql-binbinlog_format = rowmax_binlog_size = 128Mbinlog_cache_size = 2Mexpire_logs_days = 5##############slow log################slow_query_log = 1slow_query_log_file = /data1/logs/mysql.slowlong_query_time = 2###############error log###############log-error = /data1/logs/error.log###############per_thread_buffers###############max_connections = 1024max_user_connections = 1000max_connect_errors = 10000key_buffer_size = 64Mmax_allowed_packet = 128Mtable_cache = 3096table_open_cache = 6144table_definition_cache = 4096sort_buffer_size = 512Kread_buffer_size = 512Kread_rnd_buffer_size = 512Kjoin_buffer_size = 512Ktmp_table_size = 64Mmax_heap_table_size = 64Mquery_cache_type = 0query_cache_size = 0bulk_insert_buffer_size = 32Mthread_cache_size = 64thread_stack = 256K###############innodb##############innodb_data_home_dir = /data1/datainnodb_log_group_home_dir = /data1/logsinnodb_data_file_path = ibdata1:2G:autoextendinnodb_buffer_pool_size = 512Minnodb_buffer_pool_instances = 1innodb_additional_mem_pool_size = 16Minnodb_log_file_size = 1024Minnodb_log_buffer_size = 64Minnodb_log_files_in_group = 3innodb_flush_log_at_trx_commit = 2innodb_lock_wait_timeout = 10innodb_sync_spin_loops = 40innodb_max_dirty_pages_pct = 90innodb_support_xa = 1innodb_thread_concurrency = 0innodb_thread_sleep_delay = 500innodb_file_io_threads = 4innodb_concurrency_tickets = 1000log_bin_trust_function_creators = 1innodb_flush_method = O_DIRECTinnodb_file_per_table = 1innodb_read_io_threads = 4innodb_write_io_threads = 4innodb_io_capacity = 2000innodb_file_format = barracudainnodb_purge_threads = 1innodb_purge_batch_size = 32innodb_old_blocks_pct = 75innodb_change_buffering = alltransaction_isolation = READ-COMMITTED[mysqldump]quickmax_allowed_packet = 128Mmyisam_max_sort_file_size = 1G[mysql]no-auto-rehash[myisamchk]key_buffer_size = 64Msort_buffer_size = 256Kread_buffer = 2Mwrite_buffer = 2M[mysqlhotcopy]interactive-timeout[mysqld_safe]open_files_limit = 28192nginx 配置:[root@localhost ~]# cat nginx.conf user nobody;worker_processes 8; error_log logs/nginx_error.log info;pid logs/nginx.pid;worker_rlimit_nofile 204800;events{ use epoll; worker_connections 204800;}http{ include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; sendfile on; tcp_nopush on; keepalive_timeout 30; server_tokens off; 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 128k; open_file_cache max=204800 inactive=20s; open_file_cache_min_uses 1; open_file_cache_valid 30s; tcp_nodelay on; 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; server { listen 80; server_name www.test155.com; root /data0/web/www.test155.com; index index.html index.htm index.php; location ~ .*\.php?$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_intercept_errors on; fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; include fastcgi_params; fastcgi_param HTTPS on; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)?$ { expires 7d; } location ~ .*\.(js|css)?$ { expires 1d; } location = /status { stub_status on; access_log off; } log_format access '$remote_addr -- $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" $http_x_forwarded_for'; access_log /data0/web/access_www.test155.com.log access; }}