Search This Blog

Saturday, July 28, 2012

How To Install XAMPP 1.7.7 Under Ubuntu 11.10/11.04/12.04

XAMPP is simply a cross-platform Apache distribution that includes the following:

  • MySQL
  • PHP
  • Perl

UPDATEXAMPP 1.8.0 Available


The installation for XAMPP is very simple, just download and extract the files to the appropriate folder and start it. If you find difficulties installing XAMPP under Ubuntu, then this tutorial may help you, which contains simple instructions and fixes for some errors that you may encounter while using this Apache web server.

XAMPP Installation

To install it under Ubuntu 11.10/11.04/12.04 or any older version of Ubuntu, open the terminal and run these commands:

cd /tmp && wget -O xampp-linux-1.7.7.tar.gz http://goo.gl/mZx8B


sudo tar xvfz  xampp-linux-1.7.7.tar.gz  -C /opt

Start now XAMPP with the following command:

sudo /opt/lampp/lampp start

You can now access XAMPP from this link to see if it is well started:

http://localhost



The default folder for installing your web files and applications is /opt/lampp/htdocs. For stopping or restarting XAMPP, you can use later these commands:

sudo /opt/lampp/lampp stop

sudo /opt/lampp/lampp restart

Adding A Control Panel For XAMPP (Optional)

To add a control panel for XAMPP under Ubuntu to start/stop Apache/MySQL/ProFTPD via a GUI, then run the following commands:

wget http://dl.dropbox.com/u/47950494/xampp-control-panel.desktop


mv xampp-control-panel.desktop ~/.local/share/applications/


Starting XAMPP Automatically At Startup

Open the terminal and run this command:

sudo gedit /etc/init.d/xampp

Add now these two lines:

#!/bin/bash
/opt/lampp/lampp start



Press Ctrl+Q and save your file. Next, give this script file execution permission with this command:

sudo chmod a+x /etc/init.d/xampp

Then run this command:

sudo update-rc.d xampp defaults

In the next system reboot, XAMPP will start automatically.


Troubleshooting

If you get these errors when starting XAMPP:

Error 1:

XAMPP: Another MySQL daemon is already running.

Fix it with this command:

sudo /etc/init.d/mysql stop

Error 2:

XAMPP: Couldn't start MySQL!

Fix it with these commands:

sudo chown -hR root /opt/lampp


sudo chmod -R 777 /opt/lampp


sudo /opt/lampp/lampp restart

That's it!


NoteCan also be installed in Ubuntu 12.04/10.10/10.04.

Install XAMPP 1.8.0 From PPA On Ubuntu 12.04/Linux Mint 13

XAMPP 1.8.0 is the latest version that has been released recently by the Apache Friends team. XAMPP is an Apache web server that includes PHP, Perl, MySQL, and some other useful packages. XAMPP 1.8.0 brings more new features, some bug fixes, and improvements for XAMPP Control Panel, which seems stable now.

Here are the packages updated in this release:


  • Apache 2.4.2
  • MySQL 5.5.25a
  • PHP 5.4.4
  • phpMyAdmin 3.5.1
In this tutorial we will help you install XAMPP 1.8.0 from PPA. If you want to install it manually, you can check this page.

XAMPP 1.8.0 Installation


To install XAMPP 1.8.0 in Ubuntu 12.04/11.10 or Linux Mint 13 (Maya), open the terminal and run the following commands:


sudo add-apt-repository ppa:upubuntu-com/xampp
sudo apt-get update
sudo apt-get install xampp


Before starting XAMPP, you have to stop Apache and MySQL servers if you are already using another web server like LAMP, for example. To do this, run these commands from the terminal to stop Apache & MySQL:

sudo /etc/init.d/apache2 stop


sudo /etc/init.d/mysql stop

You can now start XAMPP using XAMPP Control Panel from the Unity Dash:




Or start XAMPP with this command:

sudo /opt/lampp/lampp start

You can now test XAMPP by opening this link (replace "localhost" with your own server IP address if needed):

http://localhost

If the installation is successful, you may see this page:


For more information, you may check the guides we have written here and here for XAMPP 1.7.7.

That's it!

How to install XAMPP in Ubuntu

How to install XAMPP in Ubuntu


In this tutorial you can understand how to install XAMPP in Ubuntu. XAMPP is the package which provide you PHP, Apache, MySQL, Sqlite and many more other services. Earlier XAMPP was known as LAMPP so don't get confused, you are on the right way.

As XAMPP comes in compressed package. You have to decompress it and install it. For this you have to use terminal so open terminal [ctrl+alt+T] and type the following commands step by step.


1.   First you have to extract file from their '.tar.gz' file using
      the following command in /opt directory.

           sudo tar xvfz xampp-linux-1.7.7.tar.gz -C /opt


2.   Now XAMPP is installed in /opt/lampp directory so you
      can start it by issuing the following command.

            sudo /opt/lampp/lampp start


and you get the following message if the installation done successfully.

Starting XAMPP for Linux 1.7.7...
XAMPP: Starting Apache with SSL (and PHP5)...
XAMPP: Starting MySQL...
XAMPP: Starting ProFTPD...
XAMPP for Linux started.


Now you can check the installation of XAMPP by writing http://localhost in any of your browser.



If in case you want to remove XAMPP, first you have to stop all the services which are currently running. For this execute the following command.

      sudo /opt/lampp/lampp stop

And you get the following information.

Stopping XAMPP for Linux 1.7.7...
XAMPP: Stoping Apache with SSL...
XAMPP: Stoping MySQL...
XAMPP: Stoping ProFTPD...
XAMPP stopped.

Now issue the following command to remove/uninstall the complete directory /opt/lampp

        sudo rm -rf /opt/lampp




If you want to see the video of this tutorial for how to do, here is the video of it.


Installing Xampp-1.7.7 Web server in Ubuntu 11.10

Installing Xampp-1.7.7 Web server in Ubuntu 11.10

If you are a web designer/developer, you need to have a running local server to test your website. Installing a full pledged server and all of its components manually is a very tedious task because you first need to install the actual server (like apache) then download all modules that you need (MYSql, PHP, etc) and configure them to make all the bits and pieces to work together. Thanks to folks at apachefriends.org, we can have a working server with all of the required modules (Apache, PHP, MYSql, etc) just by installing a single application called Xampp. In this post we will see how to install Xampp-1.7.7 on Ubuntu 11.10.

Download the package

Fire up the terminal and issue the following command to download the .tar.gz package
If the download is interrupted for some reason, fear not, because wget can resume interrupted downloads. Simply execute the following command
Observe the -c switch in the command, it tells wget to resume the previously interrupted download.

Extract Contents

After the downloading is finished, extract the tar package into /opt directory.
1sudo tar xvfz xampp-1.7.7.tar.gz -C /opt
You need root password to run the following command.

Start the Server

If the above command executed with no errors, then, the server is correctly installed. Now to start the server, issue the following the command
1sudo /opt/lampp/lampp start
Point to note, xampp under linux is called lampp.
To check if the server is running open any web browser and type http://localhost in the address bar. You should see the following welcome screen.
XAMPP Splash Screen
XAMPP Splash Screen

Shutdown the Server

If you need to shut down the server, run the following command in the terminal
1sudo /opt/lampp/lampp stop

Adding Custom .html pages

Ok, you got server up and running, but where should you put your html files? By default Xampp (Apache) expects all your website related files inside /opt/lampp/htdocs folder. Let us create a test page, test.html, with the following contents,
1    My Test Page
2pre>
3<h3>This is a test pageh3>
4<pre>
Now if you try to save the file in /opt/lampp/htdocs/ directory, you will get an error because of authentication problem. This is because, currently only root has access to /opt/lampp/htdocs/ directory

Authentication Issue

The following commands solves the authentication issues,
1sudo adduser USERNAME www-data
2sudo chown -R USERNAME:www-data /opt/lampp/htdocs
3sudo chmod -R g+rw /opt/lampp/htdoc
Replace USERNAME with your username. What the above commands actually does is
  1. It adds you (User) to www-data (Group)
  2. Changes the ownership of the /opt/lampp/htdocs directory so that you will be the owner.
  3. Issue read+write permissions to the group www-data
Now, you can add the file, test.html, to /opt/lampp/htdocs folder. If everything is done correctly, you can view the file from browser by clicking this link http://localhost/test.html.

Create symbolic link [optional]

To make things simple, you can create a link in your home folder that points to /opt/lampp/htdocs folder
1sudo ln -s /opt/lampp/htdocs /home/USERNAME/htdocs
So that’s it for now. In the next post, I will tell you how to host multiple websites in your local server…
Related Posts:

Difference between wamp, lamp and xampp


