Linux Server Configuration
Linux Server Configuration
7. Once you’re finished editing the configuration file, save your changes. Restart the vsftpd service to
apply changes:
sudo systemctl restart vsftpd
This creates a home/testuser directory for the new user, with a special directory for uploads. It sets permissions
for uploads only to the /uploads directory.
4. Now, you can log in to your FTP server with the user you created:
ftp 192.168.01
We will install qemu-kvm and qemu-img packages at first. These packages provide the user-level KVM and disk
image manager.
# yum install qemu-kvm qemu-img
After restarting the daemon, then check its status by running following command.
Although virt-manager is a GUI based tool, we also could launch/start it from terminal as well as from GUI.
#virt-manager
Let’s return to our localhost, before creating new virtual machine you should decide where will the files be
stored?! in other words, you should create the Volume Disk (Virtual disk / Disk image ) for your virtual machine.
By Right clicking on localhost and selecting “Details” and then select “Storage” tab.
Next, press “New Volume” button, then enter the name of your new virtual disk (Volume Disk) and enter the size
which you want/need in the “Max Capacity” section.
The allocation size is the actual size for your disk which will be allocated immediately from your
physical disk after finishing the steps.
Note: This is an important technology in storage administration field which called “thin provision”. It
used to allocate the used storage size only, NOT all of available size.
You will note that a label of the new Volume Disk has been appeared in the list.
You should also notice the path of the new disk image (Volume Disk), by default it will be under
/var/lib/libvirt/images, you can verify it using the following command.
# ls -l /var/lib/libvirt/images
Now, we’re ready to create our virtual machine. Let’s hit the button “VM” in the main window, this wizard
window will be appear.
Select the installation method which you will use to create the virtual machine. For now we will use Local install
media, later we will discuss the remaining methods.
Now its time to specify which Local install media to be used, we have two options:
For our tutorial, lets use ISO image method, so you should provide the path of your ISO image.
The storage has return back, we will use the virtual disk which we have created early to install virtual machine on
it. It will be as shown.
The final step which ask you about the name of your virtual machine and another advanced options lets talk
about it later
Network Time Protocol (NTP) and the chrony suite
Step one: install the chrony service
Step Two: we need to check whether the system already uses NTP to synchronize our
system clock over the network.
If the output from the last step showed No for NTP synchronized, we need to enable it
using:
Step three: open the main chrony configuration file with your favorite text editor, as
shown here:
vi /etc/chrony.conf
In the file, scroll down and look for the lines containing the following:
Replace the values shown with a list of preferred local time servers:
http://www.pool.ntp.org/
systemctl start chronyd
systemctl enable chronyd
To check whether chrony is taking care of your system time synchronization, use the
following:
chronyc trackin
To check the network sources chrony uses for synchronization, use the following:
chronyc sources
timedatectl list-timezones
Samba Server
Samba details
Package: samba*
Port no: 137,138,139
Script: /etc/init.d/smb
Service name : smb
Daemon : smbd
Configuration file : /etc/samba/smb.conf
1. First install Samba4 and required packages from the default CentOS repositories using the yum package
manager tool as shown.
mkdir -p /samba/anonymous_share
chmod -R 0777 /samba/anonymous_share
vi /etc/samba/smb.conf
[Anonymous share]
path = /samba/share
read only = No
create mask = 0777
directory mask = 0777
guest only = Yes
guest ok = Yes
Start samba services, and enable them to start automatically on every reboot.
systemctl start smb
systemctl start nmb
systemctl enable smb
systemctl enable nmb
We can test the Samba server configuration syntax errors using the command ‘testparm’.
testparm
firewall-cmd --reload
Now, let us create a password protected samba share so that the users should enter the valid username
and password to access the share folder.
Useradd unixmen
groupadd smbgroup
Assign the user unixmen to smbgroup, and set samba password to that user.
-M -do not create the user’s home directory. We’ll manually create this directory.
-d /samba/josh - set the user’s home directory to /samba/josh.
-s /usr/sbin/nologin - disable shell access for this user.
-G sambashare - add the user to the sambashare group.
Create a new share called “/samba/secure_share” and set the permissions to that share.
mkdir /samba/secure_share
chmod -R 0755 /samba/secure_share
chown -R unixmen:smbgroup /samba/secure_share
vi /etc/samba/smb.conf
Add the below lines at the bottom of samba config file.
[secure_share]
path = /samba/secure_share
writable = yes
browsable = yes
guest ok = no
valid users = @smbgroup
Once the installation is complete, start the nfs-server service, enable it to automatically start at system boot, and
then verify its status using the systemctl commands.
systemctl start nfs-server.service
systemctl enable nfs-server.service
systemctl status nfs-server.service
/etc/nfs.conf – main configuration file for the NFS daemons and tools.
/etc/nfsmount.conf – an NFS mount configuration file.
Next, create the file systems to export or share on the NFS server. For this guide, we will create four file systems,
three of which are used by staff from three departments: human resource, finance and marketing to share files
and one is for root user backups.
# mkdir -p /mnt/nfs_shares/{Human_Resource,Finance,Marketing}
# mkdir -p /mnt/backups
# ls -l /mnt/nfs_shares/
Then export the above file systems in the NFS server /etc/exports configuration file to determine local physical
file systems that are accessible to NFS clients.
/mnt/nfs_shares/Human_Resource 10.20.20.0/24(rw,sync)
/mnt/nfs_shares/Finance 10.20.10.0/24(rw,sync)
/mnt/nfs_shares/Marketing 10.20.30.0/24(rw,sync)
/mnt/backups 10.20.20.9/24(rw,sync,no_all_squash,root_squash)
Here are some of the exports options (read man exports for more information and export options):
To display the current export list, run the following command. Note that the exports table also applies some of
the default exports options that are not explicitly defined as shown in the following screenshot.
# exportfs -s
Next, if you have the firewalld service running, you need to allow traffic to the necessary NFS services (mountd,
nfs, rpc-bind) via the firewall, then reload the firewall rules to apply the changes, as follows.
Now on the client node(s), install the necessary packages to access NFS shares on the client systems. Run the
appropriate command for your distribution:
Then run the showmount command to show mount information for the NFS server. The command should output
the exported file system on the client as shown in the screenshot.
# showmount -e 10.20.20.8
Next, create a local file system/directory for mounting the remote NFS file system and mount it as an ntf file
system.
# mount | grep nfs
To enable the mount to persistent even after a system reboot, run the following command to enter the
appropriate entry in the /etc/fstab.
# echo "10.20.20.8:/mnt/backups /mnt/backups nfs defaults 0 0">>/etc/fstab
# cat /etc/fstab
Lastly, test if NFS setup is working fine by creating a file on the server and check if the file can be seen in the
client.
# touch /mnt/backups/file_created_on_server.text [On NFS Server]
# ls -l /mnt/backups/file_created_on_server.text [On NFS client]
Install MariaDB
yum install mariadb-server mariadb -y
systemctl start mariadb
systemctl enable mariadb
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y ## Enter Y and press Enter
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Install phpMyAdmin
Configure phpMyAdmin
vi /etc/httpd/conf.d/phpMyAdmin.conf
[...]
Alias /phpMyAdmin /usr/share/phpMyAdmin
Alias /phpmyadmin /usr/share/phpMyAdmin
#<Directory /usr/share/phpMyAdmin/>
# <IfModule mod_authz_core.c>
# # Apache 2.4
# <RequireAny>
# Require ip 127.0.0.1
# Require ip ::1
# </RequireAny>
# </IfModule>
# <IfModule !mod_authz_core.c>
# # Apache 2.2
# Order Deny,Allow
# Deny from All
# Allow from 127.0.0.1
# Allow from ::1
# </IfModule>
#</Directory>
<Directory /usr/share/phpMyAdmin/>
Options none
AllowOverride Limit
Require all granted
</Directory>
[...]
Edit “config.inc.php” file and change from “cookie” to “http” to change the
authentication in phpMyAdmin:
vi /etc/phpMyAdmin/config.inc.php
Change ‘cookie’ to ‘http’.
[...]
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config,
http or cookie based)?
[...]
load_module “/usr/lib/nginx/modules/ngx_rtmp_module.so”;