Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
How to create a proper debian LAMP server
# Hostname
hostname -f
nano /etc/hostname
nano /etc/hosts
shutdown -r now
hostname -f
## WARNING ! PHP 5 is now obsolete, please use PHP 7 or greater
# Major Packages
apt update && apt upgrade
apt install mysql-server mysql-client
apt install apache2
apt install php5 php-pear php5-mysql
service apache2 restart
# Major addons
apt install phpmyadmin apache2-mpm-prefork openssl
# PHP addons
apt install php5-mysql php5-curl php5-gd php5-intl php5-cli php5-cgi php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-imagick imagemagick libruby php5-memcached memcached php-auth
# Apache2 addons
apt install apache2-doc apache2-utils libexpat1 ssl-cert php5-mcrypt mcrypt libapache2-mod-python libapache2-mod-passenger
# Logs
cat /var/log/syslog
cat /var/log/apache2/error.log
# Conf
service apache2 reload/stop/start/restart/check
systemctl restart apache2
a2ensite / a2dissite
a2enmod / a2dismod
a2enconf / a2disconf
service apache2 stop
a2dismod mpm_event
a2dismod mpm_prefork
nano /etc/apache2/mods-available/mpm_prefork.conf
<IfModule mpm_prefork_module>
StartServers 4
MinSpareServers 20
MaxSpareServers 40
MaxRequestWorkers 200
MaxConnectionsPerChild 4500
a2enmod mpm_prefork
service apache2 start
nano /etc/apache2/apache2.conf
# Security
ServerSignature Off
ServerTokens Prod
service apache2 restart
## WARNING ! PHP 5 is now obsolete, please use PHP 7 or greater
nano /etc/php5/apache2/php.ini
; Max execution time for a script in seconds
max_execution_time = 60
; Max time for a script to parse its data (POST, GET..)
max_input_time = 60
; Max mem for a script
memory_limit = 256M
; Max upload size
upload_max_filesize = 10G
; Display errors
display_errors = Off
; Some potentially dangerous functions to disable
disable_functions = symlink,shell_exec,exec,proc_close,proc_open,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,
; UTF-8 Custom config
service apache2 restart
# New user and ownerships
adduser username
mkdir /home/username/public_html
chown -R www-data:username /home/username/public_html
# Virtual Hosts
cd /etc/apache2/sites-available
nano template.conf
<VirtualHost *:80>
# Addresses
ServerAlias website.dom
ServerAdmin admin@localhost
# Directory and rules
DocumentRoot /home/userdir/public_html
<Directory /home/userdir/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
# Logging
# LogLevel settings : debug, info, notice, warn, error, crit, alert
LogLevel warn
ErrorLog ${APACHE_LOG_DIR}/website-error.log
CustomLog ${APACHE_LOG_DIR}/website-access.log combined
cp template.conf
# Activation
service apache2 reload
nano /home/username/public_html/phpinfo.php
// Show all information, defaults to INFO_ALL
chown -R www-data:username /home/username/public_html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment