Logo
  • PHP
    • HipHop / HHVM
    • Modern PHP
    • PHPStorm
    • LAMP
    • Laravel
    • Composer
    • PDO
  • JavaScript
    • node.js
    • AngularJS
  • CSS
    • SASS
    • “CSS4” (CSS level 4)
  • HTML
  • Git
  • LAMP
  • Vagrant
  • UI / UX
  • Architecture of …
  • Off-Topic
With ♥ from Berlin
August 25, 2013
Chris
Linux, Login, PHP, php-login project
Comments Off on How to install php-login-minimal on Ubuntu 12.04 LTS

How to install php-login-minimal on Ubuntu 12.04 LTS

PreviousNext
the-php-login-project

In this article I’ll show you how to install the minimal version of the php-login.net‘s login script (see the GitHub repo here) on a standard Ubuntu server – in a very short and a very detailed way.

 

THE VERY SHORT TUTORIAL:

If you prefer a short tutorial, do it like this: First, make sure you have PHP 5.3.7+ and MySQL 5 running! Then copy the content of the php-login-minimal folder to your server’s web root (or whereever you want to have it) and perform the SQL statements from within both files in the “_installation” folder on your MySQL database (usually via PHPMyAdmin or on the mysql command line). Open the config/db.php file and change the database user and the password where it says “DB_USER” and “DB_PASS“. Your app is now running.

 

THE VERY DETAILED TUTORIAL:

THE BASIC REQUIREMENTS:

  1. A server, in this tutorial we’ll use Ubuntu 12.04 LTS as the operation system.
  2. Apache installed on the server.
  3. PHP 5.3.7 or higher installed on the server (this includes PHP 5.4+ and PHP 5.5+). PHP introduced some hashing algorithms (that are used in this script) in version 5.3.7, so you definitely need this. This tutorial will show you how to check your PHP version and how to upgrade PHP.
  4. MySQL 5 or higher installed on the server. This tutorial will show you how to check and eventually install MySQL if it’s not done already.
  5. You should be able to access your server via SSH.
  6. You should know the basics of how a server works, how to login via SSH, how to use the linux command line and how to copy files to your server.

 

THE FURTHER REQUIREMENTS:
Find out which version of PHP your server runs

Create a file called phpinfo.php on your local computer and put the following stuff in there:

<?php
phpinfo();

The function phpinfo(); shows the entire configuration and settings of PHP, so it’s perfect for inspecting and finding out what your installed version of PHP can do and what not. I think it’s a good idea to create such an phpinfo.php on every new server you set up.

Copy the file to your server’s web root folder, usually /var/www/ ! For easily accessing a server via SSH in Windows 7/8 I can recommend WinSCP and Putty. WinSCP let’s you log in via your SSH credentials (username and password OR via SSH key file) and look at your server like in a FTP tool while Putty is a simple, but effective command-line tool. WinSCP will automatically open Putty (already connected to your server) when you log in.

When you have moved the phpinfo.php file to your web root, open your browser and go to

http://www.yourdomain.com/phpinfo.php

You’ll see something like this:

check for correct php version, must be PHP 5.3.7 or higher

Is your PHP version 5.3.7 or higher ? Fine, then let’s go on ! If not, then you are using a very old version of PHP that should be updated instantly.

By the way, you can also find out your installed PHP version by doing this on the linux command line (but we did it the above way to check if your server displays php files correctly ;)

php -v

 

THE FURTHER REQUIREMENTS:
Update the PHP version (if older than 5.3.7)

Updating PHP is a big topic, so let’s do it the quick way. To update PHP, log into your server and do this on the command line (or “shell” or “bash”, whatever you call it):

sudo apt-get update

to let your system (beside some other stuff) check for updateable software, then do this to upgrade PHP:

sudo apt-get --only-upgrade install php5

After this is done, restart the Apache server with:

sudo service apache2 restart

Now check the installed version of PHP with a simple:

php -v

