CentOS 6.x 7.x yum安装nginx1.12-php7-mysql5.7环境

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/q85795362/article/details/79281708

1.安装nginx

修改yum源

vim /etc/yum.repos.d/nginx.repo
##################写入如下源内容#######################
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1


查看yum源中的nginx版本

yum list nginx


安装nginx

yum -y install nginx

查看安装的版本是否为1.12

nginx -v


打开80端口

################################ CentOS7
############## 查看防火墙状态   running为运行
firewall-cmd --state
systemctl status firewalld
############## 查看已经开放的端口
firewall-cmd --list-ports
############## 查看已经开放的服务
firewall-cmd --zone=public --list-service
############## 永久开启80端口 
firewall-cmd --zone=public --add-port=80/tcp --permanent
############## 删除一个端口
firewall-cmd --zone=public --remove-port=80/tcp --permanent
############## 使新增配置生效
firewall-cmd --reload
############## 停止firewall防火墙
systemctl stop firewalld
############## 启动firewall防火墙
systemctl start firewalld
############## 禁止firewall防火墙开机启动
systemctl disable firewalld
############## 启用开机自启动
systemctl enable firewalld
############## 查看自启动状态
systemctl is-enabled firewalld

########################## CentOS6
### 查看防火墙状态
service iptables status
### 开启80端口
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
### 保存修改
/etc/rc.d/init.d/iptables save
### 重启防火墙
service iptables restart
### 停止防火墙
service iptables stop
### 永久关闭防火墙
chkconfig iptables off

启动nginx

service nginx start
#重启
service nginx restart
#停止
service nginx stop

设置开机启动

nginx配置文件在 /etc/nginx/conf.d 里面

chkconfig nginx on

2.安装php

安装php yum源

#################### CentOS 6
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

#################### CenOS 7
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

入报以下错误


请键入如下代码

############################ CentOS 7
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

############################ CentOS 6
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -ivh epel-release-6-8.noarch.rpm
rpm -ivh remi-release-6.rpm

再进行第一步操作

修改yum源

vim /etc/yum.repos.d/remi.repo

[remi] 段中的 enabled=0 改为 enabled=1


/etc/yum.repos.d下面有php54/php70/php71/php72安装哪个就修改哪个

我这里安装php71

vim /etc/yum.repos.d/remi-php71.repo

[remi-php71] 段中的 enabled=0 改为 enabled=1


查看将要yum安装的php版本

yum list php


安装php及一些常用扩展

yum -y install php php-fpm php-cli php-pdo php-mysql php-gd php-bcmath php-xml php-mbstring php-mcrypt php-redis

查看php版本及扩展

# 版本
php -v
# 扩展
php -m

修改php配置

vim /etc/php.ini
# 时区修改
date.timezone = PRC
# 上传文件大小修改
upload_max_filesize = 20M
# 提交文件大小
post_max_size = 20M
# 隐藏 HTTP Header 中的php信息
expose_php = Off
# 打开php错误提示
display_errors = On

启动php-fpm

# 启动
service php-fpm start
# 重启
service php-fpm restart
# 停止
service php-fpm stop

设置开机启动

chkconfig php-fpm on

3.安装mysql

########################  CenOS 6

## 下载yum源
wget http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm
## rpm安装yum源
rpm -Uvh mysql57-community-release-el6-7.noarch.rpm
## 编辑yum源文件
vim /etc/yum.repos.d/mysql-community.repo

确认 [mysql57-community] 下面的 enable1

##安装 mysql
yum -y install mysql-community-server

######################## CentOS 7

## 下载yum源
wget http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
rpm -ivh mysql57-community-release-el7-11.noarch.rpm
## 安装mysql
yum -y install mysql-community-server

启动mysql

service mysqld start

查看自动生成的密码

grep "password" /var/log/mysqld.log



root@localhost:后面即为随机的密码 delsqxooB5>g

修改初始密码

mysql_secure_installation


先输入随机密码,然后进行新密码的修改

新密码必须含有 大小写字母数字和字符

登录看是否修改成功

设置mysql开机自启

chkconfig mysqld on


mysql的配置文件默认在 /etc/my.cnf

猜你喜欢

转载自blog.csdn.net/q85795362/article/details/79281708