标签 centos 下的文章

从命令行更改wdcp面板的默认访问端口 - wdcp v3.2 - centos7

环境:CentOS 7,wdcp v3.2

本例是将默认的8080端口修改为3389,因为阿里云的默认ECS安全组允许tcp 3389。

过程:

1.echo 3389 > /www/wdlinux/wdcp/conf/port.conf # 远程连接到服务器,创建 port.conf 文件,内容是端口号,如3389

2.service wdcp restart # 重启wdcp服务,以让新端口生效

3.iptables -I INPUT -p tcp -m tcp --dport 3389 -j ACCEPT # 前插入一条iptables规则,允许外网访问3389端口

4.iptables-save # 保存iptblaes 规则

5.service iptables restart # 重启iptables服务

参考:

在 CentOS 7 重命名网卡为eth0

CentOS7默认是按如固件名、BIOS等信息来命名,如看惯,想用回eth0的,可以尝试。

过程:

1.ip link # 查看当前的网卡名,如本例是 enp0s20f0
rename-eth0-1.png

2.vi /etc/default/grub # 编辑启动参数,在 GRUB_CMDLINE_LINUX 尾,加上 net.ifnames=0 biosdevname=0
rename-eth0-2.png

3.grub2-mkconfig # 测试启动参数配置

4.grub2-mkconfig -o /boot/grub2/grub.cfg # 更新启动配置文件
rename-eth0-5.png

5.mv /etc/sysconfig/network-scripts/ifcfg-{enp0s20f0,eth0} # 改名网卡配置文件

6.sed -ire "s/NAME=\"enp0s20f0\"/NAME=\"eth0\"/" /etc/sysconfig/network-scripts/ifcfg-eth0 # 替换配置文件里的网卡名称

7.sed -ire "s/DEVICE=\"enp0s20f0\"/NAME=\"eth0\"/" /etc/sysconfig/network-scripts/ifcfg-eth0 # 替换配置文件里的设置名称

8.MAC=$(cat /sys/class/net/enp0s20f0/address) # 获取网卡的MAC地址
rename-eth0-3.png

9.echo -n 'HWADDR="'$MAC\" >> /etc/sysconfig/network-scripts/ifcfg-eth0 # 将网卡MAC地址写进配置文件里
rename-eth0-4.png

10.reboot # 重启测试,成功
rename-eth0-6.png

参考:

xfs_repair 修复 CentOS 7 Metadata corruption detected 启动失败问题

一VMware虚拟机,CentOS7系统,启动后未能成功进到系统,提示 Corruption of in-memory data detected, shutting down filesystem, please umount the filesystem and rectify the problem.

过程:

1.CentOS7启动失败,自动转到急救模式
xfs-repair-1.jpg

2.journalctl -xe # 查看错误日志,提示 /dev/mapper/cl-root 挂载失败
xfs-repair-2.png

3.mount /dev/mapper/cl-root /dmnt # 尝试手动挂载,失败。提示 Structure needs cleaning
xfs-repair-3.png

4.xfs_replair -L /dev/mapper/cl-root # 尝试重建
xfs-repair-4.png

5.init 6 # 重建log后,重启机子,正常了
xfs-repair-5.jpg

参考:

在 CentOS 7 通过 Software Collections 源安装 apache2.4 php5.6 mysql5.6

现在不少商家,默认选择 CentOS 7 系统,但里边默认的php版本是5.4的,已经不太适合一些新版本的程序要求了。

过程:

  1. yum install centos-release-scl # 安装 Software Collections 源
  2. yum install httpd24 # 安装 apache 2.4
  3. scl enable httpd24 bash
  4. service httpd24-httpd start # 启动 apache 2.4 服务
  5. yum install rh-php56 rh-php56-php rh-php56-php-gd rh-php56-php-mbstring rh-php56-php-mysqlnd rh-php56-php-pdo rh-php56-php-xml # 安装 php5.6 及相关
  6. scl enable rh-php56 bash
  7. yum install rh-mysql56 # 安装 mysql5.6
  8. scl enable rh-mysql56 bash
  9. service rh-mysql56-mysqld start # 启动 mysql 服务
  10. mysql_secure_installation # 修改mysql的默认空密码
  11. 上传一份 phpmyadmin 到 opt/rh/httpd24/root/var/www/html/ ,测试正常

参考:

阿里云公共镜像CentOS 7.3 64位yum安装源文件内容

因为昨晚看到“鬼才”说新创建的ECS实例,运行yum update的命令出错,提示文件未找到。

今天(2017-08-28)新创建的一个网络类型为“经典网络”的1GB ECS实例(未分配公网IP地址),测试结果如下:

a. 内核信息如下:Linux iZbp1e4mchw553gx59aygaZ 3.10.0-514.26.2.el7.x86_64 #1 SMP Tue Jul 4 15:04:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

b. 运行 yum update 命令正常

c. /etc/yum.repos.d 目录下有 CentOS-Base.repo 和 epel.repo 两个安装源文件,分别内容如下:

  [base]
  name=CentOS-$releasever - Base
  failovermethod=priority
  baseurl=http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
  gpgcheck=1

gpgkey=http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-7

released updates

[updates]
name=CentOS-$releasever - Updates
failovermethod=priority
baseurl=http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-7

additional packages that may be useful

[extras]
name=CentOS-$releasever - Extras
failovermethod=priority
baseurl=http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-7

additional packages that extend functionality of existing packages

[centosplus]
name=CentOS-$releasever - Plus
failovermethod=priority
baseurl=http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-7

contrib - packages by Centos Users

[contrib]
name=CentOS-$releasever - Contrib
failovermethod=priority
baseurl=http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyuncs.com/centos/RPM-GPG-KEY-CentOS-7

[epel]
name=Extra Packages for Enterprise Linux 7 - $basearch
baseurl=http://mirrors.aliyuncs.com/epel/7/$basearch
failovermethod=priority
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7

[epel-debuginfo]
name=Extra Packages for Enterprise Linux 7 - $basearch - Debug
baseurl=http://mirrors.aliyuncs.com/epel/7/$basearch/debug
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0

[epel-source]
name=Extra Packages for Enterprise Linux 7 - $basearch - Source
baseurl=http://mirrors.aliyuncs.com/epel/7/SRPMS
failovermethod=priority
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-7
gpgcheck=0