Install EPEL On CentOS 7

Extra Packages for Enterprise Linux (or EPEL) is a Fedora Special Interest Group that creates, maintains, and manages a high quality set of additional packages for Enterprise Linux, including, but not limited to, Red Hat Enterprise Linux (RHEL), CentOS, Scientific Linux (SL), Oracle Linux (OL), AlmaLinux (AL) and Rocky Linux (RL).

CentOS 7

# yum install epel-release

ติดตั้งด้วย dnf (Install DNF On CentOS 7)

$ sudo dnf install epel-release

Install DNF On CentOS 7

DNF (short for “DaNdiFied Yum”) is the next upcoming major version of Yum, a package manager for RPM-based Linux distributions, such as RHEL, CentOS, and Fedora. DNF is first introduced in Fedora 18, and it has became the default package manager from Fedora 25 version. This brief tutorial will explain how to install DNF on CentOS 7 and RHEL 7 versions.

Install DNF On CentOS 7

$ sudo yum install dnf
$ dnf help

บางโปรแกรมเช่น neofetch อยู่ใน dnf-plugins-core ต้องติดตั้ง dnf-plugins-core แล้วก็ enable ก่อน ถึงจะติดตั้งได้

$ sudo yum install neofetch
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base:
 * epel:
 * extras:
 * updates:
No package neofetch available.
Error: Nothing to do

ติดตั้ง dnf-plugins-core

$ sudo yum install dnf-plugins-core

Enable COPR repository

$ sudo dnf copr enable konimex/neofetch

เสร็จแล้วค่อยติดตั้ง neofetch อีกครั้งก็จะได้ละ

$ sudo dnf install neofetch

Add User to Sudoers in CentOS

The sudo command stands for “Super User DO” and temporarily elevates the privileges of a regular user for administrative tasks.

Step 1: Verify the Wheel Group is Enabled

Your CentOS 7 installation may or may not have the wheel group enabled.

Open the configuration file by entering the command:

# visudo

Scroll through the configuration file until you see the following entry:

## Allows people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL

If the second line begins with the # sign, it has been disabled and marked as a comment. Just delete the # sign at the beginning of the second line.

Step 2: Add User to Group

To add a user to the wheel group, use the command:

# usermod –aG wheel <username>

Step: 3 Switch to the Sudo User

Switch to the new (or newly-elevated) user account with the su (substitute user) command:

su - <username>

Install Latest Git ( Git 2.x ) on CentOS 7

Start by checking installed version of git on your CentOS 7 server.

$ git --version
git version

Install Latest git on CentOS 7 from End Point repository

sudo yum -y remove git
sudo yum -y remove git-*

Add End Point CentOS 7 repo

sudo yum -y install
sudo yum install git

Check git version after installing git2u-all package

$ git --version
git version 2.30.1

ติดตั้ง MySql บน CentOS 7


ไปที่ MySQL Community Downloads แล้วเลือก MySQL Yum Repository

แล้วดาว์นโหลดไฟล์ mysql80-community-release-el7-3.noarch.rpm

ถ้าใช้ไฟล์ mysql80-community-release-el7-5.noarch.rpm ก็เป็น mysql57


sudo rpm -ivh mysql80-community-release-el7-3.noarch.rpm


sudo yum-config-manager --disable mysql80-community
sudo yum-config-manager --enable mysql56-community

หรือ เลือก enabled=1 ที่ไฟล์ /etc/yum.repos.d/mysql-community.repo

ตรวจสอบว่า enabled ถูกเวอร์ชันมั๊ย

yum repolist enabled | grep mysql 
sudo yum install mysql-server
-- OR --
sudo yum install mysql-community-server

Starting MySQL

sudo systemctl start mysqld
sudo systemctl status mysqld

uring the installation process, a temporary password is generated for the MySQL root user. Locate it in the mysqld.log with this command:

sudo grep 'temporary password' /var/log/mysqld.log

Configuring MySQL

sudo mysql_secure_installation

ติดตั้ง Visual Studio Code บน CentOS 7

อัพเดท repository

sudo rpm --import
sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=\nenabled=1\ngpgcheck=1\ngpgkey=" > /etc/yum.repos.d/vscode.repo'

ติดตั้ง code

yum check-update
sudo yum install code

เรียกใช้ code

code &


code . &

ติดตั้ง Python3 บน CentOS 7

เดิม CentOS7 จะติดตั้ง Python 2.7.5 มาให้

ติดตั้งจาก Package Manager

อัพเดท repo

$ sudo yum update

ติดตั้ง Python3

$ sudo yum install -y python3


$ python3 --version
Python 3.6.8
$ pip3 --version
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)
$ python3 -m pip --version
pip 9.0.3 from /usr/lib/python3.6/site-packages (python 3.6)

ติดตั้งผ่าน Package Manager จะได้ Python3.6 ติดตั้งอยู่ที่ /usr/bin/python3.6

ติดตั้งเวอร์ขันที่ต้องการจาก Source Code

ติดตั้ง required packages and dependencies

sudo yum groupinstall "Development Tools" -y
sudo yum install gcc open-ssl-devel bzip2-devel libffi-devel -y
sudo yum install zlib-devel

ดาว์นโหลดเวอร์ชัน 3.7.12 (04-Sep-2021)

tar xzf Python-3.7.12.tgz


cd Python-3.7.12
./configure --with-openssl=/home/[username]/openssl
./configure --enable-optimizations
sudo make altinstall

Python3.7 จะติดตั้งอยู่ที่ /usr/local/bin

กำหนด default python ให้เป็น Python3.7

