diff --git a/lemp.sh b/lemp.sh index 87adeff..98ffc15 100644 --- a/lemp.sh +++ b/lemp.sh @@ -1,7 +1,7 @@ #!/bin/bash # Install script for LEMP Web Server on CentOS 6 by xiaosong - +cd `pwd` # Checking echo "Checking..." if [ -n "`grep 'Aliyun Linux release' /etc/issue`" -o -e /etc/redhat-release ];then @@ -63,6 +63,9 @@ sudo mv composer.phar /usr/bin/composer # Configure Nginx for PHP echo "Configuring Nginx for PHP..." sudo sed -i 's/index index.html index.htm;/index index.php index.html index.htm;/g' /etc/nginx/conf.d/default.conf +sudo sed -i 's/fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;/fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;/g' /etc/nginx/conf.d/default.conf +sudo cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak +sudo cp ./nginx.conf /etc/nginx/nginx.conf # Configure PHP echo "Configuring PHP..." @@ -75,6 +78,11 @@ sudo sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /etc/php.ini sudo sed -i 's/user = apache/user = nginx/g' /etc/php-fpm.d/www.conf sudo sed -i 's/group = apache/group = nginx/g' /etc/php-fpm.d/www.conf +# Configure MariaDB +echo "Configuring MariaDB..." +sudo cp ./my.cnf /etc/my.cnf +sudo cp ./server.cnf /etc/my.cnf.d/server.cnf + # Restarting Services echo "Restarting Services..." sudo service mysql restart diff --git a/my.cnf b/my.cnf new file mode 100644 index 0000000..5b3015c --- /dev/null +++ b/my.cnf @@ -0,0 +1,16 @@ +# +# This group is read both both by the client and the server +# use it for options that affect everything +# +[client-server] + +[myisamchk] +key_buffer_size = 8M +sort_buffer_size = 8M +read_buffer = 4M +write_buffer = 4M + +# +# include all files from the config directory +# +!includedir /etc/my.cnf.d \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..7094957 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,60 @@ + +user nginx; +worker_processes 1; +worker_rlimit_nofile 51200; + +error_log /var/log/nginx/error.log warn; +pid /var/run/nginx.pid; + + +events { + use epoll; + worker_connections 51200; + multi_accept on; +} + + +http { + include /etc/nginx/mime.types; + default_type application/octet-stream; + + log_format main '$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/access.log main; + + server_names_hash_bucket_size 128; + client_header_buffer_size 32k; + large_client_header_buffers 4 32k; + client_max_body_size 50m; + sendfile on; + tcp_nopush on; + keepalive_timeout 120; + server_tokens off; + tcp_nodelay on; + + gzip on; + gzip_vary on; + gzip_comp_level 6; + gzip_min_length 1k; + gzip_buffers 16 8k; + gzip_http_version 1.1; + gzip_proxied any; + gzip_types + text/xml application/xml application/atom+xml application/rss+xml application/xhtml+xml image/svg+xml + text/javascript application/javascript application/x-javascript + text/x-json application/json application/x-web-app-manifest+json + text/css text/plain text/x-component + font/opentype application/x-font-ttf application/vnd.ms-fontobject + image/x-icon; + gzip_disable "MSIE [1-6]\.(?!.*SV1)"; + + server { + listen 80 default_server; + server_name _; + return 404; + } + + include /etc/nginx/conf.d/*.conf; +} \ No newline at end of file diff --git a/server.cnf b/server.cnf new file mode 100644 index 0000000..b198d19 --- /dev/null +++ b/server.cnf @@ -0,0 +1,112 @@ +# +# These groups are read by MariaDB server. +# Use it for options that only the server (but not clients) should see +# +# See the examples of server my.cnf files in /usr/share/mysql/ +# + +# this is read by the standalone daemon and embedded servers +[server] + +# this is only for the mysqld standalone daemon +[mysqld] +bind-address = 0.0.0.0 +server-id = 1 + +init-connect = 'SET NAMES utf8mb4' +character-set-server = utf8mb4 + +skip-name-resolve +back_log = 300 + +max_connections = 496 +max_connect_errors = 6000 +open_files_limit = 65535 +table_open_cache = 128 +max_allowed_packet = 500M +binlog_cache_size = 1M +max_heap_table_size = 8M +tmp_table_size = 16M + +read_buffer_size = 2M +read_rnd_buffer_size = 8M +sort_buffer_size = 8M +join_buffer_size = 8M +key_buffer_size = 4M + +thread_cache_size = 8 + +query_cache_type = 1 +query_cache_size = 8M +query_cache_limit = 2M + +ft_min_word_len = 4 + +log_bin = mysql-bin +binlog_format = mixed +expire_logs_days = 7 + +log_error = /data/mariadb/mysql-error.log +slow_query_log = 1 +long_query_time = 1 +slow_query_log_file = /data/mariadb/mysql-slow.log + +performance_schema = 0 + +skip-external-locking + +default_storage_engine = InnoDB +innodb_file_per_table = 1 +innodb_open_files = 500 +innodb_buffer_pool_size = 64M +innodb_write_io_threads = 4 +innodb_read_io_threads = 4 +innodb_thread_concurrency = 0 +innodb_purge_threads = 1 +innodb_flush_log_at_trx_commit = 2 +innodb_log_buffer_size = 2M +innodb_log_file_size = 32M +innodb_log_files_in_group = 3 +innodb_max_dirty_pages_pct = 90 +innodb_lock_wait_timeout = 120 + +bulk_insert_buffer_size = 8M +myisam_sort_buffer_size = 8M +myisam_max_sort_file_size = 10G +myisam_repair_threads = 1 + +interactive_timeout = 28800 +wait_timeout = 28800 + +# +# * Galera-related settings +# +[galera] +# Mandatory settings +#wsrep_on=ON +#wsrep_provider= +#wsrep_cluster_address= +#binlog_format=row +#default_storage_engine=InnoDB +#innodb_autoinc_lock_mode=2 +# +# Allow server to accept connections on all interfaces. +# +#bind-address=0.0.0.0 +# +# Optional setting +#wsrep_slave_threads=1 +#innodb_flush_log_at_trx_commit=0 + +# this is only for embedded server +[embedded] + +# This group is only read by MariaDB servers, not by MySQL. +# If you use the same .cnf file for MySQL and MariaDB, +# you can put MariaDB-only options here +[mariadb] + +# This group is only read by MariaDB-10.1 servers. +# If you use the same .cnf file for MariaDB of different versions, +# use this group for options that older servers don't understand +[mariadb-10.1]