May 31, 2012

Beginner

How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu

Tagged In: Ubuntu, My Sql, Apache, Php, Lamp Stack

For Ubuntu 12.04


About LAMP


LAMP stack is a group of open source software used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. Since the virtual private server is already running Ubuntu, the linux part is taken care of. Here is how to install the rest.

Set Up

The steps in this tutorial require the user to have root privileges on your VPS. You can see how to set that up in the Initial Server Setup in steps 3 and 4.

Step One—Install Apache


Apache is a free open source software which runs over 50% of the world’s web servers.

To install apache, open terminal and type in these commands:
sudo apt-get update
sudo apt-get install apache2

That’s it. To check if Apache is installed, direct your browser to your server’s IP address (eg. http://12.34.56.789). The page should display the words “It works!" like this.

How to Find your Server’s IP address


You can run the following command to reveal your server’s IP address.
ifconfig eth0 | grep inet | awk '{ print $2 }'

Step Two—Install MySQL


MySQL is a powerful database management system used for organizing and retrieving data

To install MySQL, open terminal and type in these commands:
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

During the installation, MySQL will ask you to set a root password. If you miss the chance to set the password while the program is installing, it is very easy to set the password later from within the MySQL shell.

Once you have installed MySQL, we should activate it with this command:
sudo mysql_install_db

Finish up by running the MySQL set up script:
sudo /usr/bin/mysql_secure_installation

The prompt will ask you for your current root password.

Type it in.
Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Then the prompt will ask you if you want to change the root password. Go ahead and choose N and move on to the next steps.

It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y                                            
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...
Once you're done with that you can finish up by installing PHP.

Step Three—Install PHP


PHP is an open source web scripting language that is widely use to build dynamic webpages.

To install PHP, open terminal and type in this command.
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

After you answer yes to the prompt twice, PHP will install itself.

It may also be useful to add php to the directory index, to serve the relevant php index files:
sudo nano /etc/apache2/mods-enabled/dir.conf

Add index.php to the beginning of index files. The page should now look like this:
<IfModule mod_dir.c>

          DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm

</IfModule>

PHP Modules


PHP also has a variety of useful libraries and modules that you can add onto your virtual server. You can see the libraries that are available.
apt-cache search php5-

Terminal will then display the list of possible modules. The beginning looks like this:
php5-cgi - server-side, HTML-embedded scripting language (CGI binary)
php5-cli - command-line interpreter for the php5 scripting language
php5-common - Common files for packages built from the php5 source
php5-curl - CURL module for php5
php5-dbg - Debug symbols for PHP5
php5-dev - Files for PHP5 module development
php5-gd - GD module for php5
php5-gmp - GMP module for php5
php5-ldap - LDAP module for php5
php5-mysql - MySQL module for php5
php5-odbc - ODBC module for php5
php5-pgsql - PostgreSQL module for php5
php5-pspell - pspell module for php5
php5-recode - recode module for php5
php5-snmp - SNMP module for php5
php5-sqlite - SQLite module for php5
php5-tidy - tidy module for php5
php5-xmlrpc - XML-RPC module for php5
php5-xsl - XSL module for php5
php5-adodb - Extension optimising the ADOdb database abstraction library
php5-auth-pam - A PHP5 extension for PAM authentication
[...]
Once you decide to install the module, type:
sudo apt-get install name of the module

You can install multiple libraries at once by separating the name of each module with a space.

Congratulations! You now have LAMP stack on your droplet!

Step Four—RESULTS: See PHP on your Server


Although LAMP is installed, we can still take a look and see the components online by creating a quick php info page

To set this up, first create a new file:
sudo nano /var/www/info.php

Add in the following line:
<?php
phpinfo();
?>

Then Save and Exit.

Restart apache so that all of the changes take effect:
sudo service apache2 restart

Finish up by visiting your php info page (make sure you replace the example ip address with your correct one): http://12.34.56.789/info.php

It should look similar to this.

See More

After installing LAMP, you can Set Up phpMyAdmin, Install WordPress, go on to do more with MySQL (A Basic MySQL Tutorial), Create an SSL Certificate, or Install an FTP Server.



By Etel Sverdlov

Share this Tutorial

Vote on Hacker News

Try this tutorial on an SSD cloud server.

Includes 512MB RAM, 20GB SSD Disk, and 1TB Transfer for $5/mo! Learn more

Create an account or login:

138 Comments

Write Tutorial
  • Gravatar pauldmoran over 1 year

    On the droplets that have lower memory foot prints (256MB RAM) please note that the default Ubuntu install of MySQL requires the addition of the line: innodb_buffer_pool_size = 32M In the /etc/mysql/my.cnf file to make it start up.

  • Gravatar Jonathan Lafleur over 1 year

    pauldmoran I have Size: 256 Mb | mage: Ubuntu 12.04 x32 Server and havn't needed to change the innodb_buffer and MySQL is running mysql 2759 0.1 13.6 326656 34036 ? Ssl 12:54 0:00 /usr/sbin/mysqld

  • Gravatar Moisey over 1 year

    The defaults should be good for the majority of users, we will be writing additional MySQL articles specifically geared towards tuning it for higher performance and explaining some of the most common tune variables.

  • Gravatar aladagemre over 1 year

    For enabling PHP, I think we also have to install this: libapache2-mod-php5

  • Gravatar Etel over 1 year

    Thank you for the recommendation: I have added libapache2-mod-php5 to the tutorial.

  • Gravatar madlittlemods over 1 year

    Thanks for the tutorial! Got my droplet up and running ;)

  • Gravatar igor.kandyba over 1 year

    After adding innodb_buffer_pool_size = 32M to my config solved the annoying PDO error - was unable to connect to the db via socket, thanks for the advice!

  • Gravatar onrweb over 1 year

    Hi, I take an error message when I tried to connect MySQL DB from my Play Framework application: "Cannot connected to the database, Communications link failure The last packet sent successfully to the server was 0 milliseconds ago. The driver has not received any packets from the server." and solved the problem like this: It related with mysql configuration file. You must open /etc/mysql/my.cnf: sudo nano /etc/mysql/my.cnf and change bind-address's default value (127.0.0.1) with your ip address: bind-address = ?.?.?.? then problem will be solved. Maybe It can help to some people encounter the same problem.

  • Gravatar teddy about 1 year

    Wouldn't it just be easier to type 'tasksel', scroll down to lamp server, hit spacebar to select it, tab to OK and press enter? It does everything for you, including prompt for a new mysql password.

  • Gravatar mike about 1 year

    teddy, I much prefer that they give the actual methods for installing these from the cmd line, rather than suggesting an automated install. You don't learn anything doing it through tasksel.

  • Gravatar ufjbgjzx472 about 1 year

    rsc jim xx fake rolex uk aru ucn wuqx rolex milgauss replica uk pd mdal ojd medp rolex day date replica

  • Gravatar about 1 year

    Instead of using prefork MPM, you can use the worker or event MPM and process php via FastCGI process manager. Instructions are given here: http://www.failover.co/blog/quick-setup-apache-worker-fastcgi-php-fpm-and-apc

  • Gravatar mathsteck about 1 year

    When I try to install MySQL the follow error appears: "Unable to set password for root...". I already tried to reinstall but without success... Anyone can help me?

  • Gravatar mathsteck about 1 year

    The complete error: "Unable to set password for the MySQL "root" user. An error occurred while setting the password for the MySQL administrative user. This may have happened because the account already has a password, or because of a communication problem with the MySQL server."

  • Gravatar Guo Xiufeng 12 months

    tasksel install lamp-server it's very simple in Ubuntu

  • Gravatar bailet3 12 months

    I don't know about you guys but I prefer to install LAMP in a single click after reading about other methods. Don't know if you are allowed to link to other guides here or not but this one seemed to help as it had alot of screenshots, http://draalin.com/installing-lamp-on-ubuntu/ They had two different installation methods there too which was nice.

  • Gravatar Eliot Landrum 11 months

    Followed these directions to the T with a clean droplet. Getting this error during the apt-get installs: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName The server appears to be working correctly, though.

  • Gravatar laviniamanzanares 11 months

    This is really useful. Thank you

  • Gravatar Kamal Nasser 11 months

    @Eliot Landrum: That is just a warning, you can ignore it --everything will work just fine.

  • Gravatar Martin Ogborne 11 months

    @Eliot Landrum: If you want to get rid of the error then edit /etc/hosts sudo nano /etc/hosts Change the file to read: 127.0.0.1 localhost 'IP' 'server name' 'hostname' For example if your droplet is on IP 12.34.56.78, your Domain is 'example.com' and hostname is 'myhost' then it will read: 127.0.0.1 localhost 12.34.56.78 example.com myhost Save this file and then edit /etc/hostname sudo nano /etc/hostname Delete whatever is in this file and type in your hostname (myhost in the example above) Save the file and reboot and the warning should be gone HTH :-)) *Can an admin delete my reply above as it stripped the important bits out*

  • Gravatar Kamal Nasser 11 months

    "*Can an admin delete my reply above as it stripped the important bits out*" Fixed that for you. Thanks for sharing the solution you found with the others! :]

  • Gravatar basan1991 10 months

    Syntax error on line 4 of /etc/apache2/mods-enabled/dir.conf: Invalid command 'index.php', perhaps misspelled or defined by a module not included in the server configuration Action 'configtest' failed. The Apache error log may have more information. ...fail!

  • Gravatar Kamal Nasser 10 months

    @basan1991 Please pastebin your apache virtualhost config.

  • Gravatar adarshaj+digitalocean 10 months

    An easy setup for lamp server is done by executing ` sudo apt-get install 'lamp-server^' `. No need to install individually one after other. (I have learnt this trick over years of usage of ubuntu server)

  • Gravatar Marcelo de Queiroz 10 months

    Dear Sirs I have a site about cars in Brazil (www.autopolis.com.br ) and I'm upgrading to Digital Ocean. I’ll use a Droplet to the database and another Droplet to the other files (Wordpress is the site CMS). The issue is that I need to migrate the site in phases and must first migrate the Database, then the other files. I created the Droplet to the Database but my site (hosted in a host here in Brazil) has the access blocked to MySQL. I believe that the reason for it is the fact that the requests are made from another server (with another IP), but I don’t know how to solve this (I'm still newbie in this type of setting). I have added a file in order to make connection test within the area of my host here in Brazil, and the return is as follows: - "Warning: mysql_connect() [function.mysql-connect]: Lost connection to MySQL server at 'reading initial communication packet', system error: 111" - "Warning: mysql_select_db() [function.mysql-select-db]: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)" Thanks in advance for your support!

  • Gravatar Kamal Nasser 10 months

    @Marcelo: Does your host provide you with phpmyadmin access? You can create a MySQL dump using phpmyadmin's export feature and import it on the database droplet.

  • Gravatar Marcelo de Queiroz 9 months

    Hello Kamal, thanks for your support! I have solved the problem allowing remote MySQL database connection. But, I have another problem now: the website is really very slow. Is there another setup to do?

  • Gravatar Kamal Nasser 9 months

    @Marcelo: What's the latency to your droplet? Try using monitoring software such as NewRelic to monitor your application's performance and get exact details on what's causing the slowness.

  • Gravatar ernesto.carreras 9 months

    I can’t move from the following step: Add index.php to the beginning of index files. The page should now look like this: DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm I added the index.php but I am not sure what to do next…I cannot hit enter or nothing else in order to continue with the next step.

  • Gravatar Kamal Nasser 9 months

    @ernesto.carreras: Try pressing Control-X, y, enter. That should save the file and exit nano.

  • Gravatar neil.niekerk 9 months

    mark@Lexington:~$ ifconfig eth0 | grep inet | awk '{ print $2 }' addr: So, there is no IP address? All I did was: sudo aptitude install apache2

  • Gravatar Kamal Nasser 9 months

    @neil.niekerk: What's the output of "ifconfig"?

  • Gravatar ernesto.carreras 9 months

    Thanks!!!!

  • Gravatar zanderwork 9 months

    How do I start this server when I turn on my computer? I ran sudo service apache2 start, and the page that says It Works! still isn't loading! Help me!

  • Gravatar Kamal Nasser 9 months

    @zanderwork: Does "sudo service apache2 start" output any errors? What's the output of the following command?

    netstat -plutn | grep 80

  • Gravatar zanderwork 9 months

    'sudo service apache2 start' gives: * Starting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName httpd (pid 1327) already running 'netstat -plutn | grep 80' gives: (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) tcp6 0 0 :::80 :::* LISTEN -

  • Gravatar Kamal Nasser 9 months

    @zanderwork: what's the output of 'ps auxww | grep 1327'?

  • Gravatar zanderwork 9 months

    1000 2441 0.0 0.0 132760 4004 ? Sl 13:14 0:00 /usr/lib/gvfs/gvfsd-metadata 1000 2984 0.0 0.0 13632 956 pts/0 S+ 13:15 0:00 grep --color=auto 1327

  • Gravatar Kamal Nasser 9 months

    @zanderwork: Weird. Are you still not able to access the website? What's the output of

    netstat -plutn | grep 80

  • Gravatar marksworn 9 months

    Thanks! Worked perfectly after spending about a day trying to get this configured properly!

  • Gravatar lindahl22 9 months

    Is this the best way to uninstall MySQL?

    sudo apt-get remove --purge mysql-client mysql-server  mysql-common libapache2-mod-auth-mysql php5-mysql
    sudo apt-get autoremove
    sudo apt-get autoclean

  • Gravatar Kamal Nasser 9 months

    @lindahl22: That works, but

    sudo apt-get remove mysql-server && sudo apt-get autoremove
    should be enough.

  • Gravatar felix.johnson 9 months

    kamal: I have Wordpress index.php in my root dir which makes it impossible to put in my sites index file....what should I do?

  • Gravatar Kamal Nasser 9 months

    @felix.johnson: Please do not duplicate your questions -- you already posted here: https://www.digitalocean.com/community/articles/how-to-install-wordpress-on-ubuntu-12-04

  • Gravatar neil.niekerk 8 months

    Before changing MySQL to remove anonymous user and "answer Yes to", per the above, I could see my 192.168.0.101/info.php. Now I cannot. My IP is 192.168.0.101. When I type 192.168.0.101/info.php I get an error. When I type http://localhost/test.php I get the PHP Version 5.3.10-1ubuntu3.7 (info page). Is this supposed to be this way, or does something need fixing?

  • Gravatar Kamal Nasser 8 months

    @neil.niekerk: What do you have in /var/www?

    ls -lah /var/www

  • Gravatar contact 8 months

    You receive error while setting up htaccess password. cammond not found htpasswd. install apache2 utilities. by sudo apt-get install apache2-utils

  • Gravatar prabhu.k.raj 8 months

    I have finished the Server Configuration But After i installed Apache : I got this error : Syntax error on line 238 of /etc/apache2/apache2.conf: Could not open configuration file /etc/zpanel/configs/apache/httpd.conf: No such file or directory Action 'start' failed.

  • Gravatar Kamal Nasser 8 months

    @prabhu.k.raj: Do you have zPanel installed?

  • Gravatar prabhu.k.raj 8 months

    Before I tried installed LAMP STACK,I installed ZPANEL(Control Panel), I doubt this is creating problem now. The httpd.conf file located /etc/zpanel.How to remove the Zpanel Installation and process normal apache installation! or Fix apache with Zpanel installation.Help is needed!

  • Gravatar Kamal Nasser 8 months

    It's actually what's causing the problem. Run the following command:

    sudo vim /etc/apache2/apache2.conf
    This will launch vim, a text editor. Once it's there, type this:
    :238
    dd
    :wq
    Then restart Apache:
    service apache2 restart

  • Gravatar prabhu.k.raj 8 months

    Thanks for the Reply. First I have opened VI editor(VIM command is not wokring) I went to 238 Line, I have seen the httpd.conf line.When i typed dd,It removed When i saved it and quit, I restarted. /usr/sbin/apache2ctl: 87: ulimit: error setting limit (Operation not permitted) apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName and More errors are displaying.

  • Gravatar Kamal Nasser 8 months

    Are you running it as root?

    sudo service apache2 restart

  • Gravatar prabhu.k.raj 8 months

    I have done this Now i am getting this error when i access in the url In the /var/www folder, I have index.html/info.php exists. Not Found The requested URL /info.php was not found on this server. Apache/2.2.22 (Ubuntu) Server at 37.139.18.195 Port 80

  • Gravatar Kamal Nasser 8 months

    @prabhu.k.raj: What do you have in /etc/apache2/sites-enabled?

    ls -lah /etc/apache2/sites-enabled

  • Gravatar prabhu.k.raj 8 months

    drwxr-xr-x 2 root root 4.0K Dec 28 2012 . drwxr-xr-x 7 root root 4.0K Aug 14 04:13 .. lrwxrwxrwx 1 root root 26 Dec 28 2012 000-default -> ../sites-available/default

  • Gravatar Kamal Nasser 8 months

    @prabhu.k.raj: Please pastebin 000-default and apache2.conf:

    cat /etc/apache2/sites-enabled/000-default | curl -F 'sprunge=<-' http://sprunge.us
    cat /etc/apache2/apache2.conf | curl -F 'sprunge=<-' http://sprunge.us

  • Gravatar felix.johnson 8 months

    I have my index file in /var/www/ but cannot access it , why?

  • Gravatar Kamal Nasser 8 months

    @felix.johnson: What do you mean by "cannot access it"? Do you get any errors? Can you access other files in /var/www?

  • Gravatar akurczyk 8 months

    Add index.php to the beginning of index files. The page should now look like this:

    
              DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm
    
    
    index.php is there already.

  • Gravatar phellipe.andrade 8 months

    I try to install the extension PCNTL of php but when i try to get the source by sudo apt-get source php5 I get this error E: You must put some 'source' URIs in your sources.list how can I solve?

  • Gravatar Kamal Nasser 8 months

    @phellipe.andrade: Try this instead:

    sudo apt-get install php5-dev php-pear
    sudo pecl install pcntl

  • Gravatar coreymberman 8 months

    If index.php is giving Error 500, but index.html works, try changing the permissions. sudo chmod 755 -R /var/www/

  • Gravatar 3Easy 8 months

    Slightly off topic, but this… I’ve follows these intructions to get a LAMP stack, then I’ve installed the php5-curl module. However I’m not sure cURL is working properly, is there another step to include cURL in what’s available to PHP. This is my stack… http://192.241.211.42/info.php

  • Gravatar Kamal Nasser 8 months

    @3Easy: Seems like curl is installed properly: http://192.241.211.42/info.php#module_curl Make sure you install the binary executable if you don't have it installed already:

    sudo apt-get install curl

  • Gravatar daniel 7 months

    I'm going to be moving my personal blog, http://www.danielmorgan.co.za , from my current ISP to my Digital Ocean droplet! I am very excited, as I love these type of projects! Thank you Digital Ocean for your excellent service!

  • Gravatar obenns 7 months

    After following your tutorial twice of both initial set up and LAMP set up, I cannot restart Apache2 from user: (13)Permission denied: make_sock: could not bind to address [::]:80 (13)Permission denied: make_sock: could not bind to address 0.0.0.0:80

  • Gravatar Kamal Nasser 7 months

    @obenns: Another process is already listening on port 80. It could be a non responding apache process. What's the output of

    netstat -plutn | grep 80
    ?

  • Gravatar bda.awk 7 months

    I have a problem after line command sudo /usr/bin/mysql_secure_installation. If I press enter ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) if not ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) How to fix this

  • Gravatar Kamal Nasser 6 months

    @bda.awk: Try entering your root password once you run mysql_secure_installation.

  • Gravatar Ishank Badhani 6 months

    Thanks for this informative tutorial. I am new to VPS, and I am learning lots of new things. My question: I'm setting up my WordPress website from scratch. Please let me know, do we need to install all PHP libraries and modules (or there're few specific modules) for my WordPress blog. ?

  • Gravatar Kamal Nasser 6 months

    @Ishank: Apache's mod_php comes with a few extensions installed by default. Should you need other extensions you can install them by running sudo apt-get install php5-extension-name (e.g. sudo apt-get install php5-gd)

  • Gravatar Robert Tagg 6 months

    Nice tutorial but I have found that under ubuntu this whole process can be done by simply running "sudo apt-get install lamp-server^".

  • Gravatar cedulestarragones 6 months

    how i could change the php file upload limit in Ubuntu? i can't install a theme in wordpress because the size, thanks

  • Gravatar Kamal Nasser 6 months

    @cedulestarragones: See http://stackoverflow.com/questions/2184513/php-change-the-maximum-upload-file-size

  • Gravatar nyombironald 6 months

    Hey guys I need your help I managed to install php and It works very nicer but why is it that if I make any error in my program I can't see which line I have made it, I just get this error Server error The website encountered an error while retrieving http://localhost/test.php. It may be down for maintenance or configured incorrectly.

  • Gravatar nyombironald 6 months

    And another thing is that I can't work on files if I try this

  • Gravatar Kamal Nasser 6 months

    @nyombironald: You will need to enable error reporting in your php files in order to see errors:

    <?php
    ....
    ini_set('display_errors', 1);
    error_reporting(-1);
    

  • Gravatar emanuelacu 6 months

    Excellent post, clean and useful... =) thanks

  • Gravatar flavioafa 6 months

    Hello! I´m in step 2 and the package "libapache2-mod-auth-mysql" not exist in ubuntu 1310. I can replace what package? Thanks!

  • Gravatar Kamal Nasser 6 months

    @flavioafa: You do not need that package on Ubuntu 13.10, you can simply ignore it.

  • Gravatar alex 6 months

    And I think that running 'tasksel' and selecting LAMP is easier, no?

  • Gravatar mattbaker+digitalocean 6 months

    Fanastic! tasksel didn't work for me, but the rest did...super easy and painless... thank you!!!

  • Gravatar scotty 6 months

    Have encountered a problem - could anyone assist ? I've set up several computers following the LAMP stack instructions on this page - and all has gone well with no problems (those were ubuntu 12.04 lts - 64 bit installs). However, today (11-4-13) after carefully following these same instructions (on a ubuntu 12.04 lts - 32 bit machine), my LAMP stack install is not working. The apache server appears to work - in that you get the: "It Works" page when typing this machines IP address. However, the command: sudo service apache2 restart - generates the error message: * Restarting web server apache2 apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.106 for ServerName apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.1.106 for ServerName (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs Action 'start' failed. The Apache error log may have more information. [fail] ------------------------------------------- In addition - the: info.php & phpmyadmin pages generate: "Error Not Found" would anyone care to advise on how to fix this ?

  • Gravatar Kamal Nasser 6 months

    @scotty: There is another program listening on port 80 so apache cannot bind to that port. What's the output of

    sudo netstat -plutn | grep 80
    ?

  • Gravatar syaiful 5 months

    Hi, the php version I get is just 5.3. How I can get update to 5.5 for example?

  • Gravatar Kamal Nasser 5 months

    @syaiful: Which version of Ubuntu are you using?

  • Gravatar andy.mclane 5 months

    sudo apt-get install apache2-utils in case htpasswd command not found

  • Gravatar rbgoksoy 5 months

    Hi, i did all steps and my ip is responding but how can i add my domain name? What is the necessary steps and configrations? Thanks!

  • Gravatar Kamal Nasser 5 months

    @rbgoksoy: See https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts and https://www.digitalocean.com/community/articles/how-to-set-up-a-host-name-with-digitalocean.

  • Gravatar rbgoksoy 5 months

    Hi again, i found this topic; https://www.digitalocean.com/community/articles/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts I will use this, Thanks!

  • Gravatar rbgoksoy 5 months

    Hi Kamal Nasser, This tab was open so i did not see your message and i wrote "found message" but thanks a lot!

  • Gravatar Kamal Nasser 5 months

    @rbgoksoy: That is okay, please let me know if that works :]

  • Gravatar rbgoksoy 5 months

    Hi Kamal Nasser First of all thanks for your concern :) I rebuild my server with Lamp and applied your two suggestions and my domain name is working! Thanks!

  • Gravatar Kamal Nasser 5 months

    @rbgoksoy: Sweet! Glad to hear :]

  • Gravatar Ryan Winchester 5 months

    Does anyone know how I would do this with Puppet (making a puppet manifest .pp file)?

  • Gravatar bylucasinf 5 months

    apt-cache search php5- for sudo apt-cache sarch php5-

  • Gravatar vici 5 months

    The above guide gave me mysql 5.5.x installed, but I need mysql 5.6 because I need to use full text index with innodb, is there any tutorial in digital ocean how to upgrade from mysql 5.5 to 5.6? OR install mysql 5.6 on Ubuntu 12.04 fresh droplet. thanks

  • Gravatar Kamal Nasser 5 months

    @vici: Try using ondrej's mysql repo:

    sudo apt-get install software-properties-common
    sudo add-apt-repository ppa:ondrej/mysql-experimental
    sudo apt-get update
    sudo apt-get upgrade

  • Gravatar Ruchira Sahan 5 months

    Nice guide. But I cant find Apache maxclients and other settings anywhere on the apache2.conf . Any idea where to find settings to tune Apache?

  • Gravatar thekar 5 months

    thekar@website-tricks:~$ sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql Reading package lists... Done Building dependency tree Reading state information... Done Some packages could not be installed. This may mean that you have requested an impossible situation or if you are using the unstable distribution that some required packages have not yet been created or been moved out of Incoming. The following information may help to resolve the situation: The following packages have unmet dependencies: libapache2-mod-auth-mysql : Depends: apache2.2-common (>= 2.2.3-3) but it is not going to be installed E: Unable to correct problems, you have held broken packages.

  • Gravatar SaM5246 4 months

    ****Error****** 12/16/2013 using Ubuntu 13.10 Package libapache2-mod-auth-mysql is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source E: Package 'libapache2-mod-auth-mysql' has no installation candidate

  • Gravatar Kamal Nasser 4 months

    @thekar: @SaM5246: You don't need to install libapache2-mod-auth-mysql on Ubuntu 12.10+. You can safely remove it from the list of packages to install.

    sudo apt-get install mysql-server php5-mysql 

  • Gravatar Ahmed Elmasry 4 months

    The above tutorial will install PHP 5.3.1 if you're using Ubuntu 12.04, to install PHP 5.4.x instead, use the following commands to install PHP: sudo apt-get update sudo apt-get install python-software-properties sudo add-apt-repository ppa:ondrej/php5-oldstable apt-cache policy php5 sudo apt-get install php5

  • Gravatar parthasarathip 4 months

    After installing apache2 using the LAMP stack as described above, I cannot access my web page which is created in /var/www/info.php. my netstat -plutn | grep 80 output was: tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 49035/apache2 my ls -lah /etc/apache2/sites-enabled output was: total 8.0K drwxr-xr-x 2 root root 4.0K Dec 20 10:26 . drwxr-xr-x 7 root root 4.0K Dec 27 11:18 .. lrwxrwxrwx 1 root root 26 Dec 20 10:26 000-default -> ../sites-available/default I don't know why I cannt access my page. Could you guys help me to sort out this issue? Thanks.

  • Gravatar Kamal Nasser 4 months

    @parthasarathip: What error do you get when you try to browse to http://yourdroplet'sipaddress/info.php?

  • Gravatar parthasarathip 4 months

    @Kamal Nasser: Thanks for your reply. My server people didn't open http port. So after opening that port Apache working good.

  • Gravatar bradlestrange1997 3 months

    Im going to be running wordpress on my server. What php modules would I need? Should I just install all of them?

  • Gravatar Kamal Nasser 3 months

    @bradlestrange1997: I believe you'll need only php5-gd.

  • Gravatar KiwoT 3 months

    If I later change the Mysql username from to something else because of security, do I need to add those changes to other programs that uses mysql? Eg postfix. Just so I dont change the Mysql username and then some programs that use mysql wont work. thanks

  • Gravatar Kamal Nasser 3 months

    @KiwoT: Usually it won't affect other programs because they aren't (and shouldn't be) using the root account to log in to MySQL.

    RENAME USER root TO new_user;
    should work just fine.

  • Gravatar alexander 3 months

    instead of showing me the .php results, the server downloads the file to my computer. i copied the code exactly. what is wrong. please email me: [email protected] thank you.

  • Gravatar Kamal Nasser 3 months

    @alexander: What's the output of the following command?

    sudo netstat -plutn | grep 80

  • Gravatar Christian Quispe 3 months

    Excelente, gracias

  • Gravatar atul2312 3 months

    use info.php in dir.conf instead of index.php to see phpinfo output

  • Gravatar mario 3 months

    The command for listing php extensions leaves some out useful entries such as "php-apc" since they aren't prefixed with "php5-". Since apt-cache accepts regular expressions it is easy to list all entries beginning with "php5-" or "php-": apt-cache search "^php5-|^php-" To go one step further you could pipe the output to sort to get an alphabetical list: apt-cache search "^php5-|^php-" | sort NOTE: One caveat with sort is that it will list all of the php5 extensions first then all of php extensions, however I still find it much easier to look through the sorted list than the unsorted version.

  • Gravatar KiwoT 2 months

    I am using ubuntu 12.04 LTS so I had to update my php version to 5.4.x , but now when I have updated php I always get these messages in my log file every sunday morning: I am getting this message every sunday morning and I have no idea what causing it. These are the messages: [Sun Jan 03 07:35:03 2014] [notice] Graceful restart requested, doing restart [Sun Jan 03 07:35:04 2014] [notice] Apache/2.2.22 (Ubuntu) PHP/5.4.17-5+debphp.org~precise+1 configured -- resuming normal operations Why do they come? This is how I update my php version: sudo apt-get update sudo apt-get install python-software-properties sudo add-apt-repository ppa:ondrej/php5-oldstable sudo apt-get update. The update worked fine, now im running 5.4.x but I keep getting those messages in my log every sunday morning since I updated

  • Gravatar Kamal Nasser 2 months

    @KiwoT: That's fine. Logrotate reloads apache after it rotates the log files, you can ignore that notice. (See https://www.digitalocean.com/community/questions/graceful-restart-requested-doing-restart)

  • Gravatar Krzysztof Wolniak 2 months

    How Can i Install PHP 5.5 and MySQL 5.6? For MySQL sudo add-apt-repository ppa:ondrej/mysql-experimental don't work i get: command not found. What about PHP 5.5?

  • Gravatar Kamal Nasser 2 months

    @Krzysztof: Try running the following command first:

    sudo apt-get install software-properties-common

  • Gravatar Krzysztof Wolniak 2 months

    @Kamal Thanks, it helped me. But now wehen I'm doing ```sudo /usr/bin/mysql_secure_installation``` and provide password, i get socket connection problem.

  • Gravatar digital.ocean about 1 month

    Well done tutorial! Great step-by-step LAMP how-to & everything worked! Thanks!!

  • Gravatar hayderimran7 about 1 month

    Awesome tutorial man. I had a baffling ordeal uninstalling the openstack dashboard I installed, because with its presence, i could not have apache2 working properly. With this tutorial, I figured out i have to remove+purge all apache2 files first, that delete that freaking ''stack'' user i created for openstack dashboard. and reinstalled apache2, and now ''It works'' shows up. this tutorial saved me. thanks again dude and btw, anyone having trouble deleting an ubuntu user by getting an error ''user is currently logged in''..here is what I figured out: its because the user you created is having server instances run on apache2, even if you try kill these process and these instances somehow respawn with different ID. so best is , delete all config files of apache2 and remove it. After that deleting an ubuntu user is just one step process. hope if someone sharing same fate as mine with openstack and deleting ubuntu user sees this and save him from agony :(

  • Gravatar jackrim1 about 1 month

    I'm a complete coding newbie please help! once I've added index.php to the directory how do I exit so I can continue with the next steps?

  • Gravatar mikelow.u94 about 1 month

    Thanks! The instructions were concise, and the process took very little time to complete. My one question is How do I know which modules I need to install? I selected the ones I were familiar with, but did not include every module. Great job with the instructions!

  • Gravatar mikelow.u94 about 1 month

    @jackrim1: You may have solved the answer to your question by now, but just in case... When you entered sudo nano /etc/apache2/mods-enabled/dir.conf, it took you out of the command line and into the nano text editor so you could add index.php at the beginning of the config file. Do a ctrl+x and you'll be prompted to answer to Save your changes. Hit Y, and then Enter. It will then return you to the command line.

  • Gravatar william.lam1 about 1 month

    Hi there I skipped one step ahead by accident and changed the root password instead of keeping it blank, would this pose any problems? It was specifically for the step 2. "Then the prompt will ask you if you want to change the root password. Go ahead and choose N and move on to the next steps" Thank you and appreciate your help! - Will

  • Gravatar Kamal Nasser about 1 month

    @william.lam1: That should be fine :]

  • Gravatar Kamal Nasser about 1 month

    @mikelow.u94: You should install only the modules you need.

  • Gravatar aknath.707 about 1 month

    Here is a step by step tutorial: http://wp.me/p3Po0l-hq

  • Gravatar Paul Waldmann about 1 month

    Let's see how it goes.

  • Gravatar dhnjy18 about 1 month

    I found this tutorial helpful, thankssssssssssssss

  • Gravatar jackrim1 30 days

    @mikelow.u94 thanks very much! I've now reached the point of starting apache and it comes up with this error message: "syntax error on line 5 of /etc/apache2/mods-enabled/dir.conf: invalid command 'index.php', perhaps misspelled or defined by a module not included in the server configuration Action 'configtest' failed" I've followed the instructions to the letter so I can't work out what is wrong?

  • Gravatar andrey 20 days

    yes, i have the same trouble

  • Gravatar pluc16 17 days

    Very nice tutorial. Would be epic if we could have more info about installing php5-fpm and make it rocks.

  • Gravatar Etel Sverdlov 17 days

    We have details on php-fpm here: https://www.digitalocean.com/community/articles/how-to-install-linux-nginx-mysql-php-lemp-stack-on-ubuntu-12-04

  • Gravatar david.nickersonexus 14 days

    Hi thanks for the tutorial, really clear even for idiots like me. Is there an extra step required to access the website content from outside of the local network? The pages all come up fine on things linked to the house WiFi but I don't seem to be able to access them across the web. Apologies if this is a stupid question, I usually only play with hardware.

  • Gravatar kibostoz 1 day

    Similar to the guys above, can't view my info.php on a fresh new Ubuntu 14.04. Netstat gives the following: tcp6 0 0 :::80 :::* LISTEN 6268/apache2 ls -lah /etc/apache2/sites-enabled gives this: total 8.0K drwxr-xr-x 2 root root 4.0K Apr 18 10:46 . drwxr-xr-x 8 root root 4.0K Apr 18 10:46 .. lrwxrwxrwx 1 root root 35 Apr 18 10:46 000-default.conf -> ../sites-available/000-default.conf Would be grateful for an advice!

Leave a Comment

Create an account or login:
Ajax-loader