Tengine2.1.0 + php5.5.25 + Mysql 5.5.42 安裝

來源:互聯網
上載者:User

標籤:ltmp

安裝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.gz
tar zxf tengine-2.1.0.tar.gz
cd tengine-2.1.0
./configure --prefix=/apps/tengine
make && 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
#下載php
wget http://cn2.php.net/distributions/php-5.5.25.tar.bz2
#解壓並編譯安裝
tar -xjf php-5.5.25.tar.bz2
cd 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=lib64
make 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.ini
sed -i ‘s/upload_max_filesize = 2M/upload_max_filesize = 32M/g‘ /apps/php/etc/php.ini
sed -i ‘s#;date.timezone =.*#date.timezone = Asia/Shanghai#g‘ /apps/php/etc/php.ini
#開啟Opcache
sed -i ‘s/;opcache.enable=0/opcache.enable=1/g‘ /apps/php/etc/php.ini
sed -i ‘/opcache.enable=1/azend_extension = "opcache.so"‘ /apps/php/etc/php.ini
sed -i ‘s/;opcache.enable_cli=0/opcache.enable_cli=1/g‘ /apps/php/etc/php.ini
sed -i ‘s/;opcache.memory_consumption=64/opcache.memory_consumption=128/g‘ /apps/php/etc/php.ini
sed -i ‘s/;opcache.max_accelerated_files=2000/opcache.max_accelerated_files=2000/g‘ /apps/php/etc/php.ini
sed -i ‘s/;opcache.revalidate_freq=2/opcache.revalidate_freq=240/g‘ /apps/php/etc/php.ini
sed -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.ini
cat >/apps/php/etc/php-fpm.conf<<EOF
[global]
pid = /var/run/php-fpm.pid
error_log = /var/log/php/php-fpm-error.log
log_level = notice
rlimit_files = 65535

[www]
listen = /dev/shm/php-fcgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 100
pm.max_requests = 1000
pm.start_servers = 18
pm.min_spare_servers = 5
pm.max_spare_servers = 20
request_terminate_timeout = 900
request_slowlog_timeout = 5
slowlog = /var/log/php/\$pool.log.slow
EOF

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 pkg
cd 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.gz
mkdir -p /apps/mysql
mv mysql-5.5.42-linux2.6-x86_64/* /apps/mysql

ln -s -f /apps/mysql/lib/mysql /usr/lib/mysql
ln -s -f /apps/mysql/include/mysql /usr/include/mysql
ln -s -f /apps/mysql/bin/mysql /usr/bin/mysql
ln -s -f /apps/mysql/bin/mysqldump /usr/bin/mysqldump
ln -s -f /apps/mysql/bin/myisamchk /usr/bin/myisamchk
ln -s -f /apps/mysql/bin/mysqld_safe /usr/bin/mysqld_safe
ln -s -f /apps/mysql/bin/mysqlbinlog /usr/bin/mysqlbinlog
ln -s -f /apps/mysql/bin/mysqladmin /usr/bin/mysqladmin

/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql -s /sbin/nologin -M mysql
mkdir -p /data/dbdata/
chown -R mysql /apps/mysql
chown -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                           = 3306
socket                         = /data/dbdata/mysql.sock
default-character-set          = utf8
 
[mysqld]
# GENERAL #
user                           = mysql
default-storage-engine         = InnoDB
character-set-server           = utf8
lower_case_table_names         = 1
socket                         = /data/dbdata/mysql.sock
pid-file                       = /data/dbdata/mysql.pid
 
# MyISAM #
key-buffer-size                = 128M
myisam-recover-options         = FORCE,BACKUP
 
# SAFETY #
max-allowed-packet             = 32M
max-connect-errors             = 10000
skip-name-resolve
 
# DATA STORAGE #
datadir                        = /data/dbdata/
 
# BINARY LOGGING #
log-bin                        = /data/dbdata/mysql-bin
expire-logs-days               = 14
sync-binlog                    = 1
max_binlog_size                = 500M
 
# CACHES AND LIMITS #
tmp-table-size                 = 32M
max-heap-table-size            = 32M
query-cache-type               = 0
query-cache-size               = 0
connect_timeout                = 20
back_log                       = 256
max-connections                = 1024
thread-cache-size              = 64
open-files-limit               = 65535
table-definition-cache         = 2048
table-open-cache               = 4096
 
# INNODB #
innodb_data_file_path          = ibdata1:10M:autoextend
innodb-flush-method            = O_DIRECT
innodb-log-files-in-group      = 2
innodb-log-file-size           = 256M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table          = 1
innodb_thread_concurrency      = 4
innodb-buffer-pool-size        = 6G
 
# LOGGING #
log-error                      = /data/dbdata/mysql-error.log
log-queries-not-using-indexes  = 1
slow-query-log                 = 1
slow-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/mysqld
sed -i ‘s#^basedir=$#basedir=/apps/mysql/#‘ /etc/init.d/mysqld
sed -i ‘s#^datadir=$#datadir=/data/dbdata/#‘ /etc/init.d/mysqld
sed -i "s#/usr/local/mysql#/apps/mysql#g" /apps/mysql/bin/mysqld_safe
chmod +x /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on

#啟動mysql:
/etc/init.d/mysqld start

#簡單配置myslq資料庫
cat > /tmp/mysql_sec_script<<EOF
use 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;
EOF
mysql < /tmp/mysql_sec_script
rm -f /tmp/mysql_sec_script





Tengine2.1.0 + php5.5.25 + Mysql 5.5.42 安裝

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.