Hello all. Today i will discuss about the difference between wamp, lamp and xampp. All these three are used for serving php websites and acts as the local server so that you can see your working website without uploading it first.
Lets first discuss about wamp.
wamp
wamp
wamp stands for windows, apache, mysql, php.
The best advantage of using wamp is that it is easy to setup configuration in wamp. But when i started using wamp, some times i faced problems while running php code , may be it was my coding problem but what else. Mostly people talk that wamp is not good for beginner but i say that wamp is very easy to use and it is best for both beginner and advanced users.
Now lets discuss about xampp.
xampp
xampp
xampp stands for x-os, apache, mysql, php , perl. x-os means it can be used for any operating system. xampp is easy to use than wamp. Its cpanel is very nice and good for beginner and its start, pause and stop button work very nicely by functionality. You can add other services to xampp also. I personally use xampp for my development.
Last thing is lamp. Lets discuss what is lamp.
lamp
lamp
lamp stands for linux, apache, mysql, php. Its functionality is same as wamp and xampp. I want to tell you one thing that the main functionality of all these three(wamp, xampp, lamp) are same i.e compile and run the php code, manage databases and other stuff. All these softwares give us ease in our development so that the complexity of handling all the services(databases handling, code manipulation) becomes easy for us.
Its time for me to end this topic so tc and have a good time. Bye…

Related Posts

HTTPD - Apache2 Web Server

HTTPD - Apache2 Web Server

Apache is the most commonly used Web Server on Linux systems. Web Servers are used to serve Web Pages requested by client computers. Clients typically request and view Web Pages using Web Browser applications such as Firefox, Opera, or Mozilla.
Users enter a Uniform Resource Locator (URL) to point to a Web server by means of its Fully Qualified Domain Name (FQDN) and a path to the required resource. For example, to view the home page of the Ubuntu Web site a user will enter only the FQDN. To request specific information about paid support, a user will enter the FQDN followed by a path.
The most common protocol used to transfer Web pages is the Hyper Text Transfer Protocol (HTTP). Protocols such as Hyper Text Transfer Protocol over Secure Sockets Layer (HTTPS), and File Transfer Protocol (FTP), a protocol for uploading and downloading files, are also supported.
Apache Web Servers are often used in combination with the MySQL database engine, the HyperText Preprocessor (PHP) scripting language, and other popular scripting languages such as Python and Perl. This configuration is termed LAMP (Linux, Apache, MySQL and Perl/Python/PHP) and forms a powerful and robust platform for the development and deployment of Web-based applications.

Installation

The Apache2 web server is available in Ubuntu Linux. To install Apache2:
  • At a terminal prompt enter the following command:
    sudo apt-get install apache2
    

Configuration

Apache2 is configured by placing directives in plain text configuration files. These directives are separated between the following files and directories:
  • apache2.conf: the main Apache2 configuration file. Contains settings that are global to Apache2.
  • conf.d: contains configuration files which apply globally to Apache2. Other packages that use Apache2 to serve content may add files, or symlinks, to this directory.
  • envvars: file where Apache2 environment variables are set.
  • httpd.conf: historically the main Apache2 configuration file, named after the httpd daemon. The file can be used for user specific configuration options that globally effect Apache2.
  • mods-available: this directory contains configuration files to both load modules and configure them. Not all modules will have specific configuration files, however.
  • mods-enabled: holds symlinks to the files in /etc/apache2/mods-available. When a module configuration file is symlinked it will be enabled the next time apache2 is restarted.
  • ports.conf: houses the directives that determine which TCP ports Apache2 is listening on.
  • sites-available: this directory has configuration files for Apache2 Virtual Hosts. Virtual Hosts allow Apache2 to be configured for multiple sites that have separate configurations.
  • sites-enabled: like mods-enabled, sites-enabled contains symlinks to the /etc/apache2/sites-available directory. Similarly when a configuration file in sites-available is symlinked, the site configured by it will be active once Apache2 is restarted.
In addition, other configuration files may be added using the Include directive, and wildcards can be used to include many configuration files. Any directive may be placed in any of these configuration files. Changes to the main configuration files are only recognized by Apache2 when it is started or restarted.
The server also reads a file containing mime document types; the filename is set by the TypesConfig directive, and is /etc/mime.types by default.

Basic Settings

