您的位置:首页 > 其它

contos7 使用yum快速 搭建lnmp 环境

2017-11-30 12:37 441 查看
1.安装 PHP
yum install php
yum install php-fpm
systemctl start php-fpm

2 安装 nginx 
yum install nginx
vim /etc/nginx/nginx.conf
打开nginx.conf 添加:

server {  

    listen       80;  

    server_name  localhost;  

    autoindex    on;  

    #charset koi8-r;  

    #access_log  /var/log/nginx/log/host.access.log  main;  

  

    location / {  

        root   /var/www/html;  

        index  index.html index.htm index.php;  

    }  

  

    location ~ \.php$ {  

        root           /var/www/html;  

        fastcgi_pass   127.0.0.1:9000;  

        fastcgi_index  index.php;  

        fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;  

        include        fastcgi_params;  

    }

3 安装MYSQL
1.下载YUM库

shell > wget http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm
2.安装YUM库

shell > yum localinstall -y mysql57-community-release-el7-7.noarch.rpm

3.安装数据库

shell > yum install -y mysql-community-server

4.启动MySQL服务

shell > systemctl start mysqld.service

5.默认空密码

shell > mysql -uroot -p

6.重置root密码后重启mysql服务

shell > update mysql.user set authentication_string=password("yourpassword") where user="root" and Host="localhost";

shell > flush privileges;

shell > quit;

shell > systemctl restart mysqld;

如果出现如下问题:

报错1:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

请修改my.cnf,添加skip-grant-tables

shell > vi /etc/my.cnf

[mysqld]

skip-grant-tables

报错2:ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.
解决办法:

1、 修改用户密码
mysql> alter user 'root'@'localhost' identified by 'youpassword';  
或者       
mysql> set password=password("youpassword");
2、刷新权限
mysql> flush privileges;

1、添加远程登录用户(登入Mysql)

use mysql;

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '你的密码' WITH GRANT OPTION;

注:'%'代表任意地址,也可以指定IP

2、检查用户表,刷新内存权限

select host, user from user;

FLUSH PRIVILEGES;

设置开机自启服务:
systemctl enable nginx
systemctl enable mysqld

开启防火墙:
systemctl start firewalld
firewall-cmd --zone=public --add-port=80/tcp --permanent    //设置需要开放的端口   permanent--表示永久生效
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: