You are on page 1of 24

How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

Communit Log In ign Up  Menu

B: Brennen Bearnes 


 ubscribe  hare  Contents 

How To Install Linux,


Apache, MQL, PHP (LAMP) 82

stack on Ubuntu 16.04


Posted April 21, 2016  938k LAMP TACK PHP MYQL APACHE UBUNTU 16.04

Introduction
A "LAMP" stack is a group of open source software that is tpicall installed together to
enable a server to host dnamic websites and web apps. This term is actuall an
acronm which represents the Linux operating sstem, with the Apache web server.
The site data is stored in a MQL database, and dnamic content is processed b
PHP.

In this guide, we'll get a LAMP stack installed on an Ubuntu 16.04 Droplet. Ubuntu will

24 இ� 1 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

fulfill our first requirement: a Linux operating sstem.

Prerequisites
Before ou begin with this guide, ou should have a separate, non-root user account
with sudo privileges set up on our server. You can learn how to do this b completing
steps 1-4 in the initial server setup for Ubuntu 16.04.

tep 1: Install Apache and Allow in Firewall


The Apache web server is among the most popular web servers in the world. It's
well-documented, and has been in wide use for much of the histor of the web, which
makes it a great default choice for hosting a website.

We can install Apache easil using Ubuntu's package manager, apt . A package
manager allows us to install most software pain-free from a repositor maintained b
Ubuntu. You can learn more about how to use apt here.

For our purposes, we can get started b tping these commands:

$ sudo apt-get update


$ sudo apt-get install apache2

ince we are using a sudo command, these operations get executed with root
privileges. It will ask ou for our regular user's password to verif our intentions.

Once ou've entered our password, apt will tell ou which packages it plans to
install and how much extra disk space the'll take up. Press Y and hit Enter to continue,
Signinstallation
and the up for ourwill
newsletter.
proceed. ×
Get the latest tutorials on SysAdmin and open source topics.
et Global erverName to uppress ntax Warnings
ign Up
Next, we will add a single line to the /etc/apache2/apache2.conf file to suppress a
warning message. While harmless, if ou do not set ServerName globall, ou will
S C R O L L TO TO P
receive the following warning when checking our Apache configuration for sntax

24 இ� 2 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

errors:

$ sudo apache2ctl configtest

Output
AH00558: apache2: Could not reliably determine the server's fully qualified doma
Syntax OK

Open up the main configuration file with our text edit:

$ sudo nano /etc/apache2/apache2.conf

Inside, at the bottom of the file, add a ServerName directive, pointing to our primar
domain name. If ou do not have a domain name associated with our server, ou can
use our server's public IP address:

Note

If ou don't know our server's IP address, skip down to the section on how to find our
server's public IP address to find it.

/etc/apache2/apache2.conf

. . .
ServerName server_domain_or_IP

aveSign
and up forthe
close ourfile
newsletter.
when ou are finished. ×
Get the latest tutorials on SysAdmin and open source topics.
Next, check for sntax errors b tping:
ign Up

$ sudo apache2ctl configtest

S C R O L L TO TO P

24 இ� 3 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

ince we added the global ServerName directive, all ou should see is:

Output
Syntax OK

Restart Apache to implement our changes:

$ sudo systemctl restart apache2

You can now begin adjusting the firewall.

Adjust the Firewall to Allow Web Traffic


Next, assuming that ou have followed the initial server setup instructions to enable
the UFW firewall, make sure that our firewall allows HTTP and HTTP traffic. You can
make sure that UFW has an application profile for Apache like so:

$ sudo ufw app list

Output
Available applications:
Apache
Apache Full
Apache Secure
OpenSSH

If ouSign
lookup
at for
theour
Apache
×
Full profile, it should show that it enables traffic to ports 80
newsletter.
and 443:
Get the latest tutorials on SysAdmin and open source topics.

ign Up
$ sudo ufw app info "Apache Full"

S C R O L L TO TO P
Output

24 இ� 4 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

Profile: Apache Full


Title: Web Server (HTTP,HTTPS)
Description: Apache v2 is the next generation of the omnipresent Apache web
server.

Ports:
80,443/tcp

Allow incoming traffic for this profile:

$ sudo ufw allow in "Apache Full"

You can do a spot check right awa to verif that everthing went as planned b
visiting our server's public IP address in our web browser (see the note under the
next heading to find out what our public IP address is if ou do not have this
information alread):

http://your_server_IP_address