This section explains Apache2 server essential configuration parameters. Refer to the Apache2 Documentation for more details.
  • Apache2 ships with a virtual-host-friendly default configuration. That is, it is configured with a single default virtual host (using the VirtualHost directive) which can modified or used as-is if you have a single site, or used as a template for additional virtual hosts if you have multiple sites. If left alone, the default virtual host will serve as your default site, or the site users will see if the URL they enter does not match the ServerName directive of any of your custom sites. To modify the default virtual host, edit the file /etc/apache2/sites-available/default.
    [Note]
    The directives set for a virtual host only apply to that particular virtual host. If a directive is set server-wide and not defined within the virtual host settings, the default setting is used. For example, you can define a Webmaster email address and not define individual email addresses for each virtual host.
    If you wish to configure a new virtual host or site, copy that file into the same directory with a name you choose. For example:
    sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/mynewsite
    
    Edit the new file to configure the new site using some of the directives described below.
  • The ServerAdmin directive specifies the email address to be advertised for the server's administrator. The default value is webmaster@localhost. This should be changed to an email address that is delivered to you (if you are the server's administrator). If your website has a problem, Apache2 will display an error message containing this email address to report the problem to. Find this directive in your site's configuration file in /etc/apache2/sites-available.
  • The Listen directive specifies the port, and optionally the IP address, Apache2 should listen on. If the IP address is not specified, Apache2 will listen on all IP addresses assigned to the machine it runs on. The default value for the Listen directive is 80. Change this to 127.0.0.1:80 to cause Apache2 to listen only on your loopback interface so that it will not be available to the Internet, to (for example) 81 to change the port that it listens on, or leave it as is for normal operation. This directive can be found and changed in its own file, /etc/apache2/ports.conf
  • The ServerName directive is optional and specifies what FQDN your site should answer to. The default virtual host has no ServerName directive specified, so it will respond to all requests that do not match a ServerName directive in another virtual host. If you have just acquired the domain name ubunturocks.com and wish to host it on your Ubuntu server, the value of the ServerName directive in your virtual host configuration file should be ubunturocks.com. Add this directive to the new virtual host file you created earlier (/etc/apache2/sites-available/mynewsite).
    You may also want your site to respond to www.ubunturocks.com, since many users will assume the www prefix is appropriate. Use the ServerAlias directive for this. You may also use wildcards in the ServerAlias directive.
    For example, the following configuration will cause your site to respond to any domain request ending in .ubunturocks.com.
    ServerAlias *.ubunturocks.com
    
  • The DocumentRoot directive specifies where Apache2 should look for the files that make up the site. The default value is /var/www. No site is configured there, but if you uncomment the RedirectMatch directive in /etc/apache2/apache2.conf requests will be redirected to /var/www/apache2-default where the default Apache2 site awaits. Change this value in your site's virtual host file, and remember to create that directory if necessary!
The /etc/apache2/sites-available directory is not parsed by Apache2. Symbolic links in /etc/apache2/sites-enabled point to "available" sites.
Enable the new VirtualHost using the a2ensite utility and restart Apache2:
sudo a2ensite mynewsite
sudo /etc/init.d/apache2 restart
[Note]
Be sure to replace mynewsite with a more descriptive name for the VirtualHost. One method is to name the file after the ServerName directive of the VirtualHost.
Similarly, use the a2dissite utility to disable sites. This is can be useful when troubleshooting configuration problems with multiple VirtualHosts:
sudo a2dissite mynewsite
sudo /etc/init.d/apache2 restart

Default Settings