Is it 5.3.7 or higher now ? Perfect ! If not, then you should contact your server provider, hoster etc. and ask for an update or simply get a modern server somewhere else. It’s 2014, ladies, and the 5.3 branch of PHP has officially reached the End of Life, which means no more updates for this branch. Seriously, there is really no good reason to use a 3+ years dead version of PHP.

 

THE FURTHER REQUIREMENTS:
Install MySQL server (if not installed)

This version of the login script needs a MySQL database, so let’s check if MySQL 5.1 or higher is installed. Have a look into your phpinfo.php output screen and search for the mysqli [the last character is an “i” !] block. It should look like this (the version number is not important right now, usually it will be 5.1, 5.5 or 5.6):

check if mysqli is installed

Everything there ? Wonderful! If not, then we have to install MySQL right now: Do

sudo apt-get upgrade

and

sudo apt-get install mysql-server php5-mysql

to install the MySQL server. You’ll be asked for a new password: Choose wisely, choose strong ! By the way: There seem to be problems with VERY long passwords and passwords that use exotic characters, so you should not overcomplicate things.

To activate everything, restart the Apache server:

sudo service apache2 restart

To prove everything is installed correctly, reload your phpinfo.php screen and have a look. You should find a mysqli info block that looks like the picture above !

 

THE FURTHER REQUIREMENTS:
Install PHPMyAdmin (for easy database handling)

Handling databases is a complex and error-prone thing, so why not using the standard PHP/MySQL-database administration tool ? PHPMyAdmin is my weapon of choice, so let’s install it via these commands (the “update” is only necessary when ubuntu doesn’t find an installable version of phpmyadmin, this happens sometimes on fresh servers):

sudo apt-get upgrade
sudo apt-get install phpmyadmin

You’ll be asked for the MySQL password you have provided in the last step. In a professional application it’s not good to log into phpmyadmin with THIS user/password, and in general it’s a bad idea to have phpmyadmin running on a live server (as it makes attackers’s life much easier), but for this installation tutorial it might be totally okay. You can log into PHPMyAdmin then on:

http://www.mydomain.com/phpmyadmin

Log in with “root” and the password you have given.

 

THE INSTALLATION PROCESS:
Change the database password

Edit your config/db.php and put in your database user (in your case probably “root”) and the password.

 

THE INSTALLATION PROCESS:
Copy the script to your server

This step is easy: Delete the phpinfo.php from your server (as it is not necessary anymore and will give potential attackers informations about your server) and copy the contents of the php-login-minimal folder to your web root, usually /var/www/. This folder should now look like (screenshot from WinSCP):

how your root folder should look like after copying the php-login script to your server

 

THE INSTALLATION PROCESS:
Creating the database

Log into PHPMyAdmin:

http://www.yourdomain.com/phpmyadmin

and create a database called “login” with the SQL statement in “_installation/01-create-database.sql“, then do the same with the file “_installation/02-create-and-fill-users-table.sql” to create the user-table. It’s also possible to import the files. The PHPMyAdmin user interface is quite self-explaining, so this should not be a problem.

The script is now ready to go under your web address:

http://www.yourdomain.com/

 

SOME WORDS ABOUT LOCAL & REMOTE DEVELOPMENT

It’s always a good decision to develop LOCALLY, which means directly on your own computer, or even better, within a virtual machine hosted on your system. Usually, developing on a live server on the web might be critial, because your tools might have no or weak passwords, your app is in development and therefore attackable, or simply because you just mistyped a bash command and your server now tries to download the entire web.

When developing locally, you could install PHP, MySQL etc by hand or use a pre-combined and pre-configured easy-to-handle development bundle, like Ampps [Win, Mac], EasyPHP [Win], WampServer [Win], SecureWAMP [Win] or even Xampp [Win, Mac, Linux].

—

