Skip to main content

LAMP on Ubuntu


LAMP Configuration on Ubuntu


A LAMP (Linux, Apache, MySQL, PHP) stack is a common web stack used for hosting web content.

This guide shows you how to install a LAMP stack on an Ubuntu 14.04 (LTS) server.

Before you begin update your system  -

# sudo apt-get update && sudo apt-get upgrade

 

Apache

Install and Configure


sudo apt-get install apache2

Configure Virtual Hosts

There are several different ways to set up virtual hosts; however, below is the recommended method. By default, Apache listens on all IP addresses available to it.
  1. Within the /etc/apache2/sites-available/ directory, create a configuration file for your website, example.com.conf, replacing example.com with your own domain information:
     
    vim /etc/apache2/sites-available/example.com.conf
     
     
     
     
    
    
    
    
    
    
    
    
    
    
    <VirtualHost *:80> 
     
         ServerAdmin webmaster@example.com
         ServerName example.com
         ServerAlias www.example.com
         DocumentRoot /var/www/html/example.com/public_html/
         ErrorLog /var/www/html/example.com/logs/error.log 
         CustomLog /var/www/html/example.com/logs/access.log combined 
     
        <Directory /var/www/html/>
            Require all granted
         </Directory>
     
    </VirtualHost>
    
    The ErrorLog and CustomLog entries are suggested for more fine-grained logging, but are not required. If they are defined (as shown above), the logs directories must be created before you restart Apache.
  2. Create the above-referenced directories:

     

    sudo mkdir -p /var/www/html/example.com/public_html 

    sudo mkdir /var/www/html/example.com/logs

  3. Link your virtual host file from the sites-available directory to the sites-enabled directory:


































    sudo a2ensite example.com.conf


    If you later need to disable your website, run:





     sudo a2dissite example.com.conf


  4. Reload Apache:

    
    

    sudo service apache2 reload


    Assuming that you have configured the DNS for your domain to point to your Linode’s IP address, virtual hosting for your domain should now work.
    If there are additional websites you wish to add to your Linode repeat the above steps to add them.

MySQL

Install and Configure

  1. Install the mysql-server package:
     
    
    
    
    
    
    

    sudo apt-get install mysql-server

    Choose a secure password when prompted.
  2. Run mysql_secure_installation, a program that helps secure MySQL. You will be presented with the opportunity to change the MySQL root password, remove anonymous user accounts, disable root logins outside of localhost, and remove test databases:
    
    
    
    

     

    mysql_secure_installation

Create a MySQL Database

  1. Log into MySQL:

    mysql -uroot -p 



    Enter MySQL’s root password, and you’ll be presented with a MySQL prompt.

  2.  Create a database and a user with permissions for it. In this example the databse is called webdata, the user webuser and password password:
     
     
     
     
     
     
     
    
    

    create database webdata; 

    grant all on webdata.* to 'webuser' identified by 'password';

  3. Exit MySQL:

    quit

PHP

  1. Install PHP, and the PHP Extension and Application Repository:
    
    
    
    
    
    
    
    

    sudo apt-get install php5 php-pear php5-mysql

    
    

  2. Once PHP5 is installed, tune the configuration file located in /etc/php5/apache2/php.ini to enable more descriptive errors, logging, and better performance. The following modifications provide a good starting point:
    /etc/php5/apache2/php.ini
     
    error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
     
    error_log = /var/log/php/error.log
     
    max_input_time = 30
     


    Ensure the lines above are uncommented. Commented lines begin with a semicolon (;).
  3. Create the log directory for PHP and give the Apache user ownership:

    sudo mkdir /var/log/php
     

    sudo chown www-data /var/log/php









  4. Reload Apache:

         sudo service apache2 reload







Congratulations! You have now set up and configured a LAMP stack. Now you can put your php script in /var/www/html/ folder and run http://example.com/

Comments

Popular posts from this blog

how to take mails backup in outlook 2007

How to take backup of mails in outlook 2007. there is a very simple way to taking backup of mails 1.Opne outlook 2007 > tools >account > data files >open folder then close all other windows and copy outlook.pst file in a safe location To restore backup 1.Opne outlook 2007 > tools >account > data files > add > and give the location of outlook.pst file.

How To Block Removable drive in linux

For Block Removable disk like pen drive you have to run only one following command - Open terminal -      #sudo chmod 700 /media For unblock -     # sudo chmod 755 /media   

Configure Vsftpd with virtual users in Ubuntu 14.04

vsftpd is a GPL licensed FTP server for UNIX systems, including Linux. It is secure and extremely fast. It is stable. Don't take my word for it, though. Below, we will see evidence supporting all three assertions. We will also see a list of a few important sites which are happily using vsftpd. This demonstrates vsftpd is a mature and trusted solution. To configure vsftpd server  with virtual users we need to enable PAM for vsftpd. apt-get install vsftpd libpam-pwdfile Now configure vsftpd to use PAM authentication vim  /etc/vsftpd.conf then paste in the following listen=YES anonymous_enable=NO local_enable=YES write_enable=YES local_umask=022 local_root=/var/www chroot_local_user=YES allow_writeable_chroot=YES hide_ids=YES #virutal user settings user_config_dir=/etc/vsftpd_user_conf guest_enable=YES virtual_use_local_privs=YES pam_service_name=vsftpd nopriv_user=vsftpd guest_username=vsftpd Now create users - You can either use a data...