This section explains configuration of the Apache2 server default settings. For example, if you add a virtual host, the settings you configure for the virtual host take precedence for that virtual host. For a directive not defined within the virtual host settings, the default value is used.
  • The DirectoryIndex is the default page served by the server when a user requests an index of a directory by specifying a forward slash (/) at the end of the directory name.
    For example, when a user requests the page http://www.example.com/this_directory/, he or she will get either the DirectoryIndex page if it exists, a server-generated directory list if it does not and the Indexes option is specified, or a Permission Denied page if neither is true. The server will try to find one of the files listed in the DirectoryIndex directive and will return the first one it finds. If it does not find any of these files and if Options Indexes is set for that directory, the server will generate and return a list, in HTML format, of the subdirectories and files in the directory. The default value, found in /etc/apache2/mods-available/dir.conf is "index.html index.cgi index.pl index.php index.xhtml index.htm". Thus, if Apache2 finds a file in a requested directory matching any of these names, the first will be displayed.
  • The ErrorDocument directive allows you to specify a file for Apache2 to use for specific error events. For example, if a user requests a resource that does not exist, a 404 error will occur, and per Apache2's default configuration, the file /usr/share/apache2/error/HTTP_NOT_FOUND.html.var will be displayed. That file is not in the server's DocumentRoot, but there is an Alias directive in /etc/apache2/apache2.conf that redirects requests to the /error directory to /usr/share/apache2/error/.
    To see a list of the default ErrorDocument directives, use this command:
    grep ErrorDocument /etc/apache2/apache2.conf
    
  • By default, the server writes the transfer log to the file /var/log/apache2/access.log. You can change this on a per-site basis in your virtual host configuration files with the CustomLog directive, or omit it to accept the default, specified in /etc/apache2/apache2.conf. You may also specify the file to which errors are logged, via the ErrorLog directive, whose default is /var/log/apache2/error.log. These are kept separate from the transfer logs to aid in troubleshooting problems with your Apache2 server. You may also specify the LogLevel (the default value is "warn") and the LogFormat (see /etc/apache2/apache2.conf for the default value).
  • Some options are specified on a per-directory basis rather than per-server. Options is one of these directives. A Directory stanza is enclosed in XML-like tags, like so:
    
    ...
    
    
    The Options directive within a Directory stanza accepts one or more of the following values (among others), separated by spaces:
    • ExecCGI - Allow execution of CGI scripts. CGI scripts are not executed if this option is not chosen.
      [Tip]
      Most files should not be executed as CGI scripts. This would be very dangerous. CGI scripts should kept in a directory separate from and outside your DocumentRoot, and only this directory should have the ExecCGI option set. This is the default, and the default location for CGI scripts is /usr/lib/cgi-bin.

    • Includes - Allow server-side includes. Server-side includes allow an HTML file to include other files. This is not a common option. See the Apache2 SSI HOWTO for more information.
    • IncludesNOEXEC - Allow server-side includes, but disable the #exec and #include commands in CGI scripts.
    • Indexes - Display a formatted list of the directory's contents, if no DirectoryIndex (such as index.html) exists in the requested directory.
      [Caution]
      For security reasons, this should usually not be set, and certainly should not be set on your DocumentRoot directory. Enable this option carefully on a per-directory basis only if you are certain you want users to see the entire contents of the directory.

    • Multiview - Support content-negotiated multiviews; this option is disabled by default for security reasons. See the Apache2 documentation on this option.
    • SymLinksIfOwnerMatch - Only follow symbolic links if the target file or directory has the same owner as the link.

httpd Settings

This section explains some basic httpd daemon configuration settings.
LockFile - The LockFile directive sets the path to the lockfile used when the server is compiled with either USE_FCNTL_SERIALIZED_ACCEPT or USE_FLOCK_SERIALIZED_ACCEPT. It must be stored on the local disk. It should be left to the default value unless the logs directory is located on an NFS share. If this is the case, the default value should be changed to a location on the local disk and to a directory that is readable only by root.
PidFile - The PidFile directive sets the file in which the server records its process ID (pid). This file should only be readable by root. In most cases, it should be left to the default value.
User - The User directive sets the userid used by the server to answer requests. This setting determines the server's access. Any files inaccessible to this user will also be inaccessible to your website's visitors. The default value for User is www-data.
[Warning]
Unless you know exactly what you are doing, do not set the User directive to root. Using root as the User will create large security holes for your Web server.
The Group directive is similar to the User directive. Group sets the group under which the server will answer requests. The default group is also www-data.

Apache2 Modules

Apache2 is a modular server. This implies that only the most basic functionality is included in the core server. Extended features are available through modules which can be loaded into Apache2. By default, a base set of modules is included in the server at compile-time. If the server is compiled to use dynamically loaded modules, then modules can be compiled separately, and added at any time using the LoadModule directive. Otherwise, Apache2 must be recompiled to add or remove modules.
Ubuntu compiles Apache2 to allow the dynamic loading of modules. Configuration directives may be conditionally included on the presence of a particular module by enclosing them in an block.
You can install additional Apache2 modules and use them with your Web server. For example, run the following command from a terminal prompt to install the MySQL Authentication module:
sudo apt-get install libapache2-mod-auth-mysql
See the /etc/apache2/mods-available directory, for additional modules.
Use the a2enmod utility to enable a module:
sudo a2enmod auth_mysql
sudo /etc/init.d/apache2 restart
Similarly, a2dismod will disable a module:
sudo a2dismod auth_mysql
sudo /etc/init.d/apache2 restart

HTTPS Configuration

