Skip to content

Instantly share code, notes, and snippets.

@bestpika
Last active March 28, 2018 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bestpika/b31203cf286ffc01e95e02af3bf75a7a to your computer and use it in GitHub Desktop.
Save bestpika/b31203cf286ffc01e95e02af3bf75a7a to your computer and use it in GitHub Desktop.
CentOS 6, 7

寫在前面

參考

指令

  • 服務

    • 開機
      • systemctl enable sth.service
      • chkconfig sth on
    • 重啟
      • systemctl restart sth.service
      • service sth restart
  • 防火牆

    • firewall-cmd --zone=public --permanent --list-all
    • firewall-cmd --zone=public --permanent --add-service=sth
    • firewall-cmd --zone=public --permanent --add-port=0/tcp
    • firewall-cmd --zone=public --permanent --add-port=0/udp
    • firewall-cmd --reload

掛載網路磁碟機

yum install samba-client samba-common cifs-utils
  • nano /etc/fstab
//domain/dir /target cifs defaults,dir_mode=0777,file_mode=0777,username=username,password=password 0 0
//domain/dir /target cifs defaults,dir_mode=0777,file_mode=0777,credentials=/root/credentials.txt 0 0

# 特殊用法
context=system_u:object_r:httpd_sys_rw_content_t:s0

MySQL

參考

5.7

  • 安裝前
yum install -y http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm # 7.x
yum install -y http://dev.mysql.com/get/mysql57-community-release-el6-7.noarch.rpm # 6.x
  • nano /etc/yum.repos.d/mysql-community.repo
[mysql56-community]
enabled=0
[mysql57-community]
enabled=1
  • 安裝
# 都可以
yum install -y mysql-community-server
yum install -y mysql
  • mysqld 開機、重啟
  • mysql 防火牆
grep "password" /var/log/mysqld.log # 讀暫時密碼
mysql -u root -p
set global validate_password_policy=0;
set global validate_password_length=3;
ALTER USER 'root'@'localhost' IDENTIFIED BY 'PASSWORD';

PHP

參考

5.6

  • CentOS 7.x
wget http://dl.fedoraproject.org/pub/epel/7/x86_64/Packages/e/epel-release-7-11.noarch.rpm
wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7*.rpm epel-release-7*.rpm
  • CentOS 6.x
wget http://dl.fedoraproject.org/pub/epel/6/x86_64/Packages/e/epel-release-6-8.noarch.rpm # x64
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm              # x86
wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
  • nano /etc/yum.repos.d/remi.repo
[remi]
enabled=1
[remi-php56]
enabled=1
  • nano /etc/yum.repos.d/epel.repo
baseurl
#mirrorlist
yum makecache
yum install -y php php-gd php-mysql php-mcrypt php-mbstring

SSH

yum install -y openssh openssh-server
  • nano /etc/ssh/sshd_config
Port 22                # 連接埠
AllowUsers USER1 USER2 # 允許登入使用者
PermitRootLogin no     # root 是否可登入
Protocol 2             # 通訊協定
  • sshd 開機、重啟
  • ssh 防火牆
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment