0% fanden dieses Dokument nützlich (0 Abstimmungen)
14 Ansichten18 Seiten

Quick Ubuntu 18 Administration

Das Dokument beschreibt die Installation und Konfiguration verschiedener Dienste und Software auf einem Linux-Server. Es werden Schritte zur Einrichtung von Netzwerk, LAMP-Stack, phpMyAdmin, NTP, NFS, Java, Maven, Git, Jenkins, Docker und Postfix beschrieben.

Hochgeladen von

Badi Ul Zaman
Copyright
© All Rights Reserved
Wir nehmen die Rechte an Inhalten ernst. Wenn Sie vermuten, dass dies Ihr Inhalt ist, beanspruchen Sie ihn hier.
Verfügbare Formate
Als PDF, TXT herunterladen oder online auf Scribd lesen
0% fanden dieses Dokument nützlich (0 Abstimmungen)
14 Ansichten18 Seiten

Quick Ubuntu 18 Administration

Das Dokument beschreibt die Installation und Konfiguration verschiedener Dienste und Software auf einem Linux-Server. Es werden Schritte zur Einrichtung von Netzwerk, LAMP-Stack, phpMyAdmin, NTP, NFS, Java, Maven, Git, Jenkins, Docker und Postfix beschrieben.

Hochgeladen von

Badi Ul Zaman
Copyright
© All Rights Reserved
Wir nehmen die Rechte an Inhalten ernst. Wenn Sie vermuten, dass dies Ihr Inhalt ist, beanspruchen Sie ihn hier.
Verfügbare Formate
Als PDF, TXT herunterladen oder online auf Scribd lesen

Quick Linux Administration

######################################################################
[Link] IP Configuration on server1
######################################################################

IP Configuration
Hostname: [Link]
IP address: [Link]
Netmask: [Link]
Gateway: [Link]
Name Server: [Link]

######################################################################

Getting example configuration from netplan manual page


man netplan

Listing ip and interface information using ip


ip a s

Editing yaml file to make required changes


vim /etc/netplan/[Link]
network:
ethernets:
ens3:
dhcp4: no
addresses: [[Link]/24]
gateway4: [Link]
nameservers:
addresses: [[Link]]
version: 2

Applying netplan configuration


netplan apply

Checking for configuration successful

ip a | grep ens3

Changing hostname as per requirement


hostnamectl set-hostname [Link]
hostnamectl

######################################################################
Q2. Install LAMP(Apache,MySQL & PHP) server
#####################################################################

Install tasksel installer

apt install tasksel -y


Install LAMP using taskel

tasksel install lamp-server

Test LAMP Installation

vim /var/www/html/[Link]
<?php
phpinfo();
?>
cat /var/www/html/[Link]

[Link]

Perform MySQL Secure Installation

mysql_secure_installation

Configure Firewall for Apache Access

ufw allow in "Apache Full"

Install PHP modules


apt-cache search ^php- | grep module

apt install php-memcache

Configure Apache ServerName


vim /etc/apache2/[Link]

ServerName [Link]

Check Apache Configuration

apache2ctl configtest

Restart and enable Apache

systemctl is-enabled [Link]

systemctl enable --now apache2

systemctl restart apache2

systemctl is-active [Link]

systemctl status apache2

tail -f /var/log/apache2/[Link]
tail -f /var/log/apache2/[Link]
journalctl -p err _SYSTEMD_UNIT=[Link]
######################################################################
Q3. Install phpMyAdmin on server
#####################################################################

Install required Packages

apt install phpmyadmin php-mbstring php-gettext

Enable php extension


phpenmod mbstring

Restart apache2
systemctl restart apache2

[Link]
phpmyadmin
XXXXXXX
######################################################################
Q4. Install and configure ntp on server
#####################################################################

Install required software


apt install ntp

Configure Firewall
ufw allow from any to any port 123 proto udp

Verify ntp is synced


ntpq -p

######################################################################
Q5. Install and configure nfs server on server
###############################################################
Install required Packages
apt install nfs-kernel-server -y

Check for nfs version support


cat /proc/fs/nfsd/versions

