Servername Ostechnix1.Lan Serveralias WWW - Ostechnix1.Lan Documentroot /Var/Www/Html/Ostechnix1.Lan

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

LAMP Server with PhpMyAdmin installation in Ubuntu 18.

04

Apache Installation
sudo apt update
sudo apt install apache2
sudo systemctl status apache2
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw reload

Hide Apache Version


By default, Apache displays the version of your Apache web server installed on your system
with the name of the operating system of your server.
sudo nano /etc/apache2/conf-enabled/security.conf
Add/edit the following line:
ServerSignature Off
ServerTokens Prod
Create configuration file for each host

sudo cp /etc/apache2/sites-available/000-default.conf
/etc/apache2/sites-available/site.in.conf

sudo vi /etc/apache2/sites-available/site.in.conf

ServerAdmin [email protected]

ServerName ostechnix1.lan
ServerAlias www.ostechnix1.lan
DocumentRoot /var/www/html/ostechnix1.lan/

sudo a2dissite 000-default.conf

sudo a2ensite ostechnix1.lan.conf

sudo systemctl restart apache2

Disable Directory Listing and FollowSymLinks

sudo nano /etc/apache2/apache2.conf

Add/edit the following line:


<Directory /var/www/>

Options -Indexes -FollowSymLinks


AllowOverride None
Require all granted
</Directory>
Mysql installation & root user creation
sudo apt install mysql-server
sudo mysql_secure_installation

Starting from MySQL 5.7, root login requires sudo command, therefore the root login will fail via
phpmyadmin, you may need to create another admin user account.

sudo mysql
CREATE USER '<user>'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO '<user>'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
SELECT User FROM mysql.user; <To list all users>
DROP USER '<user>'@'localhost'; <To delete user>
ALTER USER 'userName'@'localhost' IDENTIFIED BY 'New-Password-Here'; <To
change password>
exit
systemctl status mysql.service

PHP & phpMyAdmin installtion


sudo apt install php php-common php-mysql php-gd php-cli
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/infoV1.php
sudo apt install phpmyadmin
sudo systemctl restart apache2

Obscure phpMyAdmin URL


sudo nano /etc/apache2/conf-available/phpmyadmin.conf
Alias /<url> /usr/share/phpmyadmin <Change url as needed Planteap>
sudo service apache2 reload
Protect with .htpasswd
sudo nano /etc/apache2/conf-available/phpmyadmin.conf
Add AllowOverride All underneath DirectoryIndex index.php
sudo service apache2 reload
sudo nano /usr/share/phpmyadmin/.htaccess
<Paste in the following.>
AuthType Basic
AuthName "Restricted Access"
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user

sudo htpasswd -c /etc/phpmyadmin/.htpasswd <user>

You might also like