安装Tengine
#yum安装pcre库yum install pcre-devel openssl openssl-devel zlib -y #创建运行账号useradd -s /sbin/nologin -M www #下载并安装wget http://tengine.taobao.org/download/tengine-2.1.0.tar.gztar zxf tengine-2.1.0.tar.gzcd tengine-2.1.0./configure --prefix=/apps/tenginemake && make install #nginx.conf 参考====================================================user www www;worker_processes auto;worker_cpu_affinity auto; error_log /data/logs/nginx/error.log crit;pid /var/run/nginx.pid; worker_rlimit_nofile 51200; events{ use epoll; worker_connections 51200;} http{ include mime.types; default_type application/octet-stream; server_tokens off; server_tag TWS; reset_timedout_connection on; keepalive_timeout 120; keepalive_requests 100; sendfile on; tcp_nodelay on; tcp_nopush off; ignore_invalid_headers on; server_names_hash_max_size 256; server_names_hash_bucket_size 64; client_header_buffer_size 8k; large_client_header_buffers 4 32k; client_max_body_size 50m; client_body_buffer_size 256k; connection_pool_size 256; request_pool_size 64k; output_buffers 2 128k; postpone_output 1460; client_header_timeout 1m; client_body_timeout 3m; send_timeout 3m; 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 on; gzip_min_length 1k; gzip_buffers 4 32k; gzip_http_version 1.1; gzip_comp_level 4; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; log_format main ‘$remote_addr - $remote_user [$time_local] "$request" ‘ ‘$status $body_bytes_sent "$http_referer" ‘ ‘"$http_user_agent" "$http_x_forwarded_for" $request_time‘; open_log_file_cache max=1000 inactive=20s min_uses=1 valid=1m; server { listen 80; server_name test.cnyang.com; access_log /data/logs/nginx/test.cnyang.access.log main; index index.php index.html index.html; root /data/site/test.cnyang.com; location / { try_files $uri $uri/ /index.php?$args; } location ~ .*\.(php)?$ { expires -1s; try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; include fastcgi_params; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/dev/shm/php-fcgi.sock; #和后面的php-fpm配置结合使用(通过sock方式与php连接) } location /nstu { stub_status on; access_log off; # allow 172.16.50.0/24; # deny all; } location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } location ~ .*\.(js|css)?$ { expires 12h; } } }====================================================
安装php
#需要有www用户useradd -s /sbin/nologin -M www#yum解决依赖包问题。yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y#下载phpwget http://cn2.php.net/distributions/php-5.5.25.tar.bz2#解压并编译安装tar -xjf php-5.5.25.tar.bz2cd php-5.5.25./configure --prefix=/apps/php --with-config-file-path=/apps/php/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --enable-opcache --with-fpm-user=www --with-fpm-group=www --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64make ZEND_EXTRA_LIBS=‘-liconv‘make install #修改配置文件cp php.ini-production /apps/php/etc/php.ini sed -i ‘s/post_max_size = 8M/post_max_size = 50M/g‘ /apps/php/etc/php.inised -i ‘s/upload_max_filesize = 2M/upload_max_filesize = 32M/g‘ /apps/php/etc/php.inised -i ‘s#;date.timezone =.*#date.timezone = Asia/Shanghai#g‘ /apps/php/etc/php.ini#开启Opcachesed -i ‘s/;opcache.enable=0/opcache.enable=1/g‘ /apps/php/etc/php.inised -i ‘/opcache.enable=1/azend_extension = "opcache.so"‘ /apps/php/etc/php.inised -i ‘s/;opcache.enable_cli=0/opcache.enable_cli=1/g‘ /apps/php/etc/php.inised -i ‘s/;opcache.memory_consumption=64/opcache.memory_consumption=128/g‘ /apps/php/etc/php.inised -i ‘s/;opcache.max_accelerated_files=2000/opcache.max_accelerated_files=2000/g‘ /apps/php/etc/php.inised -i ‘s/;opcache.revalidate_freq=2/opcache.revalidate_freq=240/g‘ /apps/php/etc/php.inised -i ‘s/expose_php = On/expose_php = Off/g‘ /apps/php/etc/php.ini #禁止显示版本信息#禁用一些较危险的函数。sed -i ‘s/disable_functions =/disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname/g‘ /apps/php/etc/php.inicat >/apps/php/etc/php-fpm.conf<<EOF[global]pid = /var/run/php-fpm.piderror_log = /var/log/php/php-fpm-error.loglog_level = noticerlimit_files = 65535 [www]listen = /dev/shm/php-fcgi.socklisten.backlog = -1listen.allowed_clients = 127.0.0.1listen.owner = wwwlisten.group = wwwlisten.mode = 0666user = wwwgroup = wwwpm = dynamicpm.max_children = 100pm.max_requests = 1000pm.start_servers = 18pm.min_spare_servers = 5pm.max_spare_servers = 20request_terminate_timeout = 900request_slowlog_timeout = 5slowlog = /var/log/php/\$pool.log.slowEOF mkdir /var/log/php
安装mysql
#yum解决依赖yum install –y autoconf automake imake libxml2-devel expat-devel cmake gcc gcc-c++ libaio libaio-devel bzr bison libtool ncurses5-devel #下载安装mkdir pkgcd pkg[ ! -s mysql-5.5.42-linux2.6-x86_64.tar.gz ] && wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.42-linux2.6-x86_64.tar.gz tar zxf mysql-5.5.42-linux2.6-x86_64.tar.gzmkdir -p /apps/mysqlmv mysql-5.5.42-linux2.6-x86_64/* /apps/mysql ln -s -f /apps/mysql/lib/mysql /usr/lib/mysqlln -s -f /apps/mysql/include/mysql /usr/include/mysqlln -s -f /apps/mysql/bin/mysql /usr/bin/mysqlln -s -f /apps/mysql/bin/mysqldump /usr/bin/mysqldumpln -s -f /apps/mysql/bin/myisamchk /usr/bin/myisamchkln -s -f /apps/mysql/bin/mysqld_safe /usr/bin/mysqld_safeln -s -f /apps/mysql/bin/mysqlbinlog /usr/bin/mysqlbinlogln -s -f /apps/mysql/bin/mysqladmin /usr/bin/mysqladmin /usr/sbin/groupadd mysql/usr/sbin/useradd -g mysql -s /sbin/nologin -M mysqlmkdir -p /data/dbdata/chown -R mysql /apps/mysqlchown -R mysql /data/dbdata/ #my.cnf 参考 [ -f /etc/my.cnf ] && mv /etc/my.cnf /etc/my.cnf-$(date +%Y%m%d)cat /etc/my.cnf============================================[mysql]# CLIENT #port = 3306socket = /data/dbdata/mysql.sockdefault-character-set = utf8 [mysqld]# GENERAL #user = mysqldefault-storage-engine = InnoDBcharacter-set-server = utf8lower_case_table_names = 1socket = /data/dbdata/mysql.sockpid-file = /data/dbdata/mysql.pid # MyISAM #key-buffer-size = 128Mmyisam-recover-options = FORCE,BACKUP # SAFETY #max-allowed-packet = 32Mmax-connect-errors = 10000skip-name-resolve # DATA STORAGE #datadir = /data/dbdata/ # BINARY LOGGING #log-bin = /data/dbdata/mysql-binexpire-logs-days = 14sync-binlog = 1max_binlog_size = 500M # CACHES AND LIMITS #tmp-table-size = 32Mmax-heap-table-size = 32Mquery-cache-type = 0query-cache-size = 0connect_timeout = 20back_log = 256max-connections = 1024thread-cache-size = 64open-files-limit = 65535table-definition-cache = 2048table-open-cache = 4096 # INNODB #innodb_data_file_path = ibdata1:10M:autoextendinnodb-flush-method = O_DIRECTinnodb-log-files-in-group = 2innodb-log-file-size = 256Minnodb-flush-log-at-trx-commit = 1innodb-file-per-table = 1innodb_thread_concurrency = 4innodb-buffer-pool-size = 6G # LOGGING #log-error = /data/dbdata/mysql-error.loglog-queries-not-using-indexes = 1slow-query-log = 1slow-query-log-file = /data/dbdata/mysql-slow.log============================================ #初始化MySQL数据库/apps/mysql/scripts/mysql_install_db --defaults-file=/etc/my.cnf --basedir=/apps/mysql --datadir=/data/dbdata/ --user=mysql #配置mysql启动文件cp -f /apps/mysql/support-files/mysql.server /etc/init.d/mysqldsed -i ‘s#^basedir=$#basedir=/apps/mysql/#‘ /etc/init.d/mysqldsed -i ‘s#^datadir=$#datadir=/data/dbdata/#‘ /etc/init.d/mysqldsed -i "s#/usr/local/mysql#/apps/mysql#g" /apps/mysql/bin/mysqld_safechmod +x /etc/init.d/mysqldchkconfig --add mysqldchkconfig mysqld on #启动mysql:/etc/init.d/mysqld start #简单配置myslq数据库cat > /tmp/mysql_sec_script<<EOFuse mysql;update user set password=password(‘mysql1234‘) where user=‘root‘;delete from user where not (user=‘root‘);delete from user where user=‘root‘ and password=‘‘;DROP USER ‘‘@‘%‘;flush privileges;EOFmysql < /tmp/mysql_sec_scriptrm -f /tmp/mysql_sec_script
时间: 2024-12-29 02:12:19