Skip to content

Instantly share code, notes, and snippets.

@Rafat97
Last active January 13, 2021 15:13
Show Gist options
  • Save Rafat97/b2c6d3ee3f8328c1fb21e86c0060b20a to your computer and use it in GitHub Desktop.
Save Rafat97/b2c6d3ee3f8328c1fb21e86c0060b20a to your computer and use it in GitHub Desktop.

😭 Some important commend for web server setup 😭

******************************************************************
Apache install
******************************************************************
sudo apt-get update
sudo apt-get install apache2
******************************************************************
Mysql install
******************************************************************
sudo apt update && sudo apt install mysql-server
sudo mysql_secure_installation
******************************************************************
PHP install
******************************************************************
sudo apt-get install php libapache2-mod-php php-mysql php-curl php-gd php-json php-zip php-mbstring
sudo service apache2 restart
******************************************************************
PhpMyAdmin install
******************************************************************
sudo apt update && sudo apt install phpmyadmin
sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
sudo a2enconf phpmyadmin.conf
sudo service apache2 reload
```
sudo su
apt-get update
apt-get upgrade -y
apt-get dist-upgrade -y
apt-get autoremove -y
apt-get install apache2 php7.0 php7.0-cli php7.0-fpm php7.0-gd php-ssh2 libapache2-mod-php7.0 php7.0-mcrypt mysql-server php7.0-mysql git unzip zip postfix php7.0-curl mailutils php7.0-json phpmyadmin -y
php5enmod mcrypt
nano /etc/apache2/sites-enabled/000-default.conf
--ADD LINE--
Include /etc/phpmyadmin/apache.conf
service apache2 restart
nano /etc/phpmyadmin/config.inc.php
--ADD LINES BELOW THE PMA CONFIG AREA AND FILL IN DETAILS--
$i++;
$cfg['Servers'][$i]['host'] = '__FILL_IN_DETAILS__';
$cfg['Servers'][$i]['port'] = '3306';
$cfg['Servers'][$i]['socket'] = '';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['extension'] = 'mysql';
$cfg['Servers'][$i]['compress'] = FALSE;
$cfg['Servers'][$i]['auth_type'] = 'config';
$cfg['Servers'][$i]['user'] = '__FILL_IN_DETAILS__';
$cfg['Servers'][$i]['password'] = '__FILL_IN_DETAILS__';
```
sudo apt-get update
sudo apt-get upgrade
Install apache2:
sudo apt-get install apache2
Activing firewall:
sudo ufw status verbose
default:
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw app list
sudo ufw allow 'Apache Full'
(to allow 80, 443)
sudo ufw allow 'OpenSSH'
(to allow 22 (sftp, ssh))
sudo ufw enable
Install mysql:
sudo apt-get install mysql-server
sudo mysql_secure_installation
(no, yes, no, yes, yes)
sudo mysql -u root -p
Install PHP:
sudo apt-get install php libapache2-mod-php
sudo apt-get install php-mysql php-curl php-gd php-json php-zip php-mbstring
Install php-mcrypt:
php -m | grep mcrypt
sudo apt install php-dev libmcrypt-dev php-pear
sudo pecl channel-update pecl.php.net
sudo pecl install mcrypt-1.0.1
sudo nano /etc/php/7.2/cli/php.ini
(add "extension=mcrypt.so")
php -m | grep mcrypt
Restarting apache2:
sudo service apache2 restart
cd /var/www/html
ls
index.html
sudo nano /var/www/html/index.php
<?php
phpinfo();
?>
Install phpmyadmin:
sudo apt-get install phpmyadmin
phpmyadmin with mysql (to get access with root):
sudo mysql -u root -p
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '321@new';
FLUSH PRIVILEGES;
Installing certbot:
sudo add-apt-repository ppa:certbot/certbot
sudo apt install python-certbot-apache
sudo apt-get install unzip
To config test:
sudo apache2ctl configtest
To grant all permissions:
sudo chmod -R 755 /var/www
sudo chmod -R a+rwx /var/www
sudo chmod -R 755 /var/www
sudo mkdir -p /var/www/amarischool
sudo chown -R $USER:$USER /var/www/amarischool
sudo chmod -R 755 /var/www
sudo nano /var/www/test/index.php
<?php
echo "<h1>virtual host is 0k</h1>";
echo date("Y-m-d h:i:sA");
?>
sudo nano /etc/apache2/sites-available/000-test.org.conf
<VirtualHost *:80>
ServerAdmin hoosain.sajjad@gmail.com
ServerName adroitmedia.net
DocumentRoot /var/www/test
<Directory /var/www/test>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo apache2ctl configtest
sudo a2ensite 000-test.org.conf
sudo a2dissite 000-default.conf
sudo service apache2 restart
sudo systemctl reload apache2
sudo nano /etc/apache2/sites-available/adroitmedia.net.conf
<VirtualHost *:80>
ServerAdmin hoosain.sajjad@gmail.com
ServerName adroitmedia.net
DocumentRoot /var/www/amarischool
<Directory /var/www/amarischool>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo nano /etc/apache2/sites-available/umipbd.com.conf
<VirtualHost *:80>
ServerAdmin hoosain.sajjad@gmail.com
ServerName umipbd.com
ServerAlias www.umipbd.com
DocumentRoot /var/www/test
<Directory /var/www/test>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite umipbd.com.conf
sudo mkdir -p /var/www/amarischool0
sudo chown -R $USER:$USER /var/www/amarischool0
sudo nano /etc/apache2/sites-available/amarischool.com.conf
<VirtualHost *:80>
ServerAdmin hoosain.sajjad@gmail.com
ServerName amarischool.com
ServerAlias www.amarischool.com
DocumentRoot /var/www/amarischool
<Directory /var/www/amarischool>
Options -Indexes +FollowSymLinks +MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
sudo a2ensite amarischool.com.conf
database backup:
mysqldump -u root -p amarischool > wantedsqlfile.sql
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment