Centos 8 安装 Nginx Jdk Mysql Redis PHP开发常用工具

系统安装

安装说明:

下载地址:https://mirrors.aliyun.com/centos/

。建议下载 *.minimal.iso即可

  • 建议英文安装
  • 时区选择中国上海
  • 硬盘分区默认auto就可以(auto模式,空间都给了跟目录)
  • 网卡建议设置好,一定要设置成on
  • 这个文章是8.2版本写的,最新的8.3、 8.4 、8.5都适用的

常用操作

WEB管理平台Cockpit

centos8一个改变就是提供了一个web界面管理服务器,这个web服务名称叫Cockpit。 开启命令

systemctl start cockpit.socket
systemctl enable cockpit.socket
可以在浏览器中运行 http://ip:9090

常用命令安装

– netstat 命令安装

dnf install net-tools

时间同步

如果没有安装 请运行 dnf install chrony

vi /etc/chrony.conf

更改时区
timedatectl set-timezone Asia/Shanghai
注释掉
pool 2.centos.pool.ntp.org iburst
加入新的的时间服务器
server 182.92.12.11 iburst
server ntp.aliyun.com iburst


重启服务
systemctl restart chronyd.service
此时时间已经与网络时间同步
设置开机自启
systemctl enable chronyd.service

手工同步一下
chronyc sources -v
离线Rpm包获取
  • 离线包下载,比如mysqld dnf install mysql-server --downloadonly
  • 离线包目录 /var/cache/dnf里面的 /var/cache/dnf/BaseOS-??/packages 或 /var/cache/dnf/AppStream-??/packages
  • 离线安装RPM先运行 rpm --import /etc/pki/rpm-gpg/RPM* 否则提示key错误等

安全设置

Selinue配置(建议关闭)
临时关闭
# 临时关闭
setenforce 0
永久关闭方案
  • 编辑 /etc/sysconfig/selinux
  • SELINUX=enforcing 改为 SELINUX=disabled
防火墙配置
# 开启开机启动/关闭
systemctl enable firewalld.service
systemctl disable firewalld.service
#打开/关闭/重启命令
systemctl start firewalld.service
systemctl stop firewalld.service
systemctl restart firewalld.service
#查询状态
systemctl status firewalld.service

#-----常用配置-----
#单个端口开放
firewall-cmd --zone=public --add-port=80/tcp --permanent
#每次修改都要重新载入
firewall-cmd --reload
#移除开放的端口则端口会被限制
firewall-cmd --zone=public --remove-port=80/tcp --permanent
firewall-cmd --reload
#查看所有开放成功的端口
firewall-cmd --zone=public --list-ports

常用软件安装配置

Redis
安装
# 在线安装
dnf install redis
# 离线安装 
rpm -ivh redis-5.0.3-2.module_el8.2.0+318+3d7e67ea.x86_64.rpm.rpm
配置

默认配置就可以仅限127.0.0.1访问,无密码

启动
# 设置开机启动/关闭
systemctl enable redis.service
systemctl disable redis.service
#打开/关闭/重启命令
systemctl start redis.service
systemctl stop redis.service
systemctl restart redis.service
#查询状态
systemctl status redis.service
Mysql
安装
# 自动安装mysql客户端
dnf install mysql-server
配置

/etc/my.cnf 和 /etc/my.cnf.d/

#参考配置如下
#配置客户端
[mysql]
# 设置mysql客户端默认字符集
default-character-set=utf8
#配置服务端
[mysqld]
default_time_zone = "+8:00"
#绑定IPV4,如果是v6填写 ::
bind-address=0.0.0.0
#设置3306是默认端口
port = 3316
# 允许最大连接数
max_connections=2000
# 用户连接数
max_user_connections=1000
# 服务端使用的字符集
character-set-server=utf8
# 创建新表时将使用的默认存储引擎
default-storage-engine=INNODB
#临时表空间,特别是设置MEMORY类型的表
tmp_table_size=500M
max_heap_table_size=500M
#日志的时间
log_timestamps=SYSTEM
#关闭x插件 关闭默认33060端口
mysqlx=0 


#如果是mysql专属服务器,那就是内存的80%
innodb_buffer_pool_size = 2048M
innodb_buffer_pool_instances = 4


# 根据您的服务器IOPS能力适当调整
# 一般配普通SSD盘的话,可以调整到 10000 - 20000
# 配置高端PCIe SSD卡的话,则可以调整的更高,比如 50000 - 80000
innodb_io_capacity = 4000
innodb_io_capacity_max = 8000

/etc/my.cnf.d/mysql-default-authentication-plugin.cnf 已经约定 default_authentication_plugin=mysql_native_password

仅仅修改端口也是可以的,其它可以不修改。在 /etc/my.cnf.d/mysql-server.cnf 文件中的 [mysqld] 添加 port = 3316

修改端口不成功的时候,看看selinue是否关闭了。

启动
# 开启开机启动/关闭
systemctl enable mysqld.service
systemctl disable mysqld.service
#打开/关闭/重启命令
systemctl start mysqld.service
systemctl stop mysqld.service
systemctl restart mysqld.service
#查询状态
systemctl status mysqld.service
常用命令
# 默认root密码是空,运行如下命令进入
mysql -h localhost -P 3306 -u root -p

进入Mysql控制台

-- 修改Root密码
ALTER USER `root`@`localhost` IDENTIFIED BY '*****';
-- 创建一个远程管理员(mysql8必须两步进行)
CREATE USER newroot IDENTIFIED BY '******';
GRANT ALL PRIVILEGES ON *.* TO 'newroot'@'%' WITH GRANT OPTION;
Nginx(1.6)
安装
# 在线安 nginx 先看看什么版本
dnf module list nginx
dnf module install nginx:1.18
# 离线安装包(下载好安装离线包)
rpm -Uvh *.rpm --nodeps --force
配置

/etc/nginx/nginx.conf

 ..
启动
 # 设置开机启动/关闭
systemctl enable nginx
systemctl disable nginx
#打开/关闭/重启命令
systemctl start nginx
systemctl stop nginx
systemctl restart nginx
#查询状态
systemctl status nginx
PHP (7.3)
安装
dnf module list php
# 采用模块安装7.3版本,centos带了多个版本,看实际情况
dnf module install php:7.3
配置

/etc/php.ini

配置文件内容
Jdk (OpenJdk)
安装
# 在线安装
dnf install java-11-openjdk
# 离线安装包(下载好安装离线包)
rpm -Uvh *.rpm --nodeps --force
# 查询是否安装成功
java -version 
  • 5
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值