sudo apt-get update
//1.LAMP
sudo apt-get install apache2
sudo apt-get install php
php -v
sudo apt-get install libapache2-mod-php //php libs for apache2
sudo apt-get install mysql-servermysql-secure-installation //install mysql server
mysql -hlocalhost -uroot -ppwd //check
sudo apt-get install php7.0-mysql //php support mysql
sudo service mysql restart
sudo service apache2 restart
sudo apt-get install php-mcrypt php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc php-gettext //php modules
sudo chmod 777 /var/www/html // aparche2 html root dir permissions
sudo apt-get install phpmyadin //gui mysql manager and need php-mbstring php and php-gettext
sudo gedit /etc/apache2/apache2.conf //add 'ServerName server_domain_or_ip'in apache2.conf
sudo gedit /etc/apache2/mods-enabled/dir.conf //modify default page from index.html to index.php
sudo systemctl restart apache2
sudo systemctl status apache2 //check on the status of apache2 service
sudo apache2ctl configtest //syntax ok verity server name
sudo ufw app list //firwall app list
sudo ufw app info "Apache2 Full" //watch ports 80,443/tcp
sudo ufw allow in "Apache2 Full" //allow apache2 in firwall