Disable nfsv3 support


vim /etc/default/nfs-kernel-server
RPCNFSDCOUNT="8 --no-nfs-version 3"

systemctl restart [Link]

cat /proc/fs/nfsd/versions

Enable and Restart nfs service

systemctl enable --now [Link]

Create required Directories to share


mkdir /homes

Update exports file


vim /etc/exports

/home *.[Link](rw,sync,no_subtree_check)
/homes [Link]/24(rw,sync,no_root_squash,no_subtree_check)
/mnt/datastore/datacenter
[Link]/24(rw,sync,no_root_squash,no_subtree_check)

exportfs -rv

Configure Firewall
ufw enable

ufw allow from [Link]/24 to any port nfs

ufw status

Mount share on client


mkdir /mnt/homes

vim /etc/fstab

[Link]:/homes /mnt/homes nfs rw,soft 0 0

mount -a

df -hT

######################################################################
Q6. Install and configure JAVA 8 on server
############################################################
Install required Packages
apt update

apt install openjdk-8-jdk openjdk-8-jre -y

Check Java version


java -version

Setup Java profile


vim /etc/environment

JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
JRE_HOME=/usr/lib/jvm/java-8-openjdk-amd64/jre

java -version

######################################################################
Q7. Install and configure Apache Maven on server
###########################################################
Download Apache Maven source
cd /opt/
wget [Link]
[Link]

Extract archive
tar xvf [Link]

Rename Apache Maven directory


mv apache-maven-3.3.9 apache-maven
Configure Apache Maven
cd /etc/profile.d/

vim [Link]
# Apache Maven Environment Variables
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export MAVEN_HOME=/opt/apache-maven
export PATH=${MAVEN_HOME}/bin:${PATH}

Set Necessary permissions


chmod +x [Link]
source [Link]
mvn --version
mvn --help

######################################################################
Q8. Install and configure git on server
############################################################
Install required packages
apt update

apt install git -y

Check git version


git --version

Setup git
git config --global [Link] "Andrey Jozef"

git config --global [Link] "ajozef@[Link]"

cat ~/.gitconfig
[user]

name = Andrey Jozef

email = ajozef@[Link]

######################################################################
Q9. Install and configure jenkins on server
############################################################

Add apt repository key


wget -qO - [Link] | apt-key add -

Add Jenkins repository


echo "deb [Link] binary/" >
/etc/apt/[Link].d/[Link]

Update software list


apt update

Install required software


apt install jenkins -y

Start and enable jenkins


systemctl enable --now jenkins

Check the status of jenkins service


systemctl status jenkins

Configure firewall for jenkins


ufw status

ufw enable

ufw allow ssh

ufw allow 8080

ufw status
Setup jenkins
[Link]

cat /var/lib/jenkins/secrets/initialAdminPassword

admin

Proceed with configuration

###################################################

#############################################################
Q10. Install docker on server
#############################################################
Update software list
apt update

Installed required software


apt install [Link] -y

Start and enable docker service


systemctl enable --now docker

Check the docker version


docker --version
###################################################

Q11. Install Apache ANT on server


###########################################################
Update software list
apt update

Installed required software


apt install ant -y

Check the Apache ANT version


ant -version
###################################################

Q12. Install and configure postfix on server


###########################################################
Update hosts file
vim /etc/hosts
[Link] [Link] mail

Update software list


apt update
Installed required software
apt install mailutils -y
use type as Internet Site and [Link] as domain

Configure postfix
vim /etc/postfix/[Link]
inet_interfaces = loopback-only

myhostname=[Link]

OR

postconf -e 'inet_interfaces = loopback-only’

postconf -e 'myhostname=[Link]’

postconf -p | egrep '^inet_interfaces|^myhostname'

Enable and restart postfix server


systemctl enable --now postfix
systemctl status postfix

Test postfix is working


echo "Hey dude what’s Up? " | mail -s "Knock Knock" student@[Link]

su -l student

mail

###################################################

Q13. Install nagios 4.4.6 on server


###########################################################
Update software List
apt update

Install required Packages


