CentOS7搭建LNMP

CentOS7搭建LNMP

      • 首先更新系统软件
      • 安装nginx
          • 配置文件
      • 安装php7.2
          • 配置nginx
      • 安装MySQL5.7

首先更新系统软件

yum update

安装nginx

# 添加源 也可以不要这个
yum localinstall http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm 

# 安装
yum install nginx 

# 启动
service nginx start
配置文件

主配置文件:/etc/nginx/nginx.conf
默认配置文件:/etc/nginx/conf.d/default.conf


安装php7.2

# 添加源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

# 安装
yum install php72w php72w-cli php72w-common php72w-devel php72w-embedded php72w-fpm php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml

# 启动
systemctl php-fpm 
# 设置开机启动
systemctl enable php-fpm
配置nginx

新建 /etc/nginx/conf.d/localhost.conf

server {
        listen       80;
        server_name  localhost;
        root /www;
        access_log  /data/wwwlogs/localhost.access.log  main;
        location / {
                ssi on;
                index index.php index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
                root   html;
        }
        location ~ \.php$ {
                fastcgi_pass   127.0.0.1:9000;
                fastcgi_index  index.php;
                fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
                include        fastcgi_params;
                client_max_body_size 20m;
        }
}

安装MySQL5.7

# 添加源
yum localinstall  http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

# 安装
yum install mysql-community-server
yum install mysql-community-devel

# 启动
service mysqld start

# 获取mysql默认生成的密码
grep 'temporary password' /var/log/mysqld.log

# 更换密码
mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'new_password';

你可能感兴趣的:(原创,LNMP)