👈 back home

Setup Ubuntu Server (mysql-apache-php)

Published 2014-03-13

0. Update system

$ apt-get update
$ apt-get upgrade

1. Install Apache + PHP

# PHP (latest)
$ apt-get install apache2 php7.0 libapache2-mod-php7.0

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

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

# Restart
$ service apache2 restart

1.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

1.b Enabling Mod Rewrite .htaccess

$ a2enmod rewrite

1.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

1.c 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

2. Install MySQL Database Server

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

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

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

2.a Install PhpMyAdmin

$ apt-get install phpmyadmin

2.b Change default PhpMyAdmin URL

$ nano /etc/phpmyadmin/apache.conf

Alias /phpmyadmin to /secure_pma


3. Mail Server

3.a 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


4. 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

5. 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


6. 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

7. ClamAV – Antivirus

$ apt-get install clamav

7.a Scan folder

$ clamscan -R /path/folders

7.b Update virus database

$ freshclam

7.c Running as Cron

$ sudo crontab -e

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


8. IP Tables Firewall

$ apt-get install iptables