Monday, October 23, 2023

How To Install Linux, Apache, MySQL, PHP (LAMP)

 sudo apt update


sudo apt install apache2


sudo ufw app list

Output
Available applications: Apache Apache Full Apache Secure OpenSSH


sudo ufw allow in "Apache"


sudo ufw status

Output
Status: active To Action From -- ------ ---- OpenSSH ALLOW Anywhere Apache ALLOW Anywhere OpenSSH (v6) ALLOW Anywhere (v6) Apache (v6) ALLOW Anywhere (v6)


Apache installed 


sudo apt install mysql-server

sudo mysql_secure_installation

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:


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


Estimated strength of the password: 100 
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y


sudo mysql


exit

mysql installed


create new user in mysql

mysql -u root -p

CREATE USER 'sammy'@'localhost' IDENTIFIED BY 'password';

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

FLUSH PRIVILEGES;


if mysql give error 

your-password-does-not-satisfy-the-current-policy-requirements


SHOW VARIABLES LIKE 'validate_password%';
mysql> SET GLOBAL validate_password.length = 4;
mysql> SET GLOBAL validate_password.policy=LOW;


Database import command

mysql -u username -p new_database < data-dump.sql


PHP Install steps


sudo apt install php libapache2-mod-php php-mysql

php -v


php installed



creating-a-virtual-host-for-your-website

sudo mkdir /var/www/your_domain


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


<VirtualHost *:80>

    ServerName your_domain

    ServerAlias www.your_domain 

    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/your_domain

    ErrorLog ${APACHE_LOG_DIR}/error.log

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>



sudo a2ensite your_domain


sudo apache2ctl configtest


sudo systemctl reload apache2



Host File entry


Path C:\Windows\System32\drivers\etc

Hosts named file 


127.0.0.1       localhost

Your Ip        Domain name






No comments:

Post a Comment