Please note: Comments are closed!: Sorry, but I had to remove / deactivate the comments in this and other articles as lots of idiots and trolls commented with masterpieces a la “script is shit does not work plz help”, “does not work on android”, “you must change X to Y”, “explain to me” etc. without realizing what this script is, why there’s a readme and several tutorials and lots of commented code and what free-time open-source scripts in general are. It’s disturbing that people build their entire businesses on top of totally free software, written by unpaid volunteers in their free-time, and then they still complain and treat the autors like shit.

minimalpassword hashingPHPtutorial
Share this
Ghost

[FREE SERVER PROMO] Install GHOST for free on a free SSD server with this coupon

A little off-topic, but highly interesting: In April 2013 the former User Interface Head of WordPress (and WordPress expert) John

php

[Link] How to create, read, update and delete (CRUD) with PDO, MySQLi and MySQL the right way (prepared statements)

Mike Dalisay has written an excellent tutorial on the CORRECT USAGE of basic CRUD functions (create, read, update, delete) with

github-logo-octocat

GitHub rolls out .PSD diff and viewing

Good news for frontend designers / developers working with Photoshop a lot: GitHub has just rolled out native .psd support:

mod-rewrite-ubuntu-14-04-lts

EOL lists of Ubuntu, Debian and CentOS for your server plannings

Chosing the right server operating system will probably save your life and avoid a lot of stress with your clients.

Going node.js at Netflix (Slides by Micah R of Netflix)

It’s awesome how node.js takes over the absolute AAA-level corporate world. Note that node.js is still an early alpha product

php uk conference

Profiling PHP Applications by Bastian Hofmann (video from PHP UK Conference 2014)

The title says it all: Profiling PHP applications.  

php

Must-read PHP blog: PHPweekly.com

Probably one of the best ressources for your weekly doze of news from the PHP scene: phpweekly.com simply publishes a

vagrant

A super-simple Vagrant LAMP stack bootstrap (installable with one command)

As I have to setup servers inside Vagrant quite often, sometimes 10 times per day, I started to use provisioning:

pdo-debug

Debug PDO with this one-line function. Yeah!

Update: This article is a little bit older, the tool has changed gently. Everthing this article still works exactly like

Increase your HTML / CSS coding speed with EMMET

Codeninja.com just published a very interesting article about the excellent free code-completion/code-generation tool EMMET, which allows you to create huge

1/4

Categories

Search

ilovepreloaders – A tumblr collection of preloader animations
A quick history of Comic Sans, the most wrongly used font ever
css3-chrome-font
[Link] Retinafy your Site / Device by Nijiko Yonskai
The New Era of JavaScript (28min conference talk, Jack Franklin, 2013)
vagrant
A super-simple Vagrant LAMP stack bootstrap (installable with one command)
Soundcloud’s “VP of Engineering” about using SSDs
Disappointed by Watch Dogs’s graphics ? See how it looks with unlocked, hidden settings. Awesome!
hearthbleed-ssl-bug
The SSL Heartbleed bug explained in 30 seconds
php
Must-read PHP blog: PHPweekly.com
composer
[Link] How to require versions of PHP, HHVM / HipHop, GD, curl, openssl etc. with Composer
angular js
Learn AngularJS in 20 (or 90) minutes with Dan Wahlin
mod-rewrite-ubuntu-14-04-lts
How to enable mod_rewrite in Ubuntu 14.04 LTS
Frontend Ops Conf 2014 – Rebooting Flickr On A Node.js Stack, One Page At A Time (from PHP) by Bertrand Fan
Berlin, prepare for TOA conference (15th – 17th of July)
Creators of Laravel launch one-click-installations of Laravel (including nginx, PHP 5.5 etc.)

Tags

apache bash centos composer conference coupon CSS debian fonts framework git GitHub hack HHVM HipHop HTML HTML5 IDE JavaScript JS LAMP laravel linux mod_rewrite MVC MySQL Nginx optimization PHP PHP 5.5 PHP 5.6 phpmyadmin PHPStorm security server SSD Ubuntu UI UX vagrant video virtual machine voucher VPS wordpress
Side-Project: Wordle-Solver:
www.wordle-helper.info

Pages

  • Privacy Policy