You will see the default Ubuntu 16.04 Apache web page, which is there for
informational and testing purposes. It should look something like this:

Sign up for our newsletter. ×


Get the latest tutorials on SysAdmin and open source topics.

ign Up

S C R O L L TO TO P

24 இ� 5 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

If ou see this page, then our web server is now correctl installed and accessible
through our firewall.

How To Find our erver's Public IP Address


If ou do not know what our server's public IP address is, there are a number of was
ou can find it. Usuall, this is the address ou use to connect to our server through
H.

FromSign up for our line,


the command newsletter.
ou can find this a few was. First, ou can use the iproute2 ×
toolsGet the our
to get latestaddress
tutorials b
on SysAdmin
tping this:and open source topics.

ign Up
$ ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

S C R O L L TO TO P
This will give ou two or three lines back. The are all correct addresses, but our

24 இ� 6 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

computer ma onl be able to use one of them, so feel free to tr each one.

An alternative method is to use the curl utilit to contact an outside part to tell ou
how it sees our server. You can do this b asking a specific server what our IP
address is:

$ sudo apt-get install curl


$ curl http://icanhazip.com

Regardless of the method ou use to get our IP address, ou can tpe it into our web
browser's address bar to get to our server.

tep 2: Install MQL


Now that we have our web server up and running, it is time to install MQL. MQL is
a database management sstem. Basicall, it will organize and provide access to
databases where our site can store information.

Again, we can use apt to acquire and install our software. This time, we'll also install
some other "helper" packages that will assist us in getting our components to
communicate with each other:

$ sudo apt-get install mysql-server

Note: In this case, ou do not have to run sudo apt-get update prior to the
command. This is because we recentl ran it in the commands above to install Apache.
The package index on our computer should alread be up-to-date.
Sign up for our newsletter. ×
Get the latest tutorials on SysAdmin and open source topics.
Again, ou will be shown a list of the packages that will be installed, along with the
amount of disk space the'll take up. Enter Y to continue. ign Up

During the installation, our server will ask ou to select and confirm a password for the
MQL "root" user. This is an administrative account in MQL that hasS Cincreased
R O L L TO TO P

24 இ� 7 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

privileges. Think of it as being similar to the root account for the server itself (the one
ou are configuring now is a MQL-specific account, however). Make sure this is a
strong, unique password, and do not leave it blank.

When the installation is complete, we want to run a simple securit script that will
remove some dangerous defaults and lock down access to our database sstem a little
bit. tart the interactive script b running:

$ sudo mysql_secure_installation

You will be asked to enter the password ou set for the MQL root account. Next, ou
will be asked if ou want to configure the VALIDATE PASSWORD PLUGIN .

Warning: Enabling this feature is something of a judgment call. If enabled, passwords


which don't match the specified criteria will be rejected b MQL with an error. This
will cause issues if ou use a weak password in conjunction with software which
automaticall configures MQL user credentials, such as the Ubuntu packages for
phpMAdmin. It is safe to leave validation disabled, but ou should alwas use strong,
unique passwords for database credentials.

Answer  for es, or anthing else to continue without enabling.

VALIDATE PASSWORD PLUGIN can be used to test passwords


and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No:


Sign up for our newsletter. ×
Get the latest tutorials on SysAdmin and open source topics.
You'll be asked to select a level of password validation. Keep in mind that if ou enter
ign Up
2, for the strongest level, ou will receive errors when attempting to set an password
which does not contain numbers, upper and lowercase letters, and special characters,
or which is based on common dictionar words. S C R O L L TO TO P

24 இ� 8 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

There are three levels of password validation policy:

LOW Length >= 8


MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 1

If ou enabled password validation, ou'll be shown a password strength for the
existing root password, and asked ou if ou want to change that password. If ou are
happ with our current password, enter n for "no" at the prompt:

Using existing password for root.

Estimated strength of the password: 100


Change the password for root ? ((Press y|Y for Yes, any other key for No) :

For the rest of the questions, ou should press Y and hit the Enter ke at each prompt.
This will remove some anonmous users and the test database, disable remote root
logins, and load these new rules so that MQL immediatel respects the changes we
have made.

At this point, our database sstem is now set up and we can move on.

tep 3: Install PHP


PHP is the component of our setup that will process code to displa dnamic content. It
can run scripts, connect to our MQL databases to get information, and hand the
Sign upcontent
processed for ourover
newsletter.
to our web server to displa. ×
Get the latest tutorials on SysAdmin and open source topics.
We can once again leverage the apt sstem to install our components. We're going to
include some helper packages as well, so that PHP code can runign Upthe Apache
under
server and talk to our MQL database:

S C R O L L TO TO P
$ sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql

24 இ� 9 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

This should install PHP without an problems. We'll test this in a moment.

In most cases, we'll want to modif the wa that Apache serves files when a director is
requested. Currentl, if a user requests a director from the server, Apache will first
look for a file called index.html . We want to tell our web server to prefer PHP files,
so we'll make Apache look for an index.php file first.

To do this, tpe this command to open the dir.conf file in a text editor with root
privileges:

$ sudo nano /etc/apache2/mods-enabled/dir.conf

It will look like this:

/etc/apache2/mods-enabled/dir.conf

<IfModule mod_dir.c>
DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>

We want to move the PHP index file highlighted above to the first position after the
DirectoryIndex specification, like this:

/etc/apache2/mods-enabled/dir.conf

<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
Sign up for
</IfModule> our newsletter. ×
Get the latest tutorials on SysAdmin and open source topics.

When ou are finished, save and close the file b pressing Ctrl-X.ign
You'll
Uphave to confirm
the save b tping Y and then hit Enter to confirm the file save location.

After this, we need to restart the Apache web server in order for our changes
S C R O L Lto
TObeTO P

24 இ� 10 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

recognized. You can do this b tping this:

$ sudo systemctl restart apache2

We can also check on the status of the apache2 service using systemctl :

$ sudo systemctl status apache2

Sample Output
● apache2.service - LSB: Apache2 web server
Loaded: loaded (/etc/init.d/apache2; bad; vendor preset: enabled)
Drop-In: /lib/systemd/system/apache2.service.d
└─apache2-systemd.conf
Active: active (running) since Wed 2016-04-13 14:28:43 EDT; 45s ago
Docs: man:systemd-sysv-generator(8)
Process: 13581 ExecStop=/etc/init.d/apache2 stop (code=exited, status=0/SUCCES
Process: 13605 ExecStart=/etc/init.d/apache2 start (code=exited, status=0/SUCC
Tasks: 6 (limit: 512)
CGroup: /system.slice/apache2.service
├─13623 /usr/sbin/apache2 -k start
├─13626 /usr/sbin/apache2 -k start
├─13627 /usr/sbin/apache2 -k start
├─13628 /usr/sbin/apache2 -k start
├─13629 /usr/sbin/apache2 -k start
└─13630 /usr/sbin/apache2 -k start

Apr 13 14:28:42 ubuntu-16-lamp systemd[1]: Stopped LSB: Apache2 web server.


Apr 13 14:28:42 ubuntu-16-lamp systemd[1]: Starting LSB: Apache2 web server...
Apr 13 14:28:42 ubuntu-16-lamp apache2[13605]: * Starting Apache httpd web serv
Apr 13 14:28:42 ubuntu-16-lamp apache2[13605]: AH00558: apache2: Could not relia
Apr Sign up for our ubuntu-16-lamp
13 14:28:43 newsletter. apache2[13605]: * ×
Apr 13 14:28:43 ubuntu-16-lamp systemd[1]: Started LSB: Apache2 web server.
Get the latest tutorials on SysAdmin and open source topics.

ign Up
Install PHP Modules
To enhance the functionalit of PHP, we can optionall install some additional modules.
S C R O L L TO TO P

24 இ� 11 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

To see the available options for PHP modules and libraries, ou can pipe the results of
apt-cache search into less , a pager which lets ou scroll through the output of
other commands:

$ apt-cache search php- | less

Use the arrow kes to scroll up and down, and q to quit.

The results are all optional components that ou can install. It will give ou a short
description for each:

libnet-libidn-perl - Perl bindings for GNU Libidn


php-all-dev - package depending on all supported PHP development packages
php-cgi - server-side, HTML-embedded scripting language (CGI binary) (default)
php-cli - command-line interpreter for the PHP scripting language (default)
php-common - Common files for PHP packages
php-curl - CURL module for PHP [default]
php-dev - Files for PHP module development (default)
php-gd - GD module for PHP [default]
php-gmp - GMP module for PHP [default]

:

To get more information about what each module does, ou can either search the
internet, or ou can look at the long description of the package b tping:

$ apt-cache show package_name

Sign up for our newsletter.


There will be a lot of output, with one field called Description-en which will have a ×
Getexplanation
longer the latest tutorials on SysAdmin that
of the functionalit and open source topics.
the module provides.

ign Up
For example, to find out what the php-cli module does, we could tpe this:

$ apt-cache show php-cli S C R O L L TO TO P

24 இ� 12 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

Along with a large amount of other information, ou'll find something that looks like
this:

Output

Description-en: command-line interpreter for the PHP scripting language (default
This package provides the /usr/bin/php command interpreter, useful for
testing PHP scripts from a shell or performing general shell scripting tasks.
.
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used
open source general-purpose scripting language that is especially suited
for web development and can be embedded into HTML.
.
This package is a dependency package, which depends on Debian's default
PHP version (currently 7.0).

If, after researching, ou decide ou would like to install a package, ou can do so b
using the apt-get install command like we have been doing for our other
software.

If we decided that php-cli is something that we need, we could tpe:

$ sudo apt-get install php-cli

If ou want to install more than one module, ou can do that b listing each one,
separated b a space, following the apt-get install command, like this:

$ sudo apt-get install package1 package2 ...


Sign up for our newsletter. ×
Get the latest tutorials on SysAdmin and open source topics.
At this point, our LAMP stack is installed and configured. We should still test out our
ign Up
PHP though.

tep 4: Test PHP Processing on our Web


S C R Oerver
L L TO TO P

24 இ� 13 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

In order to test that our sstem is configured properl for PHP, we can create a ver
basic PHP script.

We will call this script info.php . In order for Apache to find the file and serve it
correctl, it must be saved to a ver specific director, which is called the "web root".

In Ubuntu 16.04, this director is located at /var/www/html/ . We can create the file at
that location b tping:

$ sudo nano /var/www/html/info.php

This will open a blank file. We want to put the following text, which is valid PHP code,
inside the file:

info.php

<?php
phpinfo();
?>

When ou are finished, save and close the file.

Now we can test whether our web server can correctl displa content generated b a
PHP script. To tr this out, we just have to visit this page in our web browser. You'll
need our server's public IP address again.

The address ou want to visit will be:

Sign up for our newsletter.


http://your_server_IP_address/info.php ×
Get the latest tutorials on SysAdmin and open source topics.

The page that ou come to should look something like this: ign Up

S C R O L L TO TO P

24 இ� 14 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

This page basicall gives ou information about our server from the perspective of
PHP. It is useful for debugging and to ensure that our settings are being applied
correctl.

If this was successful, then our PHP is working as expected.

You probabl want to remove this file after this test because it could actuall give
information about our server to unauthorized users. To do this, ou can tpe this:

$ sudo rm /var/www/html/info.php

Sign up for our newsletter. ×


You can
Get alwas
the latestrecreate
tutorialsthis page if ou
on SysAdmin andneed
opentosource
access the information again later.
topics.

ign Up
Conclusion
Now that ou have a LAMP stack installed, ou have man choices for what to do next.
S C R O L L TO TO P
Basicall, ou've installed a platform that will allow ou to install most kinds of websites

24 இ� 15 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

and web software on our server.

As an immediate next step, ou should ensure that connections to our web server are
secured, b serving them via HTTP. The easiest option here is to use Let's Encrpt to
secure our site with a free TL/L certificate.

ome other popular options are:

Install Wordpress the most popular content management sstem on the internet.

et Up PHPMAdmin to help manage our MQL databases from web browser.

Learn more about MQL to manage our databases.

Learn how to use FTP to transfer files to and from our server.

Note: We will be updating the links above to our 16.04 documentation as it is written.

B: Brennen Bearnes Upvote (82)  ubscribe  hare

Load Balancers now available on DigitalOcean


Distribute traffic across our infrastructure, managed from the control panel or
API.

Sign up for our newsletter. ×


Get the latest tutorials on SysAdmin and open source topics.

ign Up

Related Tutorials
S C R O L L TO TO P
How To Install Moodle on Ubuntu 16.04

24 இ� 16 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

How To ecure Apache with Let's Encrpt on Debian 8

How To Install WordPress with LAMP on Ubuntu 16.04

How To ecure Apache with Let's Encrpt on Ubuntu 16.04

How To Install LAMP on Ubuntu 14.04 [Quickstart]

73 Comments

Log In to Comment

laurimaa April 22, 2016

0 How to find our droplets IP:


tpe 'ifconfig' and it should be the top device/interface. inet addr: YOUR_IP

Ablon April 22, 2016

0
Sign
Nice!
up for our newsletter. ×
Get the latest tutorials on SysAdmin and open source topics.
How can I restore a Full Backup done with Cpanel, in m new VP after install
wordpress? ign Up

jschwenn MOD April 22, 2016 S C R O L L TO TO P

0 Hi,

24 இ� 17 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

The cPanel full backup is a compressed file that normall is named like backup-
[date]_[time]_[cPanel user name].tar.gz . This file can be be uncompressed
on a Mac b double clicking on it. For Windows, most unzip utilities should also be able
to uncompress the file.

After uncompressing the file ou'll have a folder with man other folders and files in it. All
of our website files should be in homedir/public_html and ou'll see the database
backups under the mysql folder. Those two items will make up our WordPress site.

You can then follow a process ver similar to the outlined here to migrate the WordPress
site to our new server.

How To Migrate WordPress from hared …


b Ramesh Jha

If ou read through this article ou'll have


the knowledge to migrate our WordPress
site from hared Hosting to a Cloud erver

Ablon April 22, 2016

0 Thank ou!

I can do this procedure in a Ubuntu 1 click to wordpress?

jschwenn MOD April 23, 2016

1 In theor es, but ou ma be better off using the phpMAdmin one-click.
ou can upload all the files in the homedir/public_html folder of the
backup to /var/www/html/ of the One-click based Droplet. Then ou
would create the database in phpMAdmin and import our database
backup also through the phpMAdmin panel. You would need to update the
database connection details in the /var/www/html/wp-config.php
Sign up forfile,
ourbut after that the WordPress site should load.
newsletter. ×
Get the latest tutorials on SysAdmin and open source topics.

Ablon April 23, 2016 ign Up

0 I receive this error, after put m pass of userd:


mysql -h localhost -u (i change here) -p (and here for mu d name) <
(and put correct file here)ackupdb.sql.gz S C R O L L TO TO P

24 இ� 18 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

Enter password:
ERROR at line 1: Unknown command '\
'.
What ou think? It's better start configuration a Ubuntu 16.04 manuall?

Ablon April 23, 2016

0 Yo!
It's ok now. Backup restored and imported db... how I can configure m
domain from bluehost here on m VP? The Domain will still there.

jschwenn MOD April 24, 2016

0 @Ablon - Here is a great tutorial on how to setup a Domain using our


DN feature.

How To et Up a Host Na…


b Etel verdlov

This article walks ou


through setting up the DN
for our site. The tutorial

Hmza April 25, 2016

0 Awesome tutorial!

PHP doesn't seem to work with Apache though.

sudo a2enconf php7.0.conf returns ERROR: Conf php7.0 does not


exist! .
ls -la | grep php returns:
Sign up for our newsletter. ×
Get-rw-r--r-- 1 root
the latest tutorials root
on SysAdmin 867open
and Aprsource
14 13:13
topics. php7.0.conf
-rw-r--r-- 1 root root 79 Apr 14 13:13 php7.0.load
ign Up

I also ran sudo a2enmod php7.0 , which returned:

S C R O L L TO TO P
Considering conflict php5 for php7.0:

24 இ� 19 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

Enabling module php7.0.


To activate the new configuration, you need to run:
service apache2 restart

However, php5 is not installed. sudo a2dismod php5 returns another error saing it
doesn't exist.

akligom April 27, 2016

0 I successfull installed apache2 but there is not in ufw list. Wh and how can I
configured it?

jacobsandeep April 30, 2016

0 Thank ou, thank ou, thank ou! i cannot thank ou enough. i could fall at our feet
and kiss them. this tut saved m life!

ergeOvD May 1, 2016

0 Thx for helpful guide.

shankhadev123 May 2, 2016

0 Unable to render php code after upgrading the ubuntu 16.04. B following to install the
php with above process.

RobertLangore May 25, 2016

0 Hi,

SignI had
up for
theour newsletter.
same ×
issue. I followed the install guide above, but installed php5.6 instead
Get of
thephp7
latest(which comes
tutorials with ubuntu
on SysAdmin and16.04).
open source topics.
output of: apachectl configtest
ign Up
"Apache is running a threaded MPM, but our PHP Module is not compiled to be
threadsafe. You need to recompile PHP"

I solved in this wa (for apache to render php code): S C R O L L TO TO P


a2dismod mpmevent

24 இ� 20 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

a2enmod mpmprefork

check again with: apachectl configtest


restart apache: service apache2 restart

Hope it works for ou, too.

edwerf May 6, 2016

0 hould this work on 32 bit computers as well? Or do ou need php7 in combination
with 64 bit computer?

I tr to install lamp on ubuntu 16.04 for 2 weeks alread and guess that 32 bit will be the
reason of m failures?

Jasonrawlings June 8, 2016

0 tep 3: Install PHP


$ sudo apt-get install php libapache2-mod-php php-mcrpt php-msql
Reading package lists... Done
Building dependenc tree
Reading state information... Done
E: Unable to locate package php
E: Unable to locate package libapache2-mod-php
E: Unable to locate package php-mcrpt
E: Unable to locate package php-msql

Yeah, this works. Not.

Luraguse June 25, 2016

0 Had the same problem, for future references if someone else gets that error, I onl
had to add a 5 (the current version of php) after php to make it work:
Signsudo
up for our newsletter.
apt-get install php5 libapache2-mod-php5 php5-mcrpt php5-msql ×
Get the latest tutorials on SysAdmin and open source topics.

ign Up
packetsniffer August 20, 2016

0 thank ou ver much for this. I had the same problem as JasonRawlings above.
Your trick worked.
S C R O L L TO TO P

24 இ� 21 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

rboc12 June 9, 2016

0 Nice Tutorial... Question though, I was able to install apache2, php, msql but Web
browser is displaing PHP codes instead of executing it.. M guess is apache issue? an
input? Thanks

wwwhq199 June 18, 2016

Would you like send some information to my mailbox(www.hq199@hotmail.c

Think ver much.

maungthuu July 12, 2016

0 Please Update Tutorial


I can't install php with our command on 16.04
" sudo apt-get install php libapache2-mod-php php-mcrpt php-msql "

It's not working

treehousetim July 14, 2016

0 For those who struggle with seeing the code in the browser instead of the phpinfo()
page...

<? phpinfo();

PHP is
Sign upinstalled
php.ini.
for ourb default with short tags off. Either change our code or change
newsletter. ×
Get
Thisthe
sedlatest tutorials
command willondoSysAdmin
the trick ifand
ouopen source
opt to topics.tags on.
turn short

ign Up
sed -i "s/short_open_tag = .*/short_open_tag = On/" /etc/php/7.0/apache2/p

S C R O L L TO TO P

24 இ� 22 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

mrdrew Septemer 26, 2016

0 Looks like the default is ON.


; shortopentag
; Default Value: On
; Development Value: Off
; Production Value: Off

oargus July 18, 2016

0 Hello everone :D

I have a problem.
I can access the application, phpmadmin, etc. But onl inside the server.

What I need to do, for external access. Like a computer in m network?

viniciusdepaula July 24, 2016

0 Thanks ver nice tutorial!!!

macinfosoft July 28, 2016

0 Awesome! ou made m da!!

macinfosoft July 28, 2016

0 Awesome! I Installed it in 10 minutes. Wow!! All thanks to our tutorial!!

omissoni August 3, 2016

1 Sign up for
For ver lazour newsletter.
ssadmins like me: ×
Get
sudothetasksel
latest tutorials on SysAdmin and open source topics.
then choose LAMP-erver.
Drink a coffee and enjo ign Up

S C R O L L TO TO P
slowdive Decemer 7, 2016

24 இ� 23 Saturday 11 March 2017 11:57 AM


How To Install Linux, Apache, MySQL, PHP (LAMP) stack... https://www.digitalocean.com/community/tutorials/how-to-i...

this is great, this should be indicated at the ver beginning of this tutorial as an
alternative option!
0

kainoack August 11, 2016

0 One of the best tutorials I have ever seen regarding servers. ALL steps worked (!)
without an issue. This is highl professional. Well done.

Load More Comments

This work is licensed under a Creative


Commons Attribution-NonCommercial-
hareAlike 4.0 International License.


Copright © 2017 DigitalOcean™ Inc.

Communit Tutorials Questions Projects Tags Newsletter R 

Distros & One-Click Apps Terms, Privac, & Copright ecurit Report a Bug Get Paid to Write
Sign up for our newsletter.
hop
×
Get the latest tutorials on SysAdmin and open source topics.

ign Up

S C R O L L TO TO P

24 இ� 24 Saturday 11 March 2017 11:57 AM

You might also like