centos7 安装php7+mysql5.7+nginx+redis

centos7 安装php7+mysql5.7+nginx+redis,第1张

概述1.先修改yum源https://webtatic.comrpm-Uvhhttps://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmrpm-Uvhhttps://mirror.webtatic.com/yum/el7/webtatic-release.rpmrpm-Uvhhttp://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

1.先修改yum源 https://webtatic.com
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


2.安装Nginx
yum install Nginx

3.安装MysqL5.7
yum -y install MysqL-community-server

4.安装PHP
 yum 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


5.开始简单MysqLd的配置
 5.1添加运行目录
  mkdir -p /var/run/MysqLd/
  chown MysqL.MysqL /var/run/MysqLd/

5.2MysqL 配置    
vim /etc/my.cnf

5.3在 [MysqLd] 下面添加
character_set_server=utf8
init_connect='SET nameS utf8'

collation-server=utf8_general_ci
esc返回 :wq命令 保存退出

直接改配置文件:
# For advice on how to change settings please see
# http://dev.MysqL.com/doc/refman/5.7/en/server-configuration-defaults.HTML

[MysqLd]
character_set_server=utf8
init_connect='SET nameS utf8'

collation-server=utf8_general_ci
# Remove leading # and set to the amount of RAM for the most important data
# cache in MysqL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
datadir=/var/lib/MysqL
socket=/var/lib/MysqL/MysqL.sock

# disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0

log-error=/var/log/MysqLd.log
pID-file=/var/run/MysqLd/MysqLd.pID


重启服务器······

5.3启动MysqL
service MysqLd start

5.4 启动MysqL状态(出现pID证明启动成功)
service MysqLd status

5.5 查看MysqL初始密码
grep 'temporary password' /var/log/MysqLd.log

5.6 设置MysqL
登陆(输入账号和密码回车):MysqL -uroot -p

修改MysqL密码:(如果密码太过于简单可能不然修改因为MysqL默认设置了密码复杂度 至少8位 必须包含 大小写字母数字及符号)
alter user root@localhost IDentifIEd by 'Tangjuyi0.';


5.7 添加一个可以在外部登陆的MysqL用户(%为白名单IP):
grant all privileges on *.* to root @"%" IDentifIEd by "Rj06221.";
flush privileges; 

退出:quit
6 配置Nginx:
Nginx可以的默认配置文件一般在: /etc/Nginx/Nginx.conf
Nginx会引用 建立我们自己的配置文件
vim /etc/Nginx/conf.d/user.conf

6.1 设置项目访问域名指向
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;
}
}

7 启动PHP   systemctl restart PHP-fpm 
8 启动Nginx  systemctl restart Nginx
9 启动MysqL   systemctl restart MysqLd

10 设置 MysqL PHP Nginx 自动启动
systemctl enable redis
systemctl enable PHP-fpm
systemctl enable MysqLd
systemctl enable Nginx


12.阿里云设置防火墙
安全组==》配置规则==》添加规则
协议类型:全部
端口类型:-1/1
优先级:1
授权类型:地段访问
授权对象:0.0.0.0/0
```

总结

以上是内存溢出为你收集整理的centos7 安装php7+mysql5.7+nginx+redis全部内容,希望文章能够帮你解决centos7 安装php7+mysql5.7+nginx+redis所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/langs/1000424.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-21
下一篇 2022-05-21

发表评论

登录后才能评论

评论列表(0条)

保存