Setting Up a LAMP Server on Ubuntu 14.04

Published on Author craigzearfossLeave a comment
  1. Update server.
    sudo apt-get update
    sudo apt-get upgrade
  2. Install git.
    sudo apt-get install git
  3. Install MySQL.
    sudo su
    apt-get install mysql-server mysql-client
  4. Install Apache2.
    apt-get install apache2
  5. Install PHP (To search for PHP packages: apt-cache search php5).
    apt-get install php5
    apt-get install libapache2-mod-php5
    apt-get install php5-mysql
    apt-get install php5-curl
    apt-get install php5-gd
    apt-get install php5-intl
    apt-get install php-pear
    apt-get install php5-imagick
    apt-get install php5-imap
    apt-get install php5-mcrypt
    apt-get install php5-memcache
    apt-get install php5-ming
    apt-get install php5-ps
    apt-get install php5-pspell
    apt-get install php5-recode
    apt-get install php5-sqlite
    apt-get install php5-tidy
    apt-get install php5-xmlrpc
    apt-get install php5-xsl
    /etc/init.d/apache2 restart
  6. Install phpMyAdmin.
    apt-get install phpmyadmin
    cd /etc/apache2/conf-enabled
    ln -s /etc/phpmyadmin/apache.conf phpmyadmin.conf
    sudo service apache2 restart
  7. Install Composer.
    cd /tmp
    curl -s | php
    sudo mv composer.phar /usr/local/bin/
    alias composer='/usr/local/bin/composer.phar'
  8. Create a user for ssh
    sudo adduser 
    sudo adduser  admin
    sudo visudo -f /etc/sudoers

    In the user privileges section add the following line:

    <username> ALL=(ALL) NOPASSWD:ALL
    su <username>
    cd /home/<username>
    mkdir .ssh
    chmod 700 .ssh
    cd .ssh
    ssh-keygen -b 1024 -f id_<username> -t dsa
    cat ~/.ssh/id_<username>*.pub > ~/.ssh/authorized_keys
    chmod 600 ~/.ssh/*
    cp ~/.ssh/* /tmp
    chmod 644 /tmp/*
    sudo nano /etc/ssh/sshd_config

    Add the new account to the AllowUsers field (or create the line if it’s not there):

    AllowUsers ubuntu <username>

    Restart ssh.

    sudo service ssh restart
  9. Download the new key from your computer using your ubuntu account.

    scp -i ~/.ssh/<key_name>.pem ubuntu@<public_ip>:/tmp/* ~/.ssh
    cd ~/.ssh
    chmod 400 id_<username>

    Test: ssh -i .ssh/id_ @

  10. Remove the key files from the server’s tmp directory:

    rm -rf /tmp/*
  11. Turn off SSH Access for Default root (ubuntu) Account. (Only do this if step 7 was successful.)
    sudo nano /etc/ssh/sshd_config

    Remove the ubuntu account from the AllowUsers field:

    AllowUsers <username>

    Make sure PermitRootLogin is off:

    PermitRootLogin no
    sudo service ssh restart



Leave a Reply

Your email address will not be published. Required fields are marked *