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

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
```

上一篇:ER同步中NTP的配置方法


下一篇:linux把邮件停止,CentOS Linux release 7 安装完成后停止几个服务