Setting up initial Ubuntu Server
– Create Droplet
– Check email
– Get IP and password
– Use that IP and connect using Putty
– Use default password provided
– System will ask you to change the password
– Default user name is root
– Create a new user that has access like root
– adduser USERNAME
– add new user to sudo group, run command
– usermod -aG sudo USERNAME
Step 1: Install Apache
– Run commands
– sudo apt-get update
– sudo apt-get install apache2
– Set Global ServerName to Suppress Syntax Warnings
– Open up the main configuration file with your text edit:
– sudo nano /etc/apache2/apache2.conf
– at the end add line: ServerName IPADDRESS of droplet
– Next, check for syntax errors by typing:
– sudo apache2ctl configtest
– Expected output: Syntax OK
– Restart Apache to implement your changes:
– sudo systemctl restart apache2
– Type IP of your droplet in browser
– It should show you Ubuntu page
– This means things went well till here
Step 2: Install MySQL
– Run command
– sudo apt-get install mysql-server
– Set new password for root user for MySQL
– Secure installation after completion
– run command: mysql_secure_installation
Step 3: Install PHP
– Run command:
– sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql
– the way that Apache serves files from index.html to index.php
– set index.php first and then index.html
– swap html and php extensions
– sudo nano /etc/apache2/mods-enabled/dir.conf
– to save file use Ctrl + X –> Y –> Enter
– Restart Apache
– sudo systemctl restart apache2
– Check status of Apache
– sudo systemctl status apache2
Install PHP Modules
– sudo apt-get install php-cli php-cgi php-common php-curl
Step 4: Test PHP Processing on your Web Server
– Create info.php file on web server
– sudo nano /var/www/html/info.php
– add content: <?php phpinfo(); ?>
– save file by Ctrl + x –> Y –> Enter
– Check: http://your_server_IP_address/info.php
– Delete info.php: sudo rm /var/www/html/info.php
Install and Secure phpMyAdmin on Ubuntu 16.04
Step One — Install phpMyAdmin
– sudo apt-get update
– sudo apt-get install phpmyadmin php-mbstring php-gettext
– Choose apache and click ok. * should be set in front of apache by pressing space bar.
– Select yes when asked whether to use dbconfig-common to set up the database
– Set password
– enable the PHP mcrypt and mbstring extensions
– sudo phpenmod mcrypt
– sudo phpenmod mbstring
– Restart Apache
– sudo systemctl restart apache2
Step Two — Secure your phpMyAdmin Instance
– Configure Apache to Allow .htaccess Overrides
– edit the linked file that has been placed in our Apache configuration directory
– sudo nano /etc/apache2/conf-available/phpmyadmin.conf
– need to add an AllowOverride All directive within the <Directory /usr/share/phpmyadmin> section of the configuration file
– Restart Apache
– sudo systemctl restart apache2
Create n .htaccess File
-the file must be created within the application directory. We can create the necessary file and open it in our text editor with root privileges by typing:
– Run command
– sudo nano /usr/share/phpmyadmin/.htaccess
Within this file, we need to enter the following information:
/usr/share/phpmyadmin/.htaccess
AuthType Basic
AuthName “Restricted Files”
AuthUserFile /etc/phpmyadmin/.htpasswd
Require valid-user
Create the .htpasswd file for Authentication
The location that we selected for our password file was “/etc/phpmyadmin/.htpasswd”. We can now create this file and pass it an initial user with the htpasswd utility:
sudo htpasswd -c /etc/phpmyadmin/.htpasswd ashish963
It will ask to set password for this user
When you will access dropletip/phpmyadmin, a prompt will ask first level of user name and password. On successfull authentication, it will allow you to use phpmyadmin user name and password to log in to phpmyadmin
This completes installation of LAMP on server.
You should be able to access index file, phpmyadmin.
MIGRATE WORDPRESS TO NEW DROPLET
Move all files from old server to new server
Move DB
Change wp-config.php, edit correct db details.
change landing page and url to new address in options table
login to wordpress, settings, permalink, change and save, restore and save.
Enable rewrite:
Go to – /etc/apache2/sites-available
Download – 000-default.conf
Edit and add:
ServerName DropletIP
DocumentRoot /var/www/l
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Run command: a2enmod rewrite
Restart apache: sudo service apache2 restart
Migrate Database from Old to New Droplet
On old website:
mysqldump –lock-all-tables -u root -p –all-databases > dump.sql
scp dump.sql root@139.59.76.174:/tmp (139 is IP of new droplet)
Come to new droplet in putty
mysql -u root -p < /tmp/dump.sql
Migrate all files from old droplet to new
On old droplet
scp -r /path/to/my/files root@0.0.0.0:/path/on/remote/droplet
scp -r /var/www/html/ root@139.59.76.174:/var/www/
rm -r /var/www/www
sudo chown root:www-data /var/www -R
sudo chmod g+w /var/www -R
Migrate Database from Old to New Droplet
On old website:
mysqldump –lock-all-tables -u root -p –all-databases > dump.sql
scp dump.sql root@139.59.76.174:/tmp (139 is IP of new droplet)
Come to new droplet in putty
mysql -u root -p < /tmp/dump.sql
rm -r /tmp
rm -r /var/www/html/