- 命令补全
[root@server ~]# yum install -y epel-release bash-completion
安装完成后重新登录生效。
- 查看系统版本
[root@server ~]# cat /etc/redhat-release
- 查看、修改系统名称
[root@server ~]# hostnamectl
[root@server ~]# hostnamectl set-hostname server
[root@server ~]# vi /etc/hosts
- 安装 nginx
[root@server ~]# cd /etc/yum.repos.d/
[root@server yum.repos.d]# vi nginx.repo
[root@server yum.repos.d]# cat nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
[root@server yum.repos.d]# yum install nginx
[root@server ~]# systemctl enable nginx
[root@server ~]# systemctl start nginx
- 安装 OpenResty
[root@server ~]# wget https://openresty.org/package/centos/openresty.repo
[root@server ~]# sudo mv openresty.repo /etc/yum.repos.d/
[root@server ~]# sudo yum check-update
[root@server ~]# sudo yum install openresty
- 防火墙配置
可参考 5 分钟理解防火墙 firewalld 了解更多信息。
[root@server ~]# firewall-cmd --permanent --zone=public --add-service=http
[root@server ~]# firewall-cmd --reload
[root@server ~]# cat /etc/firewalld/zones/public.xml
<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
<service name="ssh"/>
<service name="dhcpv6-client"/>
<service name="http"/>
</zone>
- 安装 OpenJDK 1.8
[root@server ~]# yum install java-1.8.0-openjdk-devel
- 安装 Oracle JDK 1.8
- 从 Java SE - Download 下载最新的
rpm
格式的安装包,例如:jdk-8u192-linux-x64.rpm
。 - 使用 Xftp 6 上传到服务器。
- 从 Java SE - Download 下载最新的
[root@server ~]# yum install jdk-8u192-linux-x64.rpm
[root@server ~]# java -version
- 安装 Redis 6
[root@server ~]# wget http://download.redis.io/releases/redis-6.0.6.tar.gz
- 安装 MySQL 8.0
[root@server ~]# wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
[root@server ~]# rpm -ivh mysql80-community-release-el7-1.noarch.rpm
[root@server ~]# yum install mysql-community-server
[root@server ~]# systemctl enable mysqld.service
[root@server ~]# systemctl start mysqld
[root@server ~]# grep 'temporary password' /var/log/mysqld.log
[root@server ~]# mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
mysql> CREATE USER 'user'@'%' IDENTIFIED BY 'MyNewPass4!';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'user'@'%' WITH GRANT OPTION;
mysql> quit
[root@server ~]# firewall-cmd --permanent --zone=public --add-service=mysql
[root@server ~]# firewall-cmd --reload
[root@server ~]# cat /etc/firewalld/zones/public.xml
<?xml version="1.0" encoding="utf-8"?>
<zone>
<short>Public</short>
<description>For use in public areas. You do not trust the other computers on networks to not harm your computer. Only selected incoming connections are accepted.</description>
<service name="ssh"/>
<service name="dhcpv6-client"/>
<service name="http"/>
<service name="https"/>
<service name="mysql"/>
</zone>