The mod_ssl module adds an important feature to the Apache2 server - the ability to encrypt communications. Thus, when your browser is communicating using SSL, the https:// prefix is used at the beginning of the Uniform Resource Locator (URL) in the browser navigation bar.
The mod_ssl module is available in apache2-common package. Execute the following command from a terminal prompt to enable the mod_ssl module:
sudo a2enmod ssl
There is a default HTTPS configuration file in /etc/apache2/sites-available/default-ssl. In order for Apache2 to provide HTTPS, a certificate and key file are also needed. The default HTTPS configuration will use a certificate and key generated by the ssl-cert package. They are good for testing, but the auto-generated certificate and key should be replaced by a certificate specific to the site or server. For information on generating a key and obtaining a certificate see the section called “Certificates”
To configure Apache2 for HTTPS, enter the following:
sudo a2ensite default-ssl
[Note]
The directories /etc/ssl/certs and /etc/ssl/private are the default locations. If you install the certificate and key in another directory make sure to change SSLCertificateFile and SSLCertificateKeyFile appropriately.
With Apache2 now configured for HTTPS, restart the service to enable the new settings:
sudo /etc/init.d/apache2 restart
[Note]
Depending on how you obtained your certificate you may need to enter a passphrase when Apache2 starts.
You can access the secure server pages by typing https://your_hostname/url/ in your browser address bar.

References

  • Apache2 Documentation contains in depth information on Apache2 configuration directives. Also, see the apache2-doc package for the official Apache2 docs.
  • See the Mod SSL Documentation site for more SSL related information.
  • O'Reilly's Apache Cookbook is a good resource for accomplishing specific Apache2 configurations.
  • For Ubuntu specific Apache2 questions, ask in the #ubuntu-server IRC channel on freenode.net.
  • Usually integrated with PHP and MySQL the Apache MySQL PHP Ubuntu Wiki page is a good resource.

How to Install And Configure Apache In Ubuntu

If you intend to set up a web server (or streaming server) in your Ubuntu machine, apache is one important module that you must install. In this tutorial, we will show you how to install and configure apache for your Ubuntu.Note: If you just want to have a quick setup of LAMP server, follow the guide here.

Installing Apache

Getting apache onto your Ubuntu machine is easy. Using either the Synaptic Package Manager, Ubuntu Software Center, search and install the “apache2” module. Alternatively, you can open a terminal and type the following command:
sudo apt-get install apache2
Once the installation finished, open a browser and go to the URL “http://localhost“. If you see the word “It Works!“, then your installation of apache is successful.
apache-install-success

Configuring Apache

Start, Stop and Restart Apache
After you have installed Apache, it will be added to the init.d list and will auto start whenever you boot up your computer. The following commands allow you to start, restart, stop Apache.
sudo /etc/init.d/apache2 start   #start apache
sudo /etc/init.d/apache2 stop   #stop apache
sudo /etc/init.d/apache2 restart   #restart apache
To prevent Apache from autostart when booting up:
sudo update-rc.d -f apache2 remove
To restore Apache back to the autostart list:
sudo update-rc.d apache2 defaults
Note: the above commands will work in debian-based distro (including Ubuntu) only.
Changing the default localhost folder
By default, apache will operate on the “/var/www” folder. This means that whatever files you place in this /var/www folder will be visible from the URL http://localhost. In some instances, you may want the “localhost” to point to another folder instead, say /home/user/public_html. Here is how you do it:
First, make sure the /home/damien/public_html folder exists. Create a simple html file, name it index.html and place it in the public_html folder.
Open a terminal and type:
gksu gedit /etc/apache2/sites-enabled/000-default
Change DocumentRoot /var/www to DocumentRoot /home/user/public_html.
Change to .
apache-edit-virtual-host
Save and exit the file.
Restart the apache
sudo /etc/init.d/apache2 restart
Now, in your browser, reload the URL http://localhost. You should see the html file that you have placed in the public_html folder.
apache-test-success
Configuring different sites
The above trick allows you to change the default operating folder of apache, however, some of you might not want to override the default settings. An alternative is to create multiple sites and point apache to the active site.
Create a new settings file for your new site.
sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/site1
Next, edit this settings file.
gksu gedit /etc/apache2/sites-available/site1
Change DocumentRoot /var/www to DocumentRoot /home/user/public_html.
Change to .
Save and exit the file.
Disable the default setting and make active the site1 settings
sudo a2dissite default && sudo a2ensite site1
Lastly, restart the apache.
sudo /etc/init.d/apache2 restart
With this trick, you can create multiple site configuration file, each pointing to a different folder. You can then easily switch between the sites with the a2dissite and a2ensite command
Enabling .htaccess file
.htaccess file is a powerful file that can be used to control and customize a site server behavior without editing the core Apache module. By default, the .htaccess functionality is turned off and all instances of .htaccess files are completely ignored. The server will not even attempt to read .htaccess files in the filesystem.
To enable .htaccess file, open up the settings file that you have created earlier:
gksu gedit /etc/apache2/sites-available/site1
Scroll down the file until you see the part ““. Underneath that line of code, change AllowOverride None to AllowOverride All.
apache-allowoverride
Save and exit the file.
Recommended read:
1. Install LAMP server in Ubuntu
2. How to install VLC-Shares in Ubuntu and stream audio/video to Android

