本文共 1174 字,大约阅读时间需要 3 分钟。
下载并安装NGINX
wget http://nginx.org/packages/mainline/centos/7/x86_64/RPMS/nginx-1.13.9-1.el7_4.ngx.x86_64.rpmrpm -ivh nginx-1.13.9-1.el7_4.ngx.x86_64.rpmsystemctl enable nginxsystemctl start nginx
下载并安装MYSQL
wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpmrpm -ivh mysql57-community-release-el7-11.noarch.rpmyum install -y mysql-serversystemctl enable mysqldsystemctl start mysqld
下载并安装PHP
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpmyum --enablerepo=remi,remi-php72 install php php-common php-cli php-fpm php-pdo php-bcmath php-mysqlnd php-mbstring php-mcrypt php-gd php-dom php-xml php-zipchmod 777 -R /var/lib/php/sessionsystemctl enable php-fpmsystemctl start php-fpm
开启PHP缓存 - 修改php.ini中:
realpath_cache_size = 4096krealpath_cache_ttl = 120
开启NGINX的GZIP并隐藏版本号 - 修改nginx.conf中:
server_tokens off;gzip on;gzip_min_length 20k;gzip_buffers 4 16k;gzip_comp_level 4;gzip_types text/plain text/css text/javascript application/x-javascript application/xml application/x-httpd-php;server { listen 80 default; return 444;}
说明:优化仅针对低配服务器,是最简易的优化,可明显提升运行效率,配置不高的服务器不要过分优化,否则反而会增加服务器压力。
转载地址:http://peino.baihongyu.com/