# nginx php56
#aliyun服务器
#rm -rf /usr/sbin/aliyun-service
yum update -y
yum install epel-release -y
yum install nginx mariadb -y
yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum -y install php56-php php56-php-pear php56-php-devel php56-php-fpm php56-php-mysqli php56-php-gd php56-php-cgi php56-php-curl php56-php-mbstring php56-php-bcmath php56-php-redis php56-php-memcached php56-php-memcache php56-php-apc git
yum -y install mariadb mariadb-server
yum install zsh htop iftop axel jq lsof vim make gcc unzip memcached redis mlocate fail2ban mod_ssl -y
updatedb
#vim
cat >>~/.vimrc<<EOF
set fileencodings=utf-8,ucs-bom,gb18030,gbk,gb2312,cp936
set termencoding=utf-8
set encoding=utf-8
:colorscheme desert
:set ts=2
:set expandtab
:%retab!
EOF
#sysctl
cat >/etc/sysctl.conf<<EOF
net.ipv4.icmp_echo_ignore_all = 1
net.ipv4.tcp_congestion_control = bbr
net.core.default_qdisc = fq
EOF
#firewalld
systemctl start firewalld
systemctl enable firewalld
firewall-cmd --add-service=http --permanent
firewall-cmd --add-service=http
firewall-cmd --add-service=https --permanent
firewall-cmd --add-service=https
#nginx
echo "" > /usr/share/nginx/html/index.html;
echo "" > /usr/share/nginx/html/404.html;
echo "" > /usr/share/nginx/html/50x.html;
sed -i '29a\ \ \ \ server_tokens off;' /etc/nginx/nginx.conf;
sed -i "29a\ \ \ \ client_max_body_size 100M;" /etc/nginx/nginx.conf
#php56
sed -i "s/expose_php\ =\ On/expose_php\ =\ Off/g" /opt/remi/php56/root/etc/php.ini
sed -i "s/upload_max_filesize\ =\ 2M/upload_max_filesize\ =\ 200M/g" /opt/remi/php56/root/etc/php.ini
sed -i "s/post_max_size\ =\ 8M/post_max_size\ =\ 200M/g" /opt/remi/php56/root/etc/php.ini
sed -i "s/max_execution_time\ =\ 30/max_execution_time\ =\ 300/g" /opt/remi/php56/root/etc/php.ini
sed -i "s/max_input_time\ =\ 60/max_input_time\ =\ 300/g" /opt/remi/php56/root/etc/php.ini
sed -i "s/memory_limit\ =\ 128M/memory_limit\ =\ 1280M/g" /opt/remi/php56/root/etc/php.ini
sed -i "23s/apache/nginx/g" /opt/remi/php56/root/etc/php-fpm.d/www.conf
sed -i "25s/apache/nginx/g" /opt/remi/php56/root/etc/php-fpm.d/www.conf
chown -R nginx:nginx /opt/remi/php56/root/var/lib/php/
#system
systemctl enable php56-php-fpm;
systemctl start php56-php-fpm;
systemctl enable nginx;
systemctl restart nginx;
systemctl start mariadb;
systemctl enable mariadb;
#mariadb
vim /etc/my.cnf
[mysqld]
max_connections=65535
#sed -i "12amax_connections=65535" /etc/my.cnf
#nginx 运行php
vim /etc/nginx/conf.d/domain.conf
server {
server_name domain ;
root /home/domain/public_html;
#access_log /home/domain/logs/access.log main;
#error_log /home/domain/logs/error.log;
#rewrite ^(.*)$ https://$host$1 permanent;
location / {
proxy_connect_timeout 600s;
proxy_send_timeout 600;
proxy_read_timeout 600;
proxy_buffer_size 64k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_pass_header Set-Cookie;
proxy_redirect off;
proxy_hide_header Vary;
proxy_ignore_headers Cache-Control Expires;
proxy_set_header Referer $http_referer;
proxy_set_header Host $host;
proxy_set_header Cookie $http_cookie;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ^~ /.git/ {
return 404;
}
location ~* \.(log)$ {
return 404;
}
location ~ \.php$ {
fastcgi_read_timeout 600;
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
include fastcgi_params;
}
index index.html index.htm index.php;
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}