sudo ln -fs /usr/local/bin/python3.7   /usr/bin/python3
sudo ln -fs /usr/local/bin/pydoc3.7    /usr/bin/pydoc3
sudo ln -fs /usr/local/bin/pyvenv-3.7  /usr/bin/pyvenv3
sudo ln -fs /usr/local/bin/pip3.7      /usr/bin/pip3



print("Hello World!")

เปลี่ยน permission

chmod 755



เรื่องของ yum กับ Python3

ถ้าเซ็ตให้คำสั่ง python ชี้ไปที่ python3.7

sudo ln -fs /usr/local/bin/python3.7   /usr/bin/python   

จะใช้คำสั่ง yum ไม่ได้ โดยจะ error ประมาณนี้

$ sudo yum install tree
  File "/bin/yum", line 30
    except KeyboardInterrupt, e:
SyntaxError: invalid syntax

Because yum does not support Python3.

ให้แก้ไขไฟล์ /bin/yum จาก !/usr/bin/python เป็น !/usr/bin/python2 ก็จะรัน yum ได้ (แต่อาจเจอปัญหาอื่นตามมาอีก – เปลี่ยน default python กลับไปที่ python2 ดีกว่า)

อัพเดท pip


$ pip3 --version
pip 20.1.1 from /usr/local/lib/python3.7/site-packages/pip (python 3.7)

ไม่แน่ใจว่า require openssl openssl-devel กับ epel-release มั๊ย

sudo yum install openssl openssl-devel
sudo yum install epel-release

ตรวจสอบโมดูล ssl ถ้าปกติรัน python3 -m ssl แล้วจะไม่มีอะไรเกิดขึ้น

python3 -m ssl

อัพเดท pip

python3 -m pip install --upgrade pip


$ pip3 --version
pip 21.2.4 from /home/jack/.local/lib/python3.7/site-packages/pip (python 3.7)

ติดตั้ง Chrome บน CentOS 7

1. Downloading the latest Google Chrome .rpm package


2. Install Google Chrome on your CentOS 7 system

sudo yum localinstall google-chrome-stable_current_x86_64.rpm

3. Starting Google Chrome

google-chrome &

Start Google Chrome by clicking on the Google Chrome icon (Applications → Internet → Google Chrome):

ติดตั้ง SQL Server 2017 บน CentOS 7

Install SQL Server 2017

1.Download the Microsoft SQL Server 2017 Red Hat repository configuration file:

sudo curl -o /etc/yum.repos.d/mssql-server.repo

2.Run the following commands to install SQL Server:

sudo yum install -y mssql-server

3.After the package installation finishes, run mssql-conf setup and follow the prompts to set the SA password and choose your edition.

sudo /opt/mssql/bin/mssql-conf setup

4.Once the configuration is done, verify that the service is running:

systemctl status mssql-server

5.To allow remote connections, open the SQL Server port on the firewall on RHEL. The default SQL Server port is TCP 1433. If you are using FirewallD for your firewall, you can use the following commands:

sudo firewall-cmd --zone=public --add-port=1433/tcp --permanent
sudo firewall-cmd --reload

Install the SQL Server command-line tools

1.Download the Microsoft Red Hat repository configuration file.

sudo curl -o /etc/yum.repos.d/msprod.repo

2.If you had a previous version of mssql-tools installed, remove any older unixODBC packages.

sudo yum remove unixODBC-utf16 unixODBC-utf16-devel

3.Run the following commands to install mssql-tools with the unixODBC developer package. For more information, see Install the Microsoft ODBC driver for SQL Server (Linux).

sudo yum install -y mssql-tools unixODBC-devel

4.For convenience, add /opt/mssql-tools/bin/ to your PATH environment variable. This enables you to run the tools without specifying the full path. Run the following commands to modify the PATH for both login sessions and interactive/non-login sessions:

echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bash_profile
echo 'export PATH="$PATH:/opt/mssql-tools/bin"' >> ~/.bashrc
source ~/.bashrc
echo $PATH

Connect locally

1.Run sqlcmd with parameters for your SQL Server name (-S), the user name (-U), and the password (-P).

sqlcmd -S localhost -U SA -P '<YourPassword>'

Create and query data

Create a new database

1.From the sqlcmd command prompt, paste the following Transact-SQL command to create a test database:


2.On the next line, write a query to return the name of all of the databases on your server:

SELECT Name from sys.Databases

3.The previous two commands were not executed immediately. You must type GO on a new line to execute the previous commands:


Exit the sqlcmd command prompt


ติดตั้ง vsftpd บน CentOS 7

Step 1: Install FTP Service with VSFTPD

1.Start by updating the package manager:

sudo yum update

2.Install VSFTPD software 

sudo yum install vsftpd

3. Start the service and set it to launch when the system boots with the following:

sudo systemctl start vsftpd
sudo systemctl enable vsftpd

4. Next, create a rule for your firewall to allow FTP traffic on Port 21

sudo firewall-cmd --zone=public --permanent --add-port=21/tcp
sudo firewall-cmd --zone=public --permanent --add-service=ftp
sudo firewall-cmd --reload

Step 2: Configuring VSFTPD

1. Before starting, create a copy of the default configuration file:

sudo cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.default

2. Next, edit the configuration file 

sudo nano /etc/vsftpd/vsftpd.conf

3. Set your FTP server to disable anonymous users and allow local users


4. Next, allow a logged-in user to upload files to your FTP server.


5. Limit FTP users to their own home directory. This is often called jail or chroot jail. Find and adjust the entry to match the following: