LAMP

0. Clean up

After apt-get update/upgrade

apt-get clean
apt-get autoremove

FreeSpace

HOW TO EASILY DISABLE LOG IN APACHE

/etc/apache2/apache2.conf:

#ErrorLog ${APACHE_LOG_DIR}/error.log
ErrorLog /dev/null

1. Installing Apache + PHP

apt-get install apache2 php5 libapache2-mod-php5

Enabling GD Library with PHP

apt-get install php5-gd

Enabling cURL with PHP

apt-get install php5-curl

List all installed old php 5.x packages

dpkg --list | grep php | awk '/^ii/{ print $2}'

libapache2-mod-php5
php5
php5-cli
php5-common
php5-curl
php5-gd
php5-json
php5-mysql
php5-readline

List all php 5.x available packages

apt-cache search php5-\*

Enabling Mod Rewrite with .htaccess

a2enmod rewrite

Enabling .htaccess files /etc/apache2/apache2.conf

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

For default page into /etc/apache2/sites-available/stavrev.net.conf

<VirtualHost *>
	ServerAdmin webmaster@stavrev.net
	ServerName  test.com
	DirectoryIndex index.html index.php
	DocumentRoot /var/www/
</VirtualHost>
a2enable stavrev.net

Enabling Mod Expires with .htaccess

a2enmod expires

PHP not displaying errors – Internal Server Error (500)

/etc/php5/apache2/php.ini -> display_errors = On; short_open_tag = On; upload_max_filesize = 10M

Reload

service apache2 reload
/etc/init.d/apache2 reload

2. Installing MySQL Database Server

apt-get install mysql-server mysql-client php5-mysql

Add/manage users with phpMyAdmin.

service apache2 reload
/etc/init.d/mysql restart

3. Hosting multiple websites with Apache2

IP -> A Record -> domain.com
IP -> A Record -> *.domain.com

/etc/apache2/sites-available/web-lab.com.conf

<VirtualHost *>
	ServerAdmin webmaster@web-lab.solutions
	ServerName  web-lab.solutions
	ServerAlias www.web-lab.solutions
	ServerAlias web-lab.nl
	ServerAlias web-lab.eu
	ServerAlias web-lab.org
	DirectoryIndex index.html index.php
	DocumentRoot /var/www/web-lab/web-lab.solutions/root/
</VirtualHost>
service apache2 reload

4. DateTime

date
ln -sf /usr/share/zoneinfo/Europe/Sofia /etc/localtime
service cron restart
service mysql restart
service apache2 reload

5. vsftpd

https://wiki.debian.org/vsftpd

apt-get install vsftpd

/etc/vsftpd.conf

anonymous_enable=NO
local_enable=YES
write_enable=YES
pam_service_name=ftp
seccomp_sandbox=NO
/etc/init.d/vsftpd restart

6. DNS

/etc/resolv.conf
# Google nameservers
nameserver 8.8.8.8
nameserver 8.8.4.4

7. Mails

apt-get install sendmail