Ubuntu Command for LAMP Setup and Configuration
LAMP stands for Linux, Apache, MySQL & PHP. I added the basic command and steps for LAMP Set up and Configuration
Basic Setup
sudo apt update && sudo apt install apache2 -y && sudo apt install mysql-server -y && sudo apt install php libapache2-mod-php php-mysql -y
sudo apt update : will update your system &
sudo apt install apache2 -y : will install apache2&
sudo apt install mysql-server -y : will install MySQL &
sudo apt install php libapache2-mod-php php-mysql -y : will install PHP latest version.
Change to Root User
sudo su -
or
sudo -i
Enable MB String
sudo apt install php-mbstring
Enable XML
sudo apt install php-xml
Update Apache Version To Lastest
sudo add-apt-repository ppa:ondrej/apache2 sudo apt updatesudo apt install apache2
Check PHP Version
php -v
Check Apache Version
apache2 -v
Enable Rewrite Module
sudo a2enmod rewrite
Enable Header Module
sudo a2enmod headers
Install Curl
sudo apt-get install php-curl
Apache2 restart
sudo service apache2 restart
systemctl restart apache2
Check Error Log
sudo tail -f /var/log/apache2/error.log
Enable HSTS in
other-vhosts-access-log.conf
Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"
Default set 404 Page in other-vhosts-access-log.conf
<VirtualHost *:80>ServerName default
Redirect 404 /
</VirtualHost>
Website Setup in other-vhosts-access-log.conf
<VirtualHost *:80 *:443>
DocumentRoot /var/www/html/abc.thriwe.com
ServerName abc.thriwe.com
ServerAlias abc.thriwe.com
<Directory /var/www/html/abc.thriwe.com >
Options FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
RewriteEngine On
# SSL connection forced
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?args=$1 [L,QSA]
</Directory>
LogLevel warn
</VirtualHost>
Basic Commands
Location change : Cd /foldername/foldername
Location Change(If already at some location and want to access folder at that location) : Cd foldername
Files info in folder : ll
Files names in folder : ls
Edit file : Sudo nano filename
save/override file : Ctrl + o + enter
Exit File : Ctrl + x
Exit Command : Ctrl + Z
Change File/Folder to full permission
sudo chmod -R 0777 foldername or file