How to install PHP + MySQL + phpMyAdmin on Linux, Ubuntu or Fedora Web Server.

How to install PHP + MySQL + phpMyAdmin on Linux, Ubuntu or Fedora Web Server.

How to install PHP + MySQL + phpMyAdmin on Linux, Ubuntu or Fedora Web Server.

Lets start with most popular and widely used Linux distribution Ubuntu. First of all lets understand what is LAMP.

LAMP is an acronym for a solution stack of free, open source software, originally coined from the first letters of Linux (operating system), Apache HTTP Server, MySQL (database software) and Perl/PHP/Python, principal components to build a viable general purpose web server.

Now lets see how to install LAMP on Ubuntu Web Server. (Note: Here I am explaning procedure to install LAMP stack on web server for local PC installation and my favorite CentOS please wait for next article.)

So here we start.

Connect to the terminal with root privilege and run following commands.

apt-get update
apt-get upgrade
apt-get dist-upgrade
aptitude install build-essential
apt-get install ubuntu-standard
apt-get install lamp-server
apt-get install php5-cli
apt-get install php5-curl
(rest and/or go take a dump)
apt-get install curl
apt-get install wget
apt-get install imagemagick
apt-get install emacs
apt-get install ufw (<a href="">uncomplicated firewall</a>)
apt-get install sendmail (if you need php mail() function)
Change apache’s memory usage setting ..If you want imagemagick (latest), you need PECL to install (do not run apt-get install php5-imagick => outdated version)

apt-get install php-pear
apt-get install imagemagick libmagickwand-dev
pecl install imagick

Open your php.ini (/etc/php5/apache2/php.ini)  and add this line:

a2enmod rewrite

a2enmod mod_headers (if you have wordpress blogs and want to have caching)

a2endmod mod_expires

a2endmod auth_basic

a2endmod auth_digest

/etc/init.d/apache2 restart

/etc/init.d/mysql restart

chgrp -R www-data /path/to/your/www” (so PHP can read/write to ur directory)

chmod -R 775 /path/to/your/www (so PHP can read/write to ur directory)

Some things to change
  • Change maxclients on apache2.conf to something small… like 10 or 15
  • Change keepalive to off unless your site gets pounded (ex. high traffic site).. or time to live on keep alive connections to something small like 2
  • PHP.ini upload limit – if you have high image site (like, change it to smoething more suitable like 10m
PS:If your VPS provider doesn’t give you access to their nameservers (cuz they’re doosh bags), you can always go with EveryDNS. Set it up there and point to EveryDNS dns servers on your registrar.PPS: If your Ubuntu distro doesn’t respond to this command:

apt-get install libapache2-mod-security

You need to manually download from here then run “dpkg -i libapache-mod-security_2.5.12-1_i386.deb”.

There is also more customized way to install all this stuff with manual installation method. I will explain the finest and good way to do that in next tutorial.

abhijeet on Facebookabhijeet on Linkedinabhijeet on Twitter
Abhijeet specializes in developing software. A full-stack developer and Entrepreneur, he takes an idea and crafts it into a beautiful product - front to back. He develops on the LAMP Stack (PHP, MVC, Web API, Perl, Python, Azure, AWS, Google Cloud) and utilizes AngularJS and Angular Material for a structured client. Abhijeet is a self-starter with experience working in remote, agile environments mainly focusing on the security constraints. This is the developer, Project Manager and Consultant you are looking for.