Organizational Research By

Surprising Reserch Topic

To install the default LAMP stack in Ubuntu 10.04 and above


To install the default LAMP stack in Ubuntu 10.04 and above
First refresh your package index...

$ sudo apt-get update
... and then install the LAMP stack:

$ sudo apt-get install lamp-server^
Mind the caret (^) at the end.

Starting over: How to remove the LAMP stack
To remove the LAMP stack remove the following packages:

Note: This assumes you have no other programs that require any of these packages. You might wish to simulate this removal first, and only remove the packages that don't cause removal of something desired.

apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl libnet-daemon-perl libplrpc-perl libpq5 mysql-client-5.5 mysql-common mysql-server mysql-server-5.5 php5-common php5-mysql
To also remove the debconf data, use the purge option when removing. To get rid of any configurations you may have made to apache, manually remove the /etc/apache2 directory once the packages have been removed.

You may also want to purge these packages:

mysql-client-core-5.5 mysql-server-core-5.5
Installing Apache 2
To only install the apache2 webserver, use any method to install:

apache2
It requires a restart for it to work:

$ sudo /etc/init.d/apache2 restart
or

$ sudo service apache2 restart
Checking Apache 2 installation

With your web browser, go to the URI http://localhost : if you read "It works!", which is the content of the file /var/www/index.html , this proves Apache works.

Troubleshooting Apache

If you get this error:

apache2: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName

Ubuntu 13.10+

Use a text editor such as "sudo nano" at the command line or "gksudo gedit" on the desktop to create a new file,

$ sudo nano /etc/apache2/conf-available/fqdn.conf
or

$ gksu "gedit /etc/apache2/conf-available/fqdn.conf"
then add

ServerName localhost
to the file, save it, and enable your new configuration file by running the command below.

sudo a2enconf fqdn
This can all be done in a single command with the following:

$ echo "ServerName localhost" | sudo tee /etc/apache2/conf-available/fqdn.conf && sudo a2enconf fqdn
Ubuntu 13.04 and below

In older versions of Apache, the configuration files were located in a different directory. Use a text editor such as "sudo nano" at the command line or "gksudo gedit" on the desktop to create a new file,

$ sudo nano /etc/apache2/conf.d/fqdn
or

$ gksu "gedit /etc/apache2/conf.d/fqdn"
then add

ServerName localhost
to the file and save. This can all be done in a single command with the following:

$ echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn
Virtual Hosts

Apache2 has the concept of sites, which are separate configuration files that Apache2 will read. These are available in /etc/apache2/sites-available. By default, there is one site available called 000-default. This is what you will see when you browse to http://localhost or http://127.0.0.1. You can have many different site configurations available, and activate only those that you need.

As an example, we want the default site to be /home/user/public_html/. To do this, we must create a new site and then enable it in Apache2.

To create a new site:

Copy the default website as a starting point. sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/mysite.conf

Edit the new configuration file in a text editor "sudo nano" on the command line or "gksudo gedit", for example: gksudo gedit /etc/apache2/sites-available/mysite.conf

Change the DocumentRoot to point to the new location. For example, /home/user/public_html/

In the file: /etc/apache2/apache2.conf, change the Directory directive, replace to

You can also set separate logs for each site. To do this, change the ErrorLog and CustomLog directives. This is optional, but handy if you have many sites

Save the file
Now, we must deactivate the old site, and activate our new one. Ubuntu provides two small utilities that take care of this: a2ensite (apache2enable site) and a2dissite (apache2disable site).

$ sudo a2dissite 000-default && sudo a2ensite mysite
Finally, we restart Apache2:

$ sudo /etc/init.d/apache2 restart
If you have not created /home/user/public_html/, you will receive an warning message

To test the new site, create a file in /home/user/public_html/:

$ echo 'Hello! It is working!' > /home/user/public_html/index.html
Finally, browse to http://localhost/

Installing PHP 5
To only install PHP5. use any method to install the package

libapache2-mod-php5
Enable this module by doing

$ sudo a2enmod php5
which creates a symbolic link /etc/apache2/mods-enabled/php5 pointing to /etc/apache2/mods-availble/php5 .

Except if you use deprecated PHP code beginning only by "
Relaunch Apache 2 again:

$ sudo service apache2 restart
Checking PHP 5 installation

In /var/www , create a text file called "test.php", grant the world (or, at least, Ubuntu user "apache") permission to read it, write in it the only line: "" (without the quotation marks) then, with your web browser, go to the URI "http://localhost/test.php": if you can see a description of PHP5 configuration, it proves PHP 5 works with Apache.
asked Jun 10, 2015 in LINUX by rajesh
0 votes
118 views



Related Hot Questions



Government Jobs Opening


...