How to change phpmyadmin username and password

dmubu
July 29th, 2011, 01:13 AM
Hello,

I have recently installed phpmyadmin and have logged in successfully. However, my default username is 'root'. I want to change that username to something else.

I ran the following command:
mysql -u foo -p
I received this error:
Access denied for user 'foo'@'localhost' (using password: YES)
Is there a certain configuration file I have to edit? If so, which one?

Thank you so much!
Habitual
July 29th, 2011, 06:02 PM
have you give 'foo' a db permission to connect to a db?

also, in case the actual was sanitized, try this:
mysql -h localhost -u root -p
enter the root password and let us know.

Have you modified the my.cnf in any way?
Is the mysql server process/service started?
dmubu
July 29th, 2011, 09:07 PM
Thanks for the reply..

My issue has changed slightly. I removed the LAMP stack and re-installed.

Apache and PHP work fine, but I have two main problems:

1) MySQL server is not working properly. When I enter (with password):

sudo mysql -u root -p

I receive:

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)


2) I cannot install phpMyAdmin properly. After running sudo apt-get install phpmyadmin, I receive.



The phpmyadmin package must have a database installed and configured
│ before it can be used. This can be optionally handled with
│ dbconfig-common.

│ If you are an advanced database administrator and know that you want to
│ perform this configuration manually, or if your database has already
│ been installed and configured, you should refuse this option. Details
│ on what needs to be done should most likely be provided in
│ /usr/share/doc/phpmyadmin.

│ Otherwise, you should probably choose this option.



I clicked 'OK' and selected the option to configure with apache. However, it seems that, since MySQL server is not configured properly, phpmyadmin will not install.


Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
phpmyadmin
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 0 B/4,321 kB of archives.
After this operation, 17.8 MB of additional disk space will be used.
Preconfiguring packages ...
Selecting previously deselected package phpmyadmin.
(Reading database ... 166419 files and directories currently installed.)
Unpacking phpmyadmin (from .../phpmyadmin_4%3a3.3.10-1_all.deb) ...
Processing triggers for hicolor-icon-theme ...
Processing triggers for doc-base ...
Processing 1 added doc-base file(s)...
Registering documents with scrollkeeper...
Processing triggers for man-db ...
Setting up phpmyadmin (4:3.3.10-1) ...
dbconfig-common: writing config to /etc/dbconfig-common/phpmyadmin.conf

Creating config file /etc/dbconfig-common/phpmyadmin.conf with new version

Creating config file /etc/phpmyadmin/config-db.php with new version
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES).
unable to connect to mysql server.
error encountered creating user:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
dbconfig-common: phpmyadmin configure: ignoring errors from here forwards
populating database via sql... done.
dbconfig-common: flushing administrative password





Thus, I can access neither MySQL server nor phpMyAdmin. What can I do?

Thank you.
Habitual
July 29th, 2011, 09:23 PM
You don't know or remember your mysql root password?

I suggested
mysql -h localhost -u root -p
and you typed something else. :(

pidof mysqld says what exactly? If nothing then
sudo service mysql start and try
mysql -h localhost -u root -p again.


Re-configure mysql-server:
sudo dpkg-reconfigure mysql-server
or
sudo dpkg-reconfigure mysql-server-5.1

whichever one is installed.


Once you reconfigure (and recover) your root mysql password, then
Reconfigure phpmyadmin
sudo dpkg-reconfigure phpmyadmin
dmubu
July 29th, 2011, 09:43 PM
Thanks for the quick reply. I apologize for not following earlier instructions.

This is what I have done.


sudo dpkg-reconfigure mysql-server-5.1
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql stop

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) utility, e.g. stop mysql
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service mysql start

Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the start(8) utility, e.g. start mysql
mysql start/running, process 7598


