centos 7 配置lnmp

个人觉得步骤比较详细,不一定要所有的都执行一遍。

1、yum安装epel-release第三方软件包

yum install epel-release

2、要验证EPEL仓库是否建立成功

yum repolist

3、安装php5.6.31

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm 
yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-fpm php-redis php-gd

4、设置时区

vim /etc/php.ini
#date.timezone = "Asia/Shanghai"

5、设置php-fpm运行用户组

vim /etc/php-fpm.d/www.conf
#user = nginx
#group = nginx
#listen = 127.0.0.1:9000   前面;去掉
#listen.owner = nobody    前面;去掉
#listen.group = nobody    前面;去掉
#listen.mode = 0660          前面;去掉

6、安装nginx

yum list nginx
yum install nginx

7、启动nginx

systemctl start  nginx.service
systemctl status nginx.service
systemctl enable nginx.service

8、启动php-fpm

systemctl start  php-fpm.service
systemctl status php-fpm.service
systemctl enable php-fpm.service

9、安装mysql5.7.20

wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm


10安装mysql源

yum localinstall mysql57-community-release-el7-8.noarch.rpm

11、安装mysql server

yum install mysql-community-server

12、启动mysqld

systemctl start mysqld
systemctl status mysqld
systemctl enable mysqld

13、查看临时密码

grep 'A temporary password' /var/log/mysqld.log
 //A temporary password is generated for root@localhost: BaSi;aAua1Ri

14、登录设置root新密码

mysql数据库文件存放路径:var/lib/mysql
alter user 'root'@'localhost' identified by 'Abc#123!';

15、查看mysql版本

->status;

16、新建用户

create user huirong identified by 'huirongAbc#123';

17、安装redis3.2.10

yum list redis
yum install redis

18、启动redis

systemctl start redis.service
systemctl status redis.service
systemctl enable redis.service

19查看redis版本

redis-cli 
->info 

20、创建数据库脚本提示:sql_mode=only_full_group_by的问题

vim /etc/my.cnf
在socket=/var/lib/mysql/mysql.sock下面添加 
sql_mode=STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

NGINX conf配置

server {
   
   listen       80;
    server_name  127.0.0.1;
   root        /home/www/wwwroot/;
   access_log  /home/www/logs/access.log  main;
   error_log   /home/www/logs/error.log;

    location /{
        index  index.php index.html index.htm;
      
        if (!-e $request_filename){
            rewrite ^/(.*)$ /index.php/$1 last;
        }
    }
    
    error_page   500 502 503 504  /50x.html;
    error_page   404 /404.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
   
   location ~ \.php($|/) {

        fastcgi_pass  127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_split_path_info ^(.+\.php)(.*)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        include       fastcgi_params;
    }

    location ^~ /views|controllers|config|upload|static|logs|libs {
        deny all;
    }
   
}

 

posted @ 2018-12-06 16:15  飞翔的贺兰猪  阅读(137)  评论(0编辑  收藏  举报