Linux Install a LAMP stack

LAMP stands for Linux w/ Apache w/ MySQL w/PHP.  It one of the most common web server configurations there is.  Several people will debate the naming and say “M” stands for “blah blah” or “M” changed its name, or “P stands for “blah blah blah”. Yep you have lots of choices but originally its


These steps outlined below should be done with root access or using sudo.

The Basic Steps

  1. Install Apache
  2. Start Apache
  3. Install PHP with at least MySQL, Apache MOD, mcrypt and mbstring support
  4. Restart and install MySQL
  5. Create root user for MySQL
  6. If you have a firewall on the server open the correct ports
  7. Download the latest version of PHPmyAdmin from to make your life easier managing the MySQL
  8. Install PHPmyAdmin
  9. Fix write permissions on web root

Sample Install Process for LAMP

Sample using current version of OpenSUSE

root# zypper in apache2
Installs Apache
root# systemctl start apache2
Starts Apache
root# systemctl enable apache2
Tells Apache to auto-start on bootup

root# zypper in mariadb mariadb-tools
Installs MySQL and its tools
root# mysql_secure_installation
Answer all questions and reset the root password.
Do NOT leave the root password blank!

If you want PHPv7
root# zypper in php7 php7-mysql apache2-mod_php7
root# a2enmod php7

If you want PHP v5
root# zypper in php5 php5-mysql apache2-mod_php5
root# a2enmod php5

root# zypper in phpMyAdmin

root# chmod 644 /srv/www/htdocs/
root# chmod -R 644 /srv/www/htdocs/*

Via YAST using PHP v5 on older versions

yast -i apache2 apache2-prefork apache2-utils apache2-example-pages
rcapache2 start yast -i php5 php5-mysql apache2-mod_php5 php5-mcrypt php5-mbstring yast -i mysql mysql-tools
mysqladmin -u root password <choose a good passowrd>
tar -zxvf phpMyAdmin-<latest version>-all-languages.tar.gz -C /srv/www/htdocs
mv phpMyAdmin-<latest version>-all-languages/ phpmyadmin
chmod 644 /srv/www/htdocs/
chmod -R 644 /srv/www/htdocs/*

Via ZYPPER using PHP5 on older versions

Install and configure MySQL

zypper install mysql-community-server mysql-community-server-client
systemctl enable mysql.service (Creates system start-up links)
systemctl start mysql.service (Start MySQL)
mysql_secure_installation (Secure the MySQL installation)

Install and configure Apache

zypper install apache2 apache2-prefork apache2-utils apache2-example-pages
systemctl enable apache2.service (Create system start-up links)
systemctl start apache2.service (start Apache)

Install PHP and its modules

zypper install apache2-mod_php5

The first is needed for MySQL and PHP but the others are a good list
zypper install php5-mysql php5-bcmath php5-curl php5-mbstring php5-mcrypt php5-openssl php5-xmlrpc php5-xsl php5-zlib php5-exif php5-fastcgi php5-pear

Optional PHP mods, only install the ones you need zypper install php5-bz2 php5-calendar php5-ctype php5-dom php5-ftp php5-gd php5-gettext php5-gmp php5-iconv php5-imap php5-ldap php5-odbc php5-pcntl php5-pgsql php5-posix php5-shmop php5-snmp php5-soap php5-sockets php5-sqlite php5-sysvsem php5-tokenizer php5-wddx php5-sysvmsg php5-sysvshm
systemctl restart apache2.service (Apache needs to be restarted)

Setup phpMyAdmin

zypper install phpMyAdmin
systemctl restart apache2.service (Apache needs to be restarted)

Additional steps

Allowing PHPmyAdmin on any URL

vi /etc/apache2/conf.d/phpMyAdmin.conf

Add these two line at the top of the file.
Alias /phpMyAdmin /srv/www/htdocs/phpMyAdmin
Alias /phpmyadmin /srv/www/htdocs/phpMyAdmin
Save and Close VI.

Testing PHP

vi /srv/www/htdocs/info.php

Then in VI type

Apache basics

Default document root locations

  • /srv/www/htdocs/ on OpenSUSE
  • /usr/local/http/htdocs on RedHat, OpenSUSE, SUSE, ubunto

Configuration files: Main configuration and run level configurations

  • /etc/apache2/httpd.conf
  • /etc/apache2/conf.d/

To restart the Apache server: systemctl restart apache2
To stop the Apache server: systemctl stop apache2



Did you get a clue?

If you got a clue and want to thank me, then visit the thank me page. It’s the best way to keep me publishing articles and keeping this site operation.

This site uses affiliate links. When you go to another site from here the link typically will have an affiliate code attached to it. Your actions on that site may earn a small commission for me. Read our affiliate link policy for more details.


Scroll to Top