apt install -y autoconf bc gawk dc build-essential gcc libc6 make wget unzip
apache2 php libapache2-mod-php7.2 libgd-dev libmcrypt-dev make libssl-dev snmp
libnet-snmp-perl gettext -y

Download Nagios 4.4.5


wget -c [Link]
[Link] -P /root/

Extract download source


tar xvzf [Link]

cd nagioscore-nagios-4.4.5/
Compile and install Nagios
./configure --with-httpd-conf=/etc/apache2/sites-enabled

make all

Create necessary users and add them to required groups.


make install-groups-users

usermod -a -G nagios www-data

id nagios

Install Nagios binaries


make install

Install service daemon script


make install-daemoninit

Install the command mode.


make install-commandmode

Install sample config files


make install-config

Install the Apache configuration for Nagios 


make install-webconf

Activate the mod_rewrite and mode_cgi modules


a2enmod rewrite cgi

Restart appache to activate new configuration


systemctl restart apache2

Create nagiosadmin user


htpasswd -c /usr/local/nagios/etc/[Link] nagiosadmin
XXXXXXX

Setup firewall
ufw enable

ufw allow ssh


ufw allow Apache

ufw reload

ufw status

Download nagios plugins


wget --no-check-certificate -O [Link] [Link]
[Link]

Extract archive

tar zvxf [Link]

Compile and install plugins


cd nagios-plugins-release-2.2.1

./tools/setup

./configure

make && make install

Update [Link] for necessary parameters


cd /usr/local/nagios/etc
vim [Link]
cfg_dir=/usr/local/nagios/etc/servers

Create directory to hold configuration


mkdir -p /usr/local/nagios/etc/servers

Update [Link]
vim /usr/local/nagios/etc/objects/[Link]

Update [Link]
vim /usr/local/nagios/etc/objects/[Link]

