centos 7 yum命令安装 Nginx、PHP 7、MySQL 57 、redis

前端之家收集整理的这篇文章主要介绍了centos 7 yum命令安装 Nginx、PHP 7、MySQL 57 、redis前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

修改yum源

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

rpm -Uvh http://dev.MysqL.com/get/MysqL57-community-release-el7-9.noarch.rpm

安装Nginx

yum -y install Nginx

安装PHP

yum -y install PHP70w-devel PHP70w.x86_64 PHP70w-pecl-redis PHP70w-cli.x86_64 PHP70w-common.x86_64 PHP70w-gd.x86_64 PHP70w-ldap.x86_64 PHP70w-mbstring.x86_64 PHP70w-mcrypt.x86_64 PHP70w-pdo.x86_64 PHP70w-MysqLnd PHP70w-fpm PHP70w-opcache

安装MysqL

yum -y install MysqL-community-server

安装redis

yum -y install redis

修改Nginx配置文件

vi etc/Nginx/Nginx.conf

去掉原有的的

server {

}配置

新建Nginx配置文件

vi /etc/Nginx/conf.d/user.conf

server {

listen 80;#端口

server_name admin.com www.admin.com; # 域名


root /home/www/web/newomcat/admin; # 网站根目录

index index.PHP index.html index.htm;#默认的index


# 建议放内网

# allow 192.168.0.0/24;

# deny all;


location / {


if (!-e $request_filename) {

rewrite ^/(.*)$ /index.PHP?$1 last;#去除url中的index.PHP 不需要可以不写


}



}


location ~ \.PHP$ {

try_files $uri = 404;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.PHP;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

include fastcgi_params;

}

}


MysqL 配置

vi /etc/my.cnf

在[client] 下面添加

default-character-set=utf8

在 [MysqLd] 下面添加

character_set_server=utf8

init_connect='SET NAMES utf8'

collation-server=utf8_general_ci


获取MysqL初始密码

grep 'temporary password' /var/log/MysqLd.log

修改初始密码

alter user root@localhost identified by 'testTest!'

添加一个可以在外部登陆的MysqL用户

grant all privileges on *.* to 创建的用户名 @"%" identified by "密码";


相关的启动命令

systemctl restart PHP-fpm #启动PHP

systemctl restart Nginx #启动Nginx

systemctl restart MysqLd #启动MysqL

sudo redis-server /etc/redis.conf #启动redis

原文链接:https://www.f2er.com/centos/375797.html

猜你在找的CentOS相关文章