# data[].attributes.body
- Geschiedenis van Linux
- Linux distributies
- Linux distributie installeren (in VirtualBox)

# data[].attributes.body
- Command Line Basics
- Bestanden bewerken in de terminal
- Werken met een packet manager

# data[].attributes.body
- Gebruikers en groepen in Linux
- Gebruikers aanmaken
- Home directory van gebruikers
- chown en chmod

# data[].attributes.body
- Netwerk configureren van Ubuntu Server en Ubuntu Desktop
- ping en andere netwerktools

# data[].attributes.body
- Wat is een samba server?
- Samba Server installeren en configureren.
- Samba Server gebruiken.

# data[].attributes.body
- Wat is een ftp service?
- FTP Service installeren en configureren.

# data[].attributes.body
- Bestanden aanmaken, kopiëren, verplaatsen en verwijderen.
- Bestandenstructuur van Linux
- Bestanden zoeken
- Programma's runnen
- Services starten en stoppen.
- SSH installeren en configureren.

# data[].attributes.body
- MySQL installeren en configureren.
- MySQL gebruiken op de commandline

# data[].attributes.body
- Apache en PHP installeren en configureren.
- VirtualHost aanmaken.

# data[].attributes.body
- Theorie DNS Service

# data[].attributes.attachment_link.readable_text
LAMP is short for Linux, Apache, MySQL, P HP. This tutorial shows how you can install an Apache web server on an Ubuntu 18.04 LTS (Bionic Beaver) server with PHP 7.2 (mod_php) and MySQL / MariaDB support and how to setup an SSL certificate with Let's encrypt. Additionally, I will install PHPMyAdmin to make MySQL administration easier. A LAMP setup is a perfect basis for popular CMS systems like Joomla, Wordpress or Drupal.

Preliminary Note

In this tutorial, I will use the hostname server1.example.com with the IP address 192.168.1.100. These settings might differ for you, so you have to replace them where appropriate.

I recommend to use a minimal Ubuntu server setup as basis for the tutorial, that can be a virtual- or root server image with an Ubuntu 18.04 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.

I'm running all the steps in this tutorial with root privileges, so make sure you're logged in as root:

sudo -s

1. Installing MySQL or MariaDB Database

There are currently two widely used MySQL database systems available, the classic "MySQL" server which is developed by Oracle and is available in version 5.7 now and the MySQL fork named MariaDB which is developed by the original MySQL developer Monty Widenius.

I will show you how to install both alternatives below. Just follow either chapter 1.1 or 1.2 but not both. I will use MySQL 5.7 for the virtual machine image that can be downloaded from Howtoforge.

1.1 Install MySQL 5.7

To install MySQL 5.7, execute this command:

apt-get -y install mysql-server mysql-client

The packages mysql-server and mysql-client are so-called 'meta-packages', they install always the latest MySQL version that is available from Ubuntu. The latest version is currently MySQL 5.7.

We have set the root password for MySQL already during installation, but I would like to remove the anonymous user and test database for security reasons. Run the mysql_secure_installation command below to achieve that.

mysql_secure_installation

You will be asked these questions:

Securing the MySQL server deployment.

Enter password for user root: <-- Enter the MySQL root password

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No:
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : <-- Choose 'y' here if you like to enable the password validation, I don't need that function, so I choose 'n' here.

... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : <-- y
Success.

Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : <-- y
Success.

By default, MySQL 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? (Press y|Y for Yes, any other key for No) : <-- y
- 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.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : <-- y
Success.

All done!

The MySQL setup has been secured now.

1.2 Install MariaDB 10

Run the following command to install MariaDB-server and client:

apt-get -y install mariadb-server mariadb-client

Now we set a root password for MariaDB.

mysql_secure_installation

You will be asked these questions:

Enter current password for root (enter for none): <-- press enter
Set root password? [Y/n] <-- y
New password: <-- Enter the new MariaDB root password here
Re-enter new password: <-- Repeat the password
Remove anonymous users? [Y/n] <-- y
Disallow root login remotely? [Y/n] <-- y
Reload privilege tables now? [Y/n] <-- y

1.3 Test the MySQL/MariaDB root login

Test the login to MariaDB with the "mysql command"

mysql -u root -p

and enter the MariaDB root password that you've set above. The result should be similar to the screenshot below:

To leave the MySQL/MariaDB shell, enter the command "quit" and press enter.

2. Install Apache Web Server

Apache 2 is available as an Ubuntu package, therefore we can install it like this:

apt-get -y install apache2

Now direct your browser to http://192.168.1.100, and you should see the Apache2 default page (It works!):

The document root of the apache default vhost is /var/www/html on Ubuntu and the main configuration file is /etc/apache2/apache2.conf. The configuration system isfully documented in /usr/share/doc/apache2/README.Debian.gz.

3. Install PHP 7.2

We can install PHP 7.2 and the Apache PHP module as follows:

apt-get -y install php7.2 libapache2-mod-php7.2

Then restart Apache:

systemctl restart apache2

4. Test PHP and get details about your PHP installation

The document root of the default web site is /var/www/html. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

nano /var/www/html/info.php

<?php
phpinfo();

Then change the owner of the info.php file to the www-data user and group.

chown www-data:www-data /var/www/html/info.php