Next, I tried:

sudo dpkg-reconfigure phpmyadmin


I followed the prompts to:
1) reinstall the database
2) uses unix socket connection method
3) entered 'root' for name of database's administrative user
4) entered password for database's administrative user
5) entered name of database
6) chose to reconfigure with apache2

I then received:

An error occurred while installing the database:

│ ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using
│ password: YES)

│ If at this point you choose "retry", you will be prompted with all the
│ configuration questions once more and another attempt will be made at
│ performing the operation. "retry (skip questions)" will immediately
│ attempt the operation again, skipping all questions. If you choose
│ "abort", the operation will fail and you will need to downgrade,
│ reinstall, reconfigure this package, or otherwise manually intervene to
│ continue using it. If you choose "ignore", the operation will continue,



What should I do?
dmubu
July 30th, 2011, 05:40 PM
I was able to access MySQL server using the help of this link:

http://www.cyberciti.biz/tips/recover-mysql-root-password.html

Setting Up a LAMP Server In Ubuntu Hardy Heron

LAMP stands for Linux, Apache, MySQL and PHP. It is the most widely used combination for setting up a Web Server. By far, the easiest way to install LAMP server is simply installing the Ubuntu Server Edition itself. However, many of us have installed the Ubuntu Desktop edition, only to find that we need to set up a LAMP server later on. In the following tutorial, I am going to show you how to install and configure a LAMP server in your Ubuntu Hardy Heron in less than 10 minutes.

Installing Apache, Php and MySql

In your Ubuntu desktop, go to System->Administration->Synaptic Package Manager.
Scroll down the list to search for apache2. Check the box beside it and select ‘Mark for installation‘. This will also install other dependency packages. When prompted, click ‘Mark‘.
Apache in Synaptic Package Manager
Next, scroll down the list and search for php5. Similarly, place a check beside the box and select ‘Mark for installation‘.
PHP5 in Synpatic Package Manager
Do the same for ‘mysql-server‘ and ‘phpmyadmin
MySQL in Synpatic Package Manager
phpmyadmin in Synpatic Package Manager
Once you are done, click ‘Apply‘ on the top icon bar.
The Synaptic Package Manager will now fetch all the files and install it in your Ubuntu.
When installing MySQL, you will be prompted to enter and reconfirm your password. Make sure that you enter a password that you can remember.
Setting mysql password
Also, the phpmyadmin will ask you which version of apache to use. Select apache2
Configuring Phpmyadmin
Testing your installation
Once you have finished installing the LAMP, you will need to test if it is working.
Open your browser and point the URL to http://localhost
If you see the words ‘It works’, then apache is working fine.
Testing Apache
Next, you want to create a php file to test your php setting.
gksu gedit /var/www/testphp.php
paste the following line to the file
Save and close the file.
In your browser, point the URL to http://localhost/testphp.php. You should see all the php information on the browser. If it prompt you to download the file, then your php configuration is not successful. Go to Synaptic Package Manager and reinstall php5
Testing PHp
Testing of phpmyadmin
On your browser, go to http://localhost/phpmyadmin. It should loads up the phpmyadmin login page. Log in with the user name root and the password you supplied when installing.
phpmyadmin login page
This will bring you to the main screen of phpmyadmin.
Putting it all together
To test if the apache, php5, MySQL and phpmyadmin are working together, we can test it out by installing WordPress.
Download WordPress here.
Extract the wordpress folder to your home folder.
Inside the folder, open up the wp-config-sample.php file. Edit the following information.
define(‘DB_NAME’, ‘wordpress’);    // The name of the database
define(‘DB_USER’, ‘root’);     // Your MySQL username
define(‘DB_PASSWORD’, ‘yourpasswordhere’); // …and password
Remember to change the ‘yourpasswordhere‘ to the password that you supplied during the MySQL installation.
Save the file as wp-config.php.
Next in your phpmyadmin, create a new database call wordpress.
phpmyadmin-new-db
Open a terminal, copy the wordpress folder to the apache working directory (the working directory is located at /var/www)
sudo cp -R wordpress /var/www/
Once done, on your browser, go to http://localhost/wordpress. The famous 5 minutes installation will show on screen. Follow the instructions. If is your LAMP configuration is good, your wordpress will be up in 1 minute.
That’s it. Enjoy!
[Reference: Lijamex's Blog, Howto Forge]