👈 back home

Setup Ubuntu Server (mysql-apache-php)

Written by andy onMarch 13, 2014

0. Update system

$ apt-get update
$ apt-get upgrade

# Set Timezone - Jakarta
$ dpkg-reconfigure tzdata

1. Install Apache

$ apt-get install apache2

2. Install PHP

# PHP 7
$ apt-get install php7.0 libapache2-mod-php7.0

# PHP 5
$ apt-get install php5 libapache2-mod-php5

# PHP 4
$ apt-get install php4 libapache2-mod-php4

2.a Install cURL

# PHP (latest)
$ apt-get install php7.0-curl

# PHP 5
$ apt-get install php5-curl

# PHP 4
$ apt-get install php4-curl

2.b Enabling Mod Rewrite .htaccess

$ a2enmod rewrite

2.c Enabling Overrice .htaccess

$ nano /etc/apache2/apache2.conf

AllowOverride None to All

< Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

2.d Enabling GD Library

# PHP (latest)
$ apt-get install php7.0-gd

# PHP 5
$ apt-get install php5-gd

# PHP 4
$ apt-get install php4-gd

3a. Install MySQL Database Server

$ apt-get install mysql-server

3b. Install MySQL Database Client

# PHP (latest)
$ apt-get install mysql-client php7.0-mysql

# PHP 5
$ apt-get install mysql-client php5-mysql

# PHP 4
$ apt-get install mysql-client php4-mysql

4.a Install PhpMyAdmin

$ apt-get install phpmyadmin

4.b Change default PhpMyAdmin URL

$ nano /etc/phpmyadmin/apache.conf

Alias /phpmyadmin to /secure_pma


5. Mail Server (Squirrel Web Mail)

$ apt-get install squirrelmail

Setup to run under apache

$ nano /etc/apache2/apache2.conf

and insert following line:

Include /etc/squirrelmail/apache.conf

Point your browser to http://yourdomain/squirrelmail


6. Webmin – Server Control Panel

Url can be found here: http://www.webmin.com/download.html

$ wget http://downloadpath/webmin-x.x.xx.tar.gz
$ tar xzf webmin-x.x.x.tar.gz
$ cd /webmin-x.x.x
$ ./setup.sh

7. Webalizer

$ apt-get install webalizer
$ nano /etc/webalizer.conf

change line : LogFile /var/log/apache/access.log.1
to : LogFile /var/log/apache/access.log

To see visitor statistic of your site, go to: http://domain/webalizer


8. Setup FTP with Proftpd

$ apt-get install proftpd

choose `standalone`

$ nano /etc/shells

and add `/bin/false` on last line.
Press `Ctrl+X` and press `Y` and replace the file.

Now create an account & set the password

$ useradd userftp -d /var/www -s /bin/false
$ passwd userftp

enter your password, hit enter and do it twice.

Set folder writable by www-data account

$ chmod 755 /var/www/html/uploads
$ chown -R www-data:staff /var/www/html/uploads
$ service proftpd restart

9. ClamAV – Antivirus

$ apt-get install clamav

9.a Scan folder

$ clamscan -R /path/folders

9.b Update virus database

$ freshclam

9.c Running as Cron

$ sudo crontab -e

add 02 1 * * * root clamscan -R /var/www


10. IP Tables Firewall

$ apt-get install iptables