= Apache Web Server Installation = === perfSONAR Installation Options === First update the Ubuntu package repository. {{{ sudo apt update }}} Then install the web server. {{{ sudo apt install apache2 }}} Check the apache version {{{ apache2 -v }}} Now visit your server through the IP address. http://server_ip_address. [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web1.png)]] = PHP Installation = Then install PHP and related modules for apache server and MariaDB. {{{ sudo apt install php libapache2-mod-php php-mysql }}} To test that your system is properly configured for PHP, create a PHP script called info.php. Here we will create at the root directory. {{{ sudo nano /var/www/html/info.php }}} Insert the following command to show the php information. {{{ }}} Next go to http://your_IP/info.php URL and you will get page like below, [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web5.png)]] = MariaDB DBMS Installation = Here we will choose MariaDB DBMS as our database application. Install this using below command. {{{ sudo apt install mariadb-server mariadb-client }}} Once installed check the version, {{{ mysql --version }}} For mysql there is a script that strengthen the mariaDB server security. It is a series of yes no questions which removes initial weaknesses of the server. To execute the scripts, {{{ sudo mysql_secure_installation }}} [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web2.png)]] To login MariaDB enter below command and use the password entered above. {{{ sudo mysql -u root -p }}} [[Image(https://ws.learn.ac.lk/raw-attachment/wiki/Csle2022/Agenda/databaseandweb/web3.png)]] To exit type, {{{ exit }}} = Apache Virtual Hosting = Using virtual hosts, one Apache instance can serve multiple websites. Each domain or individual site that is configured using Apache will direct the visitor to a specific directory holding that site’s information. This is done without indicating to the visitor that the same server is also responsible for other sites. Note: Before creating a virtual host for a web site domain, the particular domain or subdomain should be created. For this please contact your domain manager of your institutional IT department or relevant domain company. Then this domain should be assigned a DNS entry (A or AAAA record) to work on a web browser. In our case DNS entry should be pointed to your server IP. Presuming you meet the prerequisites below will be the steps to create virtual hosts. First you need to create a appropriate directory structure for each website hosted under each domain. By default root web directory in a Ubuntu system will be /var/www/html. For our setup we will use below directory structure for each site. web site for domain 1 - /var/www/your_domain_1/public_html web site for domain 2 - /var/www/your_domain_2/public_html web site for domain 3 - /var/www/your_domain_3/public_html In our example we hope to create three subdomains called web,sales and lms. So the full domain names will be web.your_domain.com, sales.your_domain.com and lms.your_domain.com respectively. Use these commands, with your own domain names, to create your directories: {{{ sudo mkdir -p /var/www/web.your_domain/public_html sudo mkdir -p /var/www/sales.your_domain/public_html sudo mkdir -p /var/www/lms.your_domain/public_html }}} We are going to install moodle under lms subdomain. For other two domains we will create dummy web pages for each. {{{ sudo nano /var/www/web.your_domain/public_html/index.html }}} {{{