define command{

command_name check_nrpe

command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

Check nagios configuration for errors


/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/[Link]

Restart nagios and apache services

systemctl restart [Link]

systemctl restart [Link]


Open firefox and open nagios webportal

[Link]

Add a host to monitor using nagios


ssh student@[Link]

Update sofware list


apt update

Install required nagios plugins


apt install nagios-nrpe-server nagios-plugins

Update [Link]
cd /etc/nagios/

vim [Link]
server_address=[Link]
allowed_hosts=[Link],::1,[Link]

Update nrpe_local.cfg
command[check_root]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /

command[check_ping]=/usr/lib/nagios/plugins/check_ping -H [Link] -w
100.0,20% -c 500.0,60% -p 5

command[check_ssh]=/usr/lib/nagios/plugins/check_ssh -4 [Link]

command[check_http]=/usr/lib/nagios/plugins/check_http -I [Link]

command[check_apt]=/usr/lib/nagios/plugins/check_apt

Restart and enable nrpe service at boot


systemctl enable --now nagios-nrpe-server

systemctl restart nagios-nrpe-server

Check from nagios server manual plugins check works

/usr/lib/nagios/plugins/check_nrpe -H [Link]
/usr/lib/nagios/plugins/check_nrpe -H [Link] -c check_ping

Add host configuration on Nagios server


vim /usr/local/nagios/etc/servers/[Link]
define host {
use linux-server

host_name client01

alias Ubuntu Host

address [Link]

register 1

define service {

host_name client01

service_description PING

check_command check_nrpe!check_ping

max_check_attempts 2

check_interval 2

retry_interval 2

check_period 24x7

check_freshness 1

contact_groups admins

notification_interval 2

notification_period 24x7

notifications_enabled 1

register 1

define service {

host_name client01

service_description Check Users

check_command check_nrpe!check_users

max_check_attempts 2

check_interval 2

retry_interval 2

check_period 24x7

check_freshness 1

contact_groups admins

notification_interval 2
notification_period 24x7

notifications_enabled 1

register 1

define service {

host_name client01

service_description Check SSH

check_command check_nrpe!check_ssh

max_check_attempts 2

check_interval 2

retry_interval 2

check_period 24x7

check_freshness 1

contact_groups admins

notification_interval 2

notification_period 24x7

notifications_enabled 1

register 1

define service {

host_name client01

service_description Check Root / Disk

check_command check_nrpe!check_root

max_check_attempts 2

check_interval 2

retry_interval 2

check_period 24x7

check_freshness 1

contact_groups admins

notification_interval 2

notification_period 24x7

notifications_enabled 1
register 1

define service {

host_name client01

service_description Check APT Update

check_command check_nrpe!check_apt

max_check_attempts 2

check_interval 2

retry_interval 2

check_period 24x7

check_freshness 1

contact_groups admins

notification_interval 2

notification_period 24x7

notifications_enabled 1

register 1

define service {

host_name client01

service_description Check HTTP

check_command check_nrpe!check_http
max_check_attempts 2

check_interval 2

retry_interval 2

check_period 24x7

check_freshness 1

contact_groups admins

notification_interval 2

notification_period 24x7

notifications_enabled 1

register 1

}
Check Nagios config might have typos
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/[Link]

Restart nagios server

systemctl restart nagios

###################################################

Q14. Install and Configure wordpress on server


###########################################################

Update software list


apt update

Install tasksel installer software


apt install tasksel -y

Install LAMP Server


tasksel install lamp-server

Check installed apache version


apache2 -v

Check MySQL version


mysql -V

Check installed php version


php -v

Create a simple php page to test LAMP installation

bash -c "echo -e '<?php\nphpinfo();\n?>' > /var/www/html/[Link]"


cat /var/www/html/[Link]

Update [Link]
cd /etc/apache2
ls -l
vim [Link]
ServerName [Link]

Configure MySQL secure server


mysql_secure_installation

Login to MySQL
mysql -u root -p

Create wordpress DATABASE


CREATE DATABASE wordpress;

Check if DATABASE creation went successful


SHOW DATABASES;

Create wordpress Admin User


CREATE USER `wp_admin`@`localhost` IDENTIFIED BY 'Y0u3p@s3';

Grant wp_admin user necessary permissions.


GRANT ALL ON wordpress.* TO `wp_admin`@`localhost`;

Reload Privileges
FLUSH PRIVILEGES;

EXIT from MySQL Shell


EXIT

Test wp_admin user


mysql -u wp_admin -p

Install additional php Packages

apt install php7.2 php7.2-cli php7.2-mysql php7.2-json php7.2-opcache php7.2-mbstring php7.2-


xml php7.2-gd php7.2-curl -y

Download Wordpress source


wget -c [Link] -P /root

Extract MySQL source


tar xvf /root/[Link]

Move wordpress to /var/www Directory.


mv -v /root/wordpress /var/www/wordpress

Assign webserver necessary permissions.


chown -Rv www-data:www-data /var/www/wordpress
find /var/www/wordpress/ -type d -exec chmod -v 750 {} \;
find /var/www/wordpress/ -type f -exec chmod -v 640 {} \;

Configure Wordpress
cd /var/www/wordpress
mv [Link] [Link]
vim [Link]
define( 'DB_NAME', 'wordpress' );

/** MySQL database username */


define( 'DB_USER', 'wp_admin' );
/** MySQL database password */
define( 'DB_PASSWORD', 'Y0u3p@s3' );
/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */


define('DB_COLLATE', '');

Create VirtualHost for wordpress


cd /etc/apache2/sites-available/

ls -l

egrep -v "#|$^" [Link] > [Link]

vim [Link]
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/wordpress
ServerAlias [Link]
ErrorLog ${APACHE_LOG_DIR}/[Link]
CustomLog ${APACHE_LOG_DIR}/[Link] combined
DirectoryIndex [Link] [Link]
DocumentRoot /var/www/wordpress
<Directory /var/www/worpress>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

Test apache configuration for typos


apachectl configtest

Enable wordpress VirtualHost


a2ensite [Link]

Disable Default VirtualHost


a2dissite [Link]
Enable rewrite
a2enmod rewrite

Restart apache2
systemctl restart apache2

Install wordpress
Open Firefox
[Link]

Proceed with Installation

Das könnte Ihnen auch gefallen