Centos7YUM快速搭建LNMP环境并简易优化

  1. 云栖社区>
  2. 博客>
  3. 正文

Centos7YUM快速搭建LNMP环境并简易优化

数源 2018-03-04 17:05:23 浏览1134
展开阅读全文

下载并安装NGINX

wget http://nginx.org/packages/mainline/centos/7/x86_64/RPMS/nginx-1.13.9-1.el7_4.ngx.x86_64.rpm
rpm -ivh nginx-1.13.9-1.el7_4.ngx.x86_64.rpm
systemctl enable nginx
systemctl start nginx

下载并安装MYSQL

wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
yum install -y mysql-server
systemctl enable mysqld
systemctl start mysqld

下载并安装PHP

yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
yum --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-zip
chmod 777 -R /var/lib/php/session
systemctl enable php-fpm
systemctl start php-fpm

开启PHP缓存 - 修改php.ini中:

realpath_cache_size = 4096k
realpath_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;
}

说明:优化仅针对低配服务器,是最简易的优化,可明显提升运行效率,配置不高的服务器不要过分优化,否则反而会增加服务器压力。

网友评论

登录后评论
0/500
评论
数源
+ 关注