Now we call that file in a browser (e.g. http://192.168.1.100/info.php):

As you see, PHP 7.2 is working, and it's working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP. MySQL is not listed there which means we don't have MySQL / MariaDB support in PHP yet.

5. Get MySQL / MariaDB support in PHP

To get MySQL support in PHP, we can install the php7.2-mysql package. It's a good idea to install some other PHP modules as well as you might need them for your applications. You can search for available PHP modules like this:

apt-cache search php7.2

and

apt-cache search php-

as not all PHP packages have the version number 7.2 in their name.

Pick the ones you need and install them like this:

apt-get -y install php7.2-mysql php7.2-curl php7.2-gd php7.2-intl php-pear php-imagick php7.2-imap php-memcache php7.2-pspell php7.2-recode php7.2-sqlite3 php7.2-tidy php7.2-xmlrpc php7.2-xsl php7.2-mbstring php-gettext

Now restart Apache2:

systemctl restart apache2

PHP 7.2 has now MySQL / MariaDB support as shown in phpinfo() above.

6. Install the Opcache + APCu PHP cache to speed up PHP

PHP 7 ships with a built-in opcode cacher for caching and optimizing PHP intermediate code, it has the name 'opcache' and is available in the package php7.0-opcache. It is strongly recommended to have an Opcache installed to speed up your PHP page. Besides opcache, I will install APCu which is a compatibility wrapper for opcache to provide the functions of the APC cache, an often used caching system in PHP 5.x versions and many CMS systems still use it.

Opcache and APCu can be installed as follows:

apt-get -y install php7.2-opcache php-apcu

Don't worry if it shows that Opcache is already installed.

Now restart Apache:

systemctl restart apache2

Now reload http://192.168.1.100/info.php in your browser and scroll down to the modules section again. You should now find lots of new modules there:

Please don't forget to delete the info.php file when you don't need it anymore as it provides sensitive details of your server. Run the following command to delete the file.

rm -f /var/www/html/info.php

7. Enable the SSL website in apache

SSL/ TLS is a security layer to encrypt the connection between the web browser and your server. Most web browsers start to show sites as insecure today when the connection between the server and the web browser is not encrypted with SSL. In this chapter, I will show you how to secure your website with SSL.

Execute the following commands on your server to enable SSL (https://) support. Run:

a2enmod ssl
a2ensite default-ssl

which enables the SSL module and adds a symlink in the /etc/apache2/sites-enabled folder to the file /etc/apache2/sites-available/default-ssl.conf to include it into the active apache configuration. Then restart apache to enable the new configuration:

systemctl restart apache2

Now test the SSL connection by opening https://192.168.1.100 in a web browser.

You will receive an SSL warning as the SSL certificate of the server is a "self-signed" SSL certificate, this means that the browser does not trust this certificate by default and you have to accept the security warning first. After accepting the warning, you will see the apache default page.

The closed "Green Padlock" in front of the URL in the browser shows that the connection is encrypted.

There are two ways to get rid of the SSL warning, either replace the self-signed SSL certificate /etc/ssl/certs/ssl-cert-snakeoil.pem with an officially signed SSL certificate that you buy from an SSL Authority or you get a free SSL certificate from Let's encrypt, which I will describe in chapter 8.

8. Get a free SSL Certificate from Let's Encrypt

The first step to secure the website with a Let's Encrypt SSL Certificate is to install the python3-certbot-apache package. Run the following command:

apt-get -y install python3-certbot-apache

In the next step, we will request an SSL cert from Let's Encrypt by using the certbot client program, during this process, the Let's Encrypt server tries to connect to your server through the domain name that you provide to the certbot command. It is important that this domain name points to your server in DNS already so that the website is reachable by its domain name on port 80 (http) already. If the website is not reachable from the internet, then the creation of the Let's Encrypt SSL certificate will fail.

Before we can start to create the SSL cert, set the domain name in the vhost configuration file. Open the default vhost file with an editor:

nano /etc/apache2/sites-available/000-default.conf

and add the line:

ServerName example.com

Right below the 'DocumentRoot' line. Replace example.com with the domain name of your own website.

Then create the SSL Certificate with this command:

certbot --apache -d example.com

Replace example.com with your domain name here again. The command will start a wizard that asks you several questions.

Enter the email address where the administrator who is responsible for this website can be reached.

Accept the terms and conditions of the Let's Encrypt SSL authority.

Certbot will ask you now if you like to share your email address with the Electronic Frontier Foundation. Choose here whatever you prefer.

Then choose if you want to redirect non-SSL requests to https:// automatically. I'll select yes here to avoid duplicate content problems when the website is available as http:// and https:// version.

The SSL certificate has been issued successfully.

When you access the website now with a browser, you will get redirected automatically to SSL and the green padlock in front of the URL bar in the browser shows that we are using a trusted SSL certificate now.

8.1 Let's encrypt Auto Renewal

Let's Encrypt SSL certificates are valid for a short period of 80 days only. Therefore a cronjob to auto-renew the SSL certificates is necessary that runs the certbot --renew command.

This cronjob get setup automatically when you install certbot, the cron file is /etc/cron.d/certbot. So there is nothing more to do here. If you like to know what the cronjob looks like, run the command:

/etc/cron.d/certbot

The result is:

[email protected]:~# cat /etc/cron.d/certbot
# /etc/cron.d/certbot: crontab entries for the certbot package
#
# Upstream recommends attempting renewal twice a day
#
# Eventually, this will be an opportunity to validate certificates
# haven't been revoked, etc. Renewal will only occur if expiration
# is within 30 days.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

0 */12 * * * root test -x /usr/bin/certbot -a \! -d /run/systemd/system && perl -e 'sleep int(rand(43200))' && certbot -q renew

9. Install phpMyAdmin

phpMyAdmin is a web interface through which you can manage your MySQL databases. It's a good idea to install it:

apt-get -y install phpmyadmin

IMPORTANT: The apt installer will ask you several questions now, one of them is to select the web server type. A common mistake is that the web server type is just highlighted but not selected. To select an item in an apt menu you have to press the space bar on the keyboard after you navigated to the item with tab or cursor keys. Just highlighting it is not enough!

You will see the following questions:

Web server to configure automatically: <-- Select the option: apache2
Configure database for phpmyadmin with dbconfig-common? <-- Yes
MySQL application password for phpmyadmin: <-- Press enter, apt will create a random password automatically.

9.1 Root access to PHPMyAdmin

MariaDB and MySQL enable a plugin called "unix_socket" for the root user by default, this plugin prevents that the root user can log into PHPMyAdmin and that TCP connections to MySQL are working for the root user. To get a user with privileges to create other users and databases in PHPMyAdmin, I will create a new MySQL user with the name "admin" with the same privileges than the root user.

Login to the MySQL database as root user on the shell:

mysql -u root

Create a new user with the name "admin" and password "howtoforge". Replace the password "howtoforge" with a secure password in the commands below!

CREATE USER 'admin'@'localhost' IDENTIFIED BY 'howtoforge';
GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
exit

Afterward, you can access phpMyAdmin under http://192.168.1.100/phpmyadmin/:

10 Virtual machine image download of this tutorial

This tutorial is available as ready to use virtual machine image in ovf/ova format that is compatible with VMWare and Virtualbox. The virtual machine image uses the following login details:
SSH / Shell Login
Username: administrator
Password: howtoforge

This user has sudo rights.
MySQL Login
Username: root
Password: howtoforge

The IP of the VM is 192.168.1.100, it can be changed in the file /etc/network/interfaces. Please change all the above passwords to secure the virtual machine.
About Till Brehm
Over 20 years experience as Software Developer and Linux System Administrator. Till Brehm is the founder and lead developer of the ISPConfig Hosting Control Panel software (since 2000) and he founded HowtoForge in 2005 as a place to share Linux knowledge with other Linux enthusiasts.

# data[].attributes.attachment_link.title
Ubuntu 18.04 (LTS) LAMP server tutorial with Apache, PHP 7.2, and MySQL

# data[].attributes.attachment_link.description
LAMP is short for Linux, Apache, MySQL, P HP. This tutorial shows how you can install an Apache web server on an Ubuntu 18.04 LTS (Bionic Beaver) server with PHP 7.2 (mod_php) and MySQL / MariaDB support and how to setup an SSL certificate with Let's encrypt.

# data[].attributes.attachment_link.readable_text
Domain Name System (DNS) is the root of the internet that translates the domain name to IP Address and vice versa. BIND9 (Berkeley Internet Name Domain) package provides the functionality of name to IP conversion.

This post will guide you to configure on Ubuntu 18.04.
Domain: itzgeek.local
Primary Name Server: (It is the master server, and all DNS records are created here.)
Server Name: ns1.itzgeek.local IP Address: 192.168.1.10
Secondary Name Server: (It is a slave server, gets DNS records from the Master server. You can have multiple slave DNS server in your environment. Slave server acts as a backup DNS server and serves clients DNS requests if the primary server goes down.)
Server Name: ns2.itzgeek.local IP Address: 192.168.1.20 In this post, we set up only the primary DNS server. If you are implementing the secondary NDS server, then take a look at configuring slave DNS server on Ubuntu 18.04.
Switch to the root user.

su -

OR

sudo su -

Update the repository index.

apt update
Make sure both primary and secondary DNS servers have a static IP address.
If you are using Netplan - a new network tool for configuring networking in Ubuntu 18.04, then.

The package name of DNS Ubuntu 18.04 is bind9 and is available in the base repository. Use the apt command to install bind9 package.

apt install -y bind9 bind9utils bind9-doc dnsutils

Configure DNS Server on Ubuntu 18.04

/etc/bind/ is the main configuration directory of bind9, and it holds configuration files and zone lookup files.
Global configuration file is /etc/bind/named.conf. You should not use this file for your local DNS zone rather you can use /etc/bind/named.conf.local file.

Create Zone's

Let us begin with creating forward zone for your domain.

nano /etc/bind/named.conf.local
Forward Zone:
The following is the forward zone entry for the itzgeek.local domain in the named.conf.local file.

zone "itzgeek.local" IN {//Domain name type master;//Primary DNS  file "/etc/bind/fwd.itzgeek.local.db";//Forward lookup file  allow-update { none; };/ / Since this is the primary DNS, it should be none.  };
Reverse Zone:
The following entries are for the reverse zone in the named.conf.local file.

zone "1.168.192.in-addr.arpa" IN {//Reverse lookup name, should match your network in reverse order  type master;// Primary DNS  file "/etc/bind/rev.itzgeek.local.db";//Reverse lookup file  allow-update { none; };//Since this is the primary DNS, it should be none.  };

Create Zone lookup file

Once you create zones, you can go ahead and create zone data files which hold DNS records for the forward zone and reverse zone.
Forward Zone lookup file:
Copy the sample entries to zone file called fwd.itzgeek.local.db for forward zone under /etc/bind directory.

Record types in the zone file,
Domain names should end with a dot (.).
cp /etc/bind/db.local /etc/bind/fwd.itzgeek.local.db

Edit the zone.

nano /etc/bind/fwd.itzgeek.local.db

Update the content shown below. Whenever you change any records in the lookup file, make sure you update the serial number to some random number, higher than current.

;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     ns1.itzgeek.local. root.itzgeek.local. (

                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
;@      IN      NS      localhost.
;@      IN      A       127.0.0.1
;@      IN      AAAA    ::1

;Name Server Information  IN NS ns1.itzgeek.local. IN NS ns2.itzgeek.local.;IP address of Name Server ns1 IN A 192.168.1.10 ns2 IN A 192.168.1.20 ;Mail Exchanger itzgeek.local. IN MX 10 mail.itzgeek.local.;A - Record HostName To Ip Address  www IN A 192.168.1.100 mail IN A 192.168.1.150 @ IN A 192.168.1.200;CNAME record  ftp IN CNAME www.itgeek.local.
Reverse Zone lookup file:
Copy the sample entries to the zone file called rev.itzgeek.local.db for reverse zone under /etc/bind directory and create reverse pointers for the above forward zone records.

PTR - Pointer
SOA - Start of Authority

cp /etc/bind/db.127 /etc/bind/rev.itzgeek.local.db

Edit the reverse zone file.

nano /etc/bind/rev.itzgeek.local.db

Update the content shown below. Whenever you change any DNS records in the lookup file, make sure to update the serial number to some random number, higher than the current one.

;
; BIND reverse data file for local loopback interface
;
$TTL    604800
@       IN      SOA     itzgeek.local. root.itzgeek.local. (

                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
;@      IN      NS      localhost.
;1.0.0  IN      PTR     localhost.

;Name Server Information  IN NS ns1.itzgeek.local. IN NS ns2.itzgeek.local.;Reverse lookup for Name Server  10 IN PTR ns1.itzgeek.local. 20 IN PTR ns2.itzgeek.local.;PTR Record IP address to HostName  100 IN PTR www.itzgeek.local. 150 IN PTR mail.itzgeek.local. 200 IN PTR itzgeek.local.

Check BIND Configuration Syntax

Use named-checkconf command to check the syntax and named.conf* files for any errors.

named-checkconf
Command will return to the shell if there are no errors.
Also, you can use named-checkzone to check the syntax errors in zone files.

named-checkzone itzgeek.local /etc/bind/fwd.itzgeek.local.db
Output:
zone itzgeek.local/IN: loaded serial 20
OK

named-checkzone 1.168.192.in-addr.arpa /etc/bind/rev.itzgeek.local.db
Output:
zone 1.168.192.in-addr.arpa/IN: loaded serial 20
OK

Restart bind service.

systemctl restart bind9

Enable it on system startup.

systemctl enable bind9

Check the status of bind9 service.

systemctl status bind9
Output:
bind9.service - BIND Domain Name Server
   Loaded: loaded (/lib/systemd/system/bind9.service; enabled; vendor preset: enabled)
   Active: active (running)  since Sun 2018-06-17 13:33:05 UTC; 21s ago Docs: man:named(8) Main PID: 2683 (named) Tasks: 4 (limit: 2323) CGroup: /system.slice/bind9.service └─2683 /usr/sbin/named -f -u bind Jun 17 13:33:05 server named[2683]: network unreachable resolving './NS/IN': 2001:500:3::42#53 Jun 17 13:33:05 server named[2683]: managed-keys-zone: Key 19036 for zone . acceptance timer complete: key now tr Jun 17 13:33:05 server named[2683]: managed-keys-zone: Key 20326 for zone . acceptance timer complete: key now tr Jun 17 13:33:05 server named[2683]: resolver priming query complete Jun 17 13:33:06 server named[2683]: checkhints: b.root-servers.net/A (199.9.14.201) missing from hints Jun 17 13:33:06 server named[2683]: checkhints: b.root-servers.net/A (192.228.79.201) extra record in hints Jun 17 13:33:06 server named[2683]: checkhints: b.root-servers.net/AAAA (2001:500:200::b) missing from hints Jun 17 13:33:06 server named[2683]: checkhints: b.root-servers.net/AAAA (2001:500:84::b) extra record in hints Jun 17 13:33:06 server named[2683]: checkhints: l.root-servers.net/AAAA (2001:500:9f::42) missing from hints Jun 17 13:33:06 server named[2683]: checkhints: l.root-servers.net/AAAA (2001:500:3::42) extra record in hints

Go to any client machine and add our new DNS server IP Address in /etc/resolv.conf file.

nano /etc/resolv.conf

Make an entry like below.

nameserver 192.168.1.10
OR
Read the below tutorial to set DNS server IP in Linux.

Use the dig command to check the forward zone.

dig www.itzgeek.local
If you get command not found, then install bind-utils package. Output:
; <<>> DiG 9.11.3-1ubuntu1.1-Ubuntu <<>> www.itzgeek.local
;; global options: +cmd
;; Got answer:
;; WARNING: .local is reserved for Multicast DNS
;; You are currently testing what happens when an mDNS query is leaked to DNS
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60898
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;www.itzgeek.local.             IN      A

;; ANSWER SECTION:
www.itzgeek.local. 604800 IN A 192.168.1.100  ;; Query time: 0 msec ;; SERVER: 127.0.0.53#53(127.0.0.53) ;; WHEN: Sun Jun 17 13:44:57 UTC 2018 ;; MSG SIZE rcvd: 62
The DNS server's answer for the forward lookup: 192.168.1.100 as IP address for www.itzgeek.local.
Confirm the reverse lookup with dig command.

dig -x 192.168.1.100
Output:
; <<>> DiG 9.11.3-1ubuntu1.1-Ubuntu <<>> -x 192.168.1.100
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 25695
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;100.1.168.192.in-addr.arpa.    IN      PTR

;; ANSWER SECTION:
100.1.168.192.in-addr.arpa. 604800 IN PTR www.itzgeek.local. ;; Query time: 0 msec ;; SERVER: 127.0.0.53#53(127.0.0.53) ;; WHEN: Sun Jun 17 13:45:50 UTC 2018 ;; MSG SIZE rcvd: 86
The DNS server's answer for reverse lookup: www.itzgeek.local as a name for 192.168.1.100.
This result confirms that both zone lookups are working fine.

You now have successfully configured DNS server on Ubuntu 18.04 as the master server.

In our next post, we will configure slave DNS server on Ubuntu 18.04.

That's All.

# data[].attributes.attachment_link.title
How To Configure DNS Server On Ubuntu 18.04 - ITzGeek

# data[].attributes.attachment_link.description
Domain Name System (DNS) is the root of the internet that translates the domain name to IP Address and vice versa. BIND9 (Berkeley Internet Name Domain) package provides the functionality of name to IP conversion. This post will guide you to configure on Ubuntu 18.04 .

# data[].attributes.attachment_link.readable_text
Objective

The objective is to configure static IP address on Ubuntu 18.04 Bionic Beaver Linux

Operating System and Software Versions

Operating System: - Ubuntu 18.04 Bionic Beaver Linux

Requirements

Privileged access to Ubuntu 18.04 system will be required.

Difficulty

EASY

Conventions

# - requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command

$ - requires given linux commands to be executed as a regular non-privileged user

Instructions

Configure static IP address using DHCP

Most likely your current Ubuntu system uses DHCP server to configure its networking settings. Hence, the configuration of your IP address is dynamic. In many scenarios, simply configuring your router or local DHCP server is a preferred way to set a static address to any host regardless of the operating system in use. Check your router manual and assign the static IP address to your host based on its MAC address using the DHCP service.

Configure static IP address using Netplan

Netplan network configuration had been first introduced to Ubuntu 18.04 LTS Bionic Beaver. It is available to all new Ubuntu 18.04 installations.

Depending on your Ubuntu installation Netplan may not be avaiable on upgraded Ubuntu systems. If this is your case you might attempt to configure a static IP address for your network interface using /etc/network/interfaces file as described at the end of this document.

Ubuntu Server

To configure a static IP address on your Ubuntu 18.04 server you need to modify a relevant netplan network configuration file within /etc/netplan/ directory.

For example you might find there a default netplan configuration file called 01-netcfg.yaml with a following content instructing the networkd deamon to configure your network interface via DHCP:

# This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: yes

To set your network interface enp0s3 to static IP address 192.168.1.222 with gateway 192.168.1.1 and DNS server as 8.8.8.8 and 8.8.4.4 replace the above configuration with the one below.

WARNING:
You must adhere to a correct code indent for each line of the block. In other words the prefix number of spaces for each line is important. Othersiwe you may end up with an error message similar to: Invalid YAML at //etc/netplan/01-netcfg.yaml line 7 column 6: did not find expected key

# This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: networkd ethernets: enp0s3: dhcp4: no addresses: [192.168.1.222/24] gateway4: 192.168.1.1 nameservers: addresses: [8.8.8.8,8.8.4.4]

Once ready apply changes with:

$ sudo netplan apply

In case you run into some issues execute:

$ sudo netplan --debug apply

Ubuntu Desktop

This is a preferred way of setting the static IP address on Ubuntu Desktop.

Click on top right network icon and select settings corresponding to the network interface you wish to assign with the static IP address.

Next, click on the gear box icon next to your network connection you wish to configure. This could be wired or wireless connection.

Select IPv4 from the top menu.

Select Manual for the IPv4 settings, enter your desired configuration and hit Apply

Restart your network by ON/OFF switch.

Check your new static IP address configuration.

Configure static IP address using interfaces file

The following procedure is mostly obsolete on Ubuntu 18.04 systems with Netplan preinstall. However, some upgraded Ubuntu 18.04 may still need to use the /etc/network/interfaces file to configure the static IP address on Ubuntu Server or Desktop systems. The content of /etc/network/interfaces file most likely currently contains the following lines:

# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

To configure the static IP address we first need to know the network interface name which we need to assign with the static IP address. Use any of the bellow commands to list all network interface names available:

$ ip a
OR
$ ip link show
1: lo: mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: enp0s3:  mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000 link/ether 08:00:27:2f:a4:ad brd ff:ff:ff:ff:ff:ff

The network interface name we would like to configure with the static IP address is enp0s3. Use your favorite command line text editor to change the following content into your existing /etc/network/interfaces file while replacing the example configuration settings with settings to fit your needs:

auto enp0s3 iface enp0s3 inet static address 10.1.1.83 netmask 255.0.0.0 gateway 10.1.1.1 dns-nameservers 8.8.8.8 8.8.4.4

On Line 1 we have enabled our network interface. Line 2 forces the system to use the static IP address. Line 3 declares the actual static IP address to be assigned to the enp0s3 network interface. On Line 4 we configure network mask and Line 5 is used to set a gateway IP address. Optionally, on Line 6 we can set multiple IP addresses of preferred DNS servers. Here is the resulting example /etc/network/interfaces file:

$ sudo nano /etc/network/interfaces

Save the /etc/network/interfaces file and either reboot your system or restart network using the following linux command s to apply new settings:

$ sudo ip a flush enp0s3
$ sudo systemctl restart networking.service

Check your IP address configuration to confirm correctness of your new configuration settings.

# data[].attributes.attachment_link.title
How to configure static IP address on Ubuntu 18.04 Bionic Beaver Linux

# data[].attributes.attachment_link.description
The objective is to configure static IP address on Ubuntu 18.04 Bionic Beaver Linux Operating System: - Ubuntu 18.04 Bionic Beaver Linux Privileged access to Ubuntu 18.04 system will be required.

# data[].attributes.attachment_link.title
How to Create a Network Share Via Samba Via CLI (Command-line interface/Linux Terminal) - Uncomplicated, Simple and Brief Way! - Community Help Wiki

# data[].attributes.attachment_link.description
Note: Samba uses a separate set of passwords than the standard Linux system accounts (stored in /etc/samba/smbpasswd), so you'll need to create a Samba password for yourself. This tutorial implies that you will use your own user and it does not cover situations involving other users passwords, groups, etc...

# data[].attributes.attachment_link.readable_text
There are options in /etc/vsftpd.conf to help make vsftpd more secure. For example users can be limited to their home directories by uncommenting:

You can also limit a specific list of users to just their home directories:

chroot_list_enable=YES
chroot_list_file=/etc/vsftpd.chroot_list

After uncommenting the above options, create a /etc/vsftpd.chroot_list containing a list of users one per line. Then restart vsftpd:

sudo systemctl restart vsftpd.service

Also, the /etc/ftpusers file is a list of users that are disallowed FTP access. The default list includes root, daemon, nobody, etc. To disable FTP access for additional users simply add them to the list.

FTP can also be encrypted using FTPS. Different from SFTP, FTPS is FTP over Secure Socket Layer (SSL). SFTP is a FTP like session over an encrypted SSH connection. A major difference is that users of SFTP need to have a shell account on the system, instead of a nologin shell. Providing all users with a shell may not be ideal for some environments, such as a shared web host. However, it is possible to restrict such accounts to only SFTP and disable shell interaction. See the section on OpenSSH-Server for more.

To configure FTPS, edit /etc/vsftpd.conf and at the bottom add:

Also, notice the certificate and key related options:

rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key

By default these options are set to the certificate and key provided by the ssl-cert package. In a production environment these should be replaced with a certificate and key generated for the specific host. For more information on certificates see Certificates.

Now restart vsftpd, and non-anonymous users will be forced to use FTPS:

sudo systemctl restart vsftpd.service

To allow users with a shell of /usr/sbin/nologin access to FTP, but have no shell access, edit /etc/shells adding the nologin shell:

# /etc/shells: valid login shells
/bin/csh
/bin/sh
/usr/bin/es
/usr/bin/ksh
/bin/ksh
/usr/bin/rc
/usr/bin/tcsh
/bin/tcsh
/usr/bin/esh
/bin/dash
/bin/bash
/bin/rbash
/usr/bin/screen
/usr/sbin/nologin

This is necessary because, by default vsftpd uses PAM for authentication, and the /etc/pam.d/vsftpd configuration file contains:

auth    required        pam_shells.so

The shells PAM module restricts access to shells listed in the /etc/shells file.

Most popular FTP clients can be configured to connect using FTPS. The lftp command line FTP client has the ability to use FTPS as well.

# data[].attributes.attachment_link.description
There are options in /etc/vsftpd.conf to help make vsftpd more secure. For example users can be limited to their home directories by uncommenting: You can also limit a specific list of users to just their home directories: chroot_list_enable=YES chroot_list_file=/etc/vsftpd.chroot_list After uncommenting the above options, create a /etc/vsftpd.chroot_list containing a list of users one per line.

# data[].attributes.attachment_link.readable_text
Introduction

MySQL is an open-source database management system, commonly installed as part of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. It uses a relational database and SQL (Structured Query Language) to manage its data.

The short version of the installation is simple: update your package index, install the mysql-server package, and then run the included security script.

sudo apt update


sudo apt install mysql-server


sudo mysql_secure_installation

This tutorial will explain how to install MySQL version 5.7 on an Ubuntu 18.04 server. However, if you're looking to update an existing MySQL installation to version 5.7, you can read this MySQL 5.7 update guide instead.

Prerequisites

To follow this tutorial, you will need:

Step 1 - Installing MySQL

On Ubuntu 18.04, only the latest version of MySQL is included in the APT package repository by default. At the time of writing, that's MySQL 5.7

To install it, update the package index on your server with apt:

Then install the default package:

This will install MySQL, but will not prompt you to set a password or make any other configuration changes. Because this leaves your installation of MySQL insecure, we will address this next.

Step 2 - Configuring MySQL

For fresh installations, you'll want to run the included security script. This changes some of the less secure default options for things like remote root logins and sample users. On older versions of MySQL, you needed to initialize the data directory manually as well, but this is done automatically now.

Run the security script:

This will take you through a series of prompts where you can make some changes to your MySQL installation's security options. The first prompt will ask whether you'd like to set up the Validate Password Plugin, which can be used to test the strength of your MySQL password. Regardless of your choice, the next prompt will be to set a password for the MySQL root user. Enter and then confirm a secure password of your choice.

From there, you can press Y and then ENTER to accept the defaults for all the subsequent questions. This will remove some anonymous users and the test database, disable remote root logins, and load these new rules so that MySQL immediately respects the changes you have made.

To initialize the MySQL data directory, you would use mysql_install_db for versions before 5.7.6, and mysqld --initialize for 5.7.6 and later. However, if you installed MySQL from the Debian distribution, as described in Step 1, the data directory was initialized automatically; you don't have to do anything. If you try running the command anyway, you'll see the following error:

mysqld: Can't create directory '/var/lib/mysql/' (Errcode: 17 - File exists) . . . 2018-04-23T13:48:00.572066Z 0 [ERROR] Aborting

Note that even though you've set a password for the root MySQL user, this user is not configured to authenticate with a password when connecting to the MySQL shell. If you'd like, you can adjust this setting by following Step 3.

Step 3 - (Optional) Adjusting User Authentication and Privileges

In Ubuntu systems running MySQL 5.7 (and later versions), the root MySQL user is set to authenticate using the auth_socket plugin by default rather than with a password. This allows for some greater security and usability in many cases, but it can also complicate things when you need to allow an external program (e.g., phpMyAdmin) to access the user.

In order to use a password to connect to MySQL as root, you will need to switch its authentication method from auth_socket to mysql_native_password. To do this, open up the MySQL prompt from your terminal:

Next, check which authentication method each of your MySQL user accounts use with the following command:

+------------------+-------------------------------------------+-----------------------+-----------+ | user | authentication_string | plugin | host | +------------------+-------------------------------------------+-----------------------+-----------+ | root | | auth_socket | localhost | | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | | debian-sys-maint | *CC744277A401A7D25BE1CA89AFF17BF607F876FF | mysql_native_password | localhost | +------------------+-------------------------------------------+-----------------------+-----------+ 4 rows in set (0.00 sec)

In this example, you can see that the root user does in fact authenticate using the auth_socket plugin. To configure the root account to authenticate with a password, run the following ALTER USER command. Be sure to change to a strong password of your choosing, and note that this command will change the root password you set in Step 2:

ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';

Then, run FLUSH PRIVILEGES which tells the server to reload the grant tables and put your new changes into effect:

Check the authentication methods employed by each of your users again to confirm that root no longer authenticates using the auth_socket plugin:

+------------------+-------------------------------------------+-----------------------+-----------+ | user | authentication_string | plugin | host | +------------------+-------------------------------------------+-----------------------+-----------+ | root | *3636DACC8616D997782ADD0839F92C1571D6D78F | mysql_native_password | localhost | | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | | debian-sys-maint | *CC744277A401A7D25BE1CA89AFF17BF607F876FF | mysql_native_password | localhost | +------------------+-------------------------------------------+-----------------------+-----------+ 4 rows in set (0.00 sec)

You can see in this example output that the root MySQL user now authenticates using a password. Once you confirm this on your own server, you can exit the MySQL shell:

Alternatively, some may find that it better suits their workflow to connect to MySQL with a dedicated user. To create such a user, open up the MySQL shell once again:

From there, create a new user and give it a strong password:

Then, grant your new user the appropriate privileges. For example, you could grant the user privileges to all tables within the database, as well as the power to add, change, and remove user privileges, with this command:

GRANT ALL PRIVILEGES ON *.* TO 'sammy'@'localhost' WITH GRANT OPTION;

Note that, at this point, you do not need to run the FLUSH PRIVILEGES command again. This command is only needed when you modify the grant tables using statements like INSERT, UPDATE, or DELETE. Because you created a new user, instead of modifying an existing one, FLUSH PRIVILEGES is unnecessary here.

Following this, exit the MySQL shell:

Finally, let's test the MySQL installation.

Step 4 - Testing MySQL

Regardless of how you installed it, MySQL should have started running automatically. To test this, check its status.

You'll see output similar to the following:

● mysql.service - MySQL Community Server Loaded: loaded (/lib/systemd/system/mysql.service; enabled; vendor preset: en Active: active (running) since Wed 2018-04-23 21:21:25 UTC; 30min ago Main PID: 3754 (mysqld) Tasks: 28 Memory: 142.3M CPU: 1.994s CGroup: /system.slice/mysql.service └─3754 /usr/sbin/mysqld

If MySQL isn't running, you can start it with sudo systemctl start mysql.

For an additional check, you can try connecting to the database using the mysqladmin tool, which is a client that lets you run administrative commands. For example, this command says to connect to MySQL as root (-u root), prompt for a password (-p), and return the version.

You should see output similar to this:

mysqladmin Ver 8.42 Distrib 5.7.21, for Linux on x86_64 Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Server version 5.7.21-1ubuntu1 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /var/run/mysqld/mysqld.sock Uptime: 30 min 54 sec Threads: 1 Questions: 12 Slow queries: 0 Opens: 115 Flush tables: 1 Open tables: 34 Queries per second avg: 0.006

This means MySQL is up and running.

Conclusion

You now have a basic MySQL setup installed on your server. Here are a few examples of next steps you can take:

# data[].attributes.attachment_link.title
How To Install MySQL on Ubuntu 18.04 | DigitalOcean

# data[].attributes.attachment_link.description
MySQL is an open-source database management system, commonly installed as part of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. It uses a relational database and SQL (Structured Query Language) to manage its data. The short version of the installation is simple: update your package index, install the mysql-server package, and then run the included security script.

# data[].attributes.body
- voldoende: 1 t/m 6
- goed: 1 t/m 9
- uitstekend 1 t/m 10

# data[].attributes.attachment_link.title
Learn Basics of Ubuntu directory structure

# data[].attributes.attachment_link.description
Hellow my name is Vipul kumar. And i am going to tell you about Basics of Ubuntu Linux, for new comers .1st let me tell you, you shud know about Directory structure in ubuntu linux.

# data[].attributes.attachment_link.readable_text
In this tutorial, we'll provide a step by step instructions about how to set up Apache Virtual Hosts on Ubuntu 18.04.

Apache Virtual Hosts allows you to run more than one website on a single machine. With Virtual Hosts, you can specify the site document root (the directory which contains the website files), create a separate security policy for each site, use different SSL certificates and much more.

Although this tutorial is written for Ubuntu 18.04 Bionic Beaver the same steps can be used for Ubuntu 16.04 Xenial Xerus.

Prerequisites

Make sure that you have met the following prerequisites before continuing with this tutorial:

Create the Directory Structure

Document root is the directory where the website files for a domain name are stored and served in response to requests. You can set the document root to any location you want but in this guide we will use the following directory structure:

/var/www/ ├── domain1.com │   └── public_html ├── domain2.com │   └── public_html ├── domain3.com │   └── public_html

Basically we will create a separate directory for each domain we want to host on our server inside the /var/www directory. Within each of these directories, we will create a public_html directory that will store the domain website files.

Let's create the root directory for the example.com domain:

sudo mkdir -p /var/www/example.com/public_html

For testing purposes we will also create an index.html file inside the domain document root directory.

Open your editor and create the demo file:

/var/www/example.com/public_html/index.html

In this guide, we are running the commands as a sudo user and the newly created files and directories are owned by the root user.

To avoid any permission issues we can change the ownership of the domain document root directory to the apache user ( www-data) :

sudo chown -R www-data: /var/www/example.com

Create a Virtual Hosts

By default on Ubuntu systems, Apache Virtual Hosts configuration files are stored in /etc/apache2/sites-available directory and can be enabled by creating symbolic links to the /etc/apache2/sites-enabled directory.

Open your editor of choice and create the following basic Virtual Host configuration file:

/etc/apache2/sites-available/example.com.conf

<VirtualHost *:80 > ServerName example.com ServerAlias www.example.com ServerAdmin [email protected] DocumentRoot /var/www/example.com/public_html <Directory /var/www/example.com/public_html > Options -Indexes +FollowSymLinks AllowOverride All </Directory> ErrorLog ${APACHE_LOG_DIR}/example.com-error.log CustomLog ${APACHE_LOG_DIR}/example.com-access.log combined </VirtualHost>

ServerName: The domain that should match for this virtual host configuration. This should be your domain name.

ServerAlias: All other domains that should match for this virtual host as well, such as the www subdomain.

DocumentRoot: The directory from which Apache will serve the domain files.

Options: This directive controls which server features are available in a specific directory.

-Indexes: Prevents directory listings.

FollowSymLinks: This option tells your web server to follow the symbolic links.

AllowOverride: Specifies which directives declared in the .htaccess file can override the configuration directives.

ErrorLog, CustomLog: Specifies the location for log files.

You can name the configuration file as you like but the best practice is to use the domain name as the name of the virtual host configuration file.

To enable the new virtual host file we need to create a symbolic link from the virtual host file to the sites-enabled directory, which is read by apache2 during startup.

The easiest way to enable the virtual host is by using the a2ensite helper:

The other option is to manually create a symlink as shown below:

sudo ln -s /etc/apache2/sites-available/example.com.conf /etc/apache2/sites-enabled/

Once the configuration is enabled test if the syntax is correct with:

sudo apachectl configtest

If there are no errors your will see the following output:

In order for the changes to take effect, restart the apache2 service with:

sudo systemctl restart apache2

Finally to verify that everything is working as expected, open http://example.com in your browser of choice, and you will see something like this:

Conclusion

You have learned how to create an apache virtual host configuration to host multiple domains on a single Ubuntu server. You can repeat the steps we outlined above and create additional virtual hosts for all your domains.

If you are facing any problem, feel free to leave a comment.

# data[].attributes.attachment_link.title
How To Set Up Apache Virtual Hosts on Ubuntu 18.04

# data[].attributes.attachment_link.description
In this tutorial, we'll provide a step by step instructions about how to set up Apache Virtual Hosts on Ubuntu 18.04. Apache Virtual Hosts allows you to run more than one website on a single machine.

# data[].attributes.attachment_link.readable_text
Introduction

A "LAMP" stack is a group of open-source software that is typically installed together to enable a server to host dynamic websites and web apps. This term is actually an acronym which represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by P HP.

In this guide, we will install a LAMP stack on an Ubuntu 18.04 server.

Prerequisites

In order to complete this tutorial, you will need to have an Ubuntu 18.04 server with a non-root sudo-enabled user account and a basic firewall. This can be configured using our initial server setup guide for Ubuntu 18.04.

Step 1 - Installing Apache and Updating the Firewall

The Apache web server is among the most popular web servers in the world. It's well-documented and has been in wide use for much of the history of the web, which makes it a great default choice for hosting a website.

Install Apache using Ubuntu's package manager, apt:

Since this is a sudo command, these operations are executed with root privileges. It will ask you for your regular user's password to verify your intentions.

Once you've entered your password, apt will tell you which packages it plans to install and how much extra disk space they'll take up. Press Y and hit ENTER to continue, and the installation will proceed.

Adjust the Firewall to Allow Web Traffic

Next, assuming that you have followed the initial server setup instructions and enabled the UFW firewall, make sure that your firewall allows HTTP and HTTPS traffic. You can check that UFW has an application profile for Apache like so:

Available applications: Apache Apache Full Apache Secure OpenSSH

If you look at the Apache Full profile, it should show that it enables traffic to ports 80 and 443:

Profile: Apache Full Title: Web Server (HTTP,HTTPS) Description: Apache v2 is the next generation of the omnipresent Apache web server. Ports: 80,443/tcp

Allow incoming HTTP and HTTPS traffic for this profile:

You can do a spot check right away to verify that everything went as planned by visiting your server's public IP address in your web browser (see the note under the next heading to find out what your public IP address is if you do not have this information already):

You will see the default Ubuntu 18.04 Apache web page, which is there for informational and testing purposes. It should look something like this:

If you see this page, then your web server is now correctly installed and accessible through your firewall.

How To Find your Server's Public IP Address

If you do not know what your server's public IP address is, there are a number of ways you can find it. Usually, this is the address you use to connect to your server through SSH.

There are a few different ways to do this from the command line. First, you could use the iproute2 tools to get your IP address by typing this:

This will give you two or three lines back. They are all correct addresses, but your computer may only be able to use one of them, so feel free to try each one.

An alternative method is to use the curl utility to contact an outside party to tell you how it sees your server. This is done by asking a specific server what your IP address is:

Regardless of the method you use to get your IP address, type it into your web browser's address bar to view the default Apache page.

Step 2 - Installing MySQL

Now that you have your web server up and running, it is time to install MySQL. MySQL is a database management system. Basically, it will organize and provide access to databases where your site can store information.

Again, use apt to acquire and install this software:

Note: In this case, you do not have to run sudo apt update prior to the command. This is because you recently ran it in the commands above to install Apache. The package index on your computer should already be up-to-date.

This command, too, will show you a list of the packages that will be installed, along with the amount of disk space they'll take up. Enter Y to continue.

When the installation is complete, run a simple security script that comes pre-installed with MySQL which will remove some dangerous defaults and lock down access to your database system. Start the interactive script by running:

This will ask if you want to configure the VALIDATE PASSWORD PLUGIN.

Note: Enabling this feature is something of a judgment call. If enabled, passwords which don't match the specified criteria will be rejected by MySQL with an error. This will cause issues if you use a weak password in conjunction with software which automatically configures MySQL user credentials, such as the Ubuntu packages for phpMyAdmin. It is safe to leave validation disabled, but you should always use strong, unique passwords for database credentials.

Answer Y for yes, or anything else to continue without enabling.

VALIDATE PASSWORD PLUGIN can be used to test passwords and improve security. It checks the strength of password and allows the users to set only those passwords which are secure enough. Would you like to setup VALIDATE PASSWORD plugin? Press y|Y for Yes, any other key for No:

If you answer "yes", you'll be asked to select a level of password validation. Keep in mind that if you enter 2 for the strongest level, you will receive errors when attempting to set any password which does not contain numbers, upper and lowercase letters, and special characters, or which is based on common dictionary words.

There are three levels of password validation policy: LOW Length >= 8 MEDIUM Length >= 8, numeric, mixed case, and special characters STRONG Length >= 8, numeric, mixed case, special characters and dictionary file Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1

Regardless of whether you chose to set up the VALIDATE PASSWORD PLUGIN, your server will next ask you to select and confirm a password for the MySQL root user. This is an administrative account in MySQL that has increased privileges. Think of it as being similar to the root account for the server itself (although the one you are configuring now is a MySQL-specific account). Make sure this is a strong, unique password, and do not leave it blank.

If you enabled password validation, you'll be shown the password strength for the root password you just entered and your server will ask if you want to change that password. If you are happy with your current password, enter N for "no" at the prompt:

Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

For the rest of the questions, press Y and hit the ENTER key at each prompt. This will remove some anonymous users and the test database, disable remote root logins, and load these new rules so that MySQL immediately respects the changes you have made.

Note that in Ubuntu systems running MySQL 5.7 (and later versions), the root MySQL user is set to authenticate using the auth_socket plugin by default rather than with a password. This allows for some greater security and usability in many cases, but it can also complicate things when you need to allow an external program (e.g., phpMyAdmin) to access the user.

If you prefer to use a password when connecting to MySQL as root, you will need to switch its authentication method from auth_socket to mysql_native_password. To do this, open up the MySQL prompt from your terminal:

Next, check which authentication method each of your MySQL user accounts use with the following command:

+------------------+-------------------------------------------+-----------------------+-----------+ | user | authentication_string | plugin | host | +------------------+-------------------------------------------+-----------------------+-----------+ | root | | auth_socket | localhost | | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | | debian-sys-maint | *CC744277A401A7D25BE1CA89AFF17BF607F876FF | mysql_native_password | localhost | +------------------+-------------------------------------------+-----------------------+-----------+ 4 rows in set (0.00 sec)

In this example, you can see that the root user does in fact authenticate using the auth_socket plugin. To configure the root account to authenticate with a password, run the following ALTER USER command. Be sure to change to a strong password of your choosing:

Then, run FLUSH PRIVILEGES which tells the server to reload the grant tables and put your new changes into effect:

Check the authentication methods employed by each of your users again to confirm that root no longer authenticates using the auth_socket plugin:

+------------------+-------------------------------------------+-----------------------+-----------+ | user | authentication_string | plugin | host | +------------------+-------------------------------------------+-----------------------+-----------+ | root | *3636DACC8616D997782ADD0839F92C1571D6D78F | mysql_native_password | localhost | | mysql.session | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | | mysql.sys | *THISISNOTAVALIDPASSWORDTHATCANBEUSEDHERE | mysql_native_password | localhost | | debian-sys-maint | *CC744277A401A7D25BE1CA89AFF17BF607F876FF | mysql_native_password | localhost | +------------------+-------------------------------------------+-----------------------+-----------+ 4 rows in set (0.00 sec)

You can see in this example output that the root MySQL user now authenticates using a password. Once you confirm this on your own server, you can exit the MySQL shell:

At this point, your database system is now set up and you can move on to installing PHP, the final component of the LAMP stack.

Step 3 - Installing PHP

PHP is the component of your setup that will process code to display dynamic content. It can run scripts, connect to your MySQL databases to get information, and hand the processed content over to your web server to display.

Once again, leverage the apt system to install PHP. In addition, include some helper packages this time so that PHP code can run under the Apache server and talk to your MySQL database:

This should install PHP without any problems. We'll test this in a moment.

In most cases, you will want to modify the way that Apache serves files when a directory is requested. Currently, if a user requests a directory from the server, Apache will first look for a file called index.html. We want to tell the web server to prefer PHP files over others, so make Apache look for an index.php file first.

To do this, type this command to open the dir.conf file in a text editor with root privileges:

It will look like this:

/etc/apache2/mods-enabled/dir.conf

<IfModule mod_dir.c> DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm </IfModule>

Move the PHP index file (highlighted above) to the first position after the DirectoryIndex specification, like this:

/etc/apache2/mods-enabled/dir.conf

<IfModule mod_dir.c> DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm </IfModule>

When you are finished, save and close the file by pressing CTRL+X. Confirm the save by typing Y and then hit ENTER to verify the file save location.

After this, restart the Apache web server in order for your changes to be recognized. Do this by typing this:

You can also check on the status of the apache2 service using systemctl:

● apache2.service - LSB: Apache2 web server Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled) Drop-In: /lib/systemd/system/apache2.service.d └─apache2-systemd.conf Active: active (running) since Tue 2018-04-23 14:28:43 EDT; 45s ago Docs: man:systemd-sysv-generator(8) Process: 13581 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCESS) Process: 13605 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCCESS) Tasks: 6 (limit: 512) CGroup: /system.slice/apache2.service ├─13623 /usr/sbin/apache2 -k start ├─13626 /usr/sbin/apache2 -k start ├─13627 /usr/sbin/apache2 -k start ├─13628 /usr/sbin/apache2 -k start ├─13629 /usr/sbin/apache2 -k start └─13630 /usr/sbin/apache2 -k start

Press Q to exit this status output.

To enhance the functionality of PHP, you have the option to install some additional modules. To see the available options for PHP modules and libraries, pipe the results of apt search into less, a pager which lets you scroll through the output of other commands:

Use the arrow keys to scroll up and down, and press Q to quit.

The results are all optional components that you can install. It will give you a short description for each:

bandwidthd-pgsql/bionic 2.0.1+cvs20090917-10ubuntu1 amd64 Tracks usage of TCP/IP and builds html files with graphs bluefish/bionic 2.2.10-1 amd64 advanced Gtk+ text editor for web and software development cacti/bionic 1.1.38+ds1-1 all web interface for graphing of monitoring systems ganglia-webfrontend/bionic 3.6.1-3 all cluster monitoring toolkit - web front-end golang-github-unknwon-cae-dev/bionic 0.0~git20160715.0.c6aac99-4 all PHP-like Compression and Archive Extensions in Go haserl/bionic 0.9.35-2 amd64 CGI scripting program for embedded environments kdevelop-php-docs/bionic 5.2.1-1ubuntu2 all transitional package for kdevelop-php kdevelop-php-docs-l10n/bionic 5.2.1-1ubuntu2 all transitional package for kdevelop-php-l10n ... :

To learn more about what each module does, you could search the internet for more information about them. Alternatively, look at the long description of the package by typing:

There will be a lot of output, with one field called Description which will have a longer explanation of the functionality that the module provides.

For example, to find out what the php-cli module does, you could type this:

Along with a large amount of other information, you'll find something that looks like this:

... Description: command-line interpreter for the PHP scripting language (default) This package provides the /usr/bin/php command interpreter, useful for testing PHP scripts from a shell or performing general shell scripting tasks. . PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used open source general-purpose scripting language that is especially suited for web development and can be embedded into HTML. . This package is a dependency package, which depends on Ubuntu's default PHP version (currently 7.2). ...

If, after researching, you decide you would like to install a package, you can do so by using the apt install command like you have been doing for the other software.

If you decided that php-cli is something that you need, you could type:

If you want to install more than one module, you can do that by listing each one, separated by a space, following the apt install command, like this:

At this point, your LAMP stack is installed and configured. Before you do anything else, we recommend that you set up an Apache virtual host where you can store your server's configuration details.

Step 4 - Setting Up Virtual Hosts (Recommended)

When using the Apache web server, you can use virtual hosts (similar to server blocks in Nginx) to encapsulate configuration details and host more than one domain from a single server. We will set up a domain called your_domain, but you should replace this with your own domain name. To learn more about setting up a domain name with DigitalOcean, see our Introduction to DigitalOcean DNS.

Apache on Ubuntu 18.04 has one server block enabled by default that is configured to serve documents from the /var/www/html directory. While this works well for a single site, it can become unwieldy if you are hosting multiple sites. Instead of modifying /var/www/html, let's create a directory structure within /var/www for our your_domain site, leaving /var/www/html in place as the default directory to be served if a client request doesn't match any other sites.

Create the directory for your_domain as follows:

sudo mkdir /var/www/your_domain

Next, assign ownership of the directory with the $USER environment variable:

The permissions of your web roots should be correct if you haven't modified your unmask value, but you can make sure by typing:

Next, create a sample index.html page using nano or your favorite editor:

Inside, add the following sample HTML:

/var/www/your_domain/index.html

<html> <head> <title>Welcome to Your_domain!</title> </head> <body> <h1>Success! The your_domain server block is working!</h1> </body> </html>

Save and close the file when you are finished.

In order for Apache to serve this content, it's necessary to create a virtual host file with the correct directives. Instead of modifying the default configuration file located at /etc/apache2/sites-available/000-default.conf directly, let's make a new one at /etc/apache2/sites-available/your_domain.conf:

Paste in the following configuration block, which is similar to the default, but updated for our new directory and domain name:

/etc/apache2/sites-available/your_domain.conf

<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName your_domain ServerAlias www.your_domain DocumentRoot /var/www/your_domain ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>

Notice that we've updated the DocumentRoot to our new directory and ServerAdmin to an email that the your_domain site administrator can access. We've also added two directives: ServerName, which establishes the base domain that should match for this virtual host definition, and ServerAlias, which defines further names that should match as if they were the base name.

Save and close the file when you are finished.

Let's enable the file with the a2ensite tool:

Disable the default site defined in 000-default.conf:

Next, let's test for configuration errors:

You should see the following output:

Restart Apache to implement your changes:

Apache should now be serving your domain name. You can test this by navigating to http://your_domain , where you should see something like this:

With that, you virtual host is fully set up. Before making any more changes or deploying an application, though, it would be helpful to proactively test out your PHP configuration in case there are any issues that should be addressed.

Step 5 - Testing PHP Processing on your Web Server

In order to test that your system is configured properly for PHP, create a very basic PHP script called info.php. In order for Apache to find this file and serve it correctly, it must be saved to your web root directory.

Create the file at the web root you created in the previous step by running:

This will open a blank file. Add the following text, which is valid PHP code, inside the file:

<?php phpinfo(); ?>

When you are finished, save and close the file.

Now you can test whether your web server is able to correctly display content generated by this PHP script. To try this out, visit this page in your web browser. You'll need your server's public IP address again.

The address you will want to visit is:

http://your_domain/info.php

The page that you come to should look something like this:

This page provides some basic information about your server from the perspective of PHP. It is useful for debugging and to ensure that your settings are being applied correctly.

If you can see this page in your browser, then your PHP is working as expected.

You probably want to remove this file after this test because it could actually give information about your server to unauthorized users. To do this, run the following command:

You can always recreate this page if you need to access the information again later.

Conclusion

Now that you have a LAMP stack installed, you have many choices for what to do next. Basically, you've installed a platform that will allow you to install most kinds of websites and web software on your server.

As an immediate next step, you should ensure that connections to your web server are secured, by serving them via HTTPS. The easiest option here is to use Let's Encrypt to secure your site with a free TLS/SSL certificate.

Some other popular options are:

# data[].attributes.attachment_link.title
How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 18.04 | DigitalOcean

# data[].attributes.attachment_link.description
A 'LAMP' stack is a group of open source software that is typically installed together to enable a server to host dynamic websites and web apps. This stack typically consists of the Linux operating system, the Apache web server, a MySQL database, and