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 23, 2013
Chris
Linux, Login, PHP, php-login project
52

How to install php-login-one-file on Ubuntu 12.04 LTS

PreviousNext
the-php-login-project

This tutorial will show you how to install the one-file version of php-login.net‘s login script (see the full GitHub repository 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: Copy the content of the php-login-one-file folder to your server’s web root (or whereever you want to have it) and run _install.php (in the _installation folder), which will create a database file in the project’s root folder. Make sure you have PHP 5.3.7+ with SQLite extension and PDO installed (see long tutorial).

 

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. You should be able to access your server via SSH.
  5. 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

This script does not use MySQL, but a simple SQLite database file (which is in this case just a file), so we need to make sure that the installed version of PHP is able to handle SQLite:

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 2013, 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 4 year old version of PHP.

 

THE FURTHER REQUIREMENTS:
Install SQLite extension (if not installed)

This version of the login script does not use a MySQL database, it simply creates a little file in a subfolder of your web project. One file for each database table by the way. This kind of database is called SQLite, and PHP needs a special SQLite extension to work with this stuff. To check if the SQLite extension is installed, search for this box on your phpinfo.php output screen:

check for installed PDO SQLite extension in PHP

Does it say sqlite in the right column ? If not, install the PHP SQLite extension with

sudo apt-get install php5-sqlite

(if you have problems, check How to enable SQLite3 for PHP on StackOverflow)

and restart the Apache server (to load the new extension) like this

sudo service apache2 restart

To prove everything is installed correctly, reload your phpinfo.php screen and have a look. It should look like this:

PHP PDO SQLite extension successfully installed

 

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-one-file folder to your web root, usually /var/www/.

 

THE INSTALLATION PROCESS:
Making the “database” folder writeable

By default the www folder on your web root path /var/www/ might not be writeable by PHP. Folder/file rights on linux are a huge and complex topic, so we only do it the quick way here, so let’s go to /var/ on the command line by doing

cd /var

and changing the right of the “database” folder with

sudo chown -R www-data:www-data www

By the way, if this does not work, try setting full acess to the folder. Note that 777 is insecure as it gives too much rights on the folder, but for development purposes it’s okay.

sudo chmod 777 www

 

THE INSTALLATION PROCESS:
First run, creating the database

Open your browser and start the installation function inside the script by calling

http://www.yourdomain.com/_installation/_install.php

which will create the user database file within the root folder. The script is now ready to go under your web address:

http://www.yourdomain.com/

Make sure to delete the _install.php file now ! To always have a look into your one-file database simply call _debug.php. Also make sure to delete this file when you are running a real app!

 

IMPORTANT SECURITY NOTICE:

In the default setup the database – which is only a simple users.db file – can be downloaded directly. To prevent this, change the path of your database file! A path that is not accessable by public is perfect. The .htaccess in the project does not work in every setup.

 

SOME FINAL THOUGHTS

Your app is now running. To be honest, this tutorial was a little bit overcomplicated. When you are reading this post you probably want to create a very simple tool, based on a one-file login system, so you probably have rent a simple and pre-configured server that already has a modern version of PHP and the PDO / SQLite extension installed. Usually copying the script files to the server and calling the install script is everything you have to do.

 

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. This can kill you if you pay for every gigabyte of traffic. Believe me ;)

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]. A lot of people seems to use Xampp, but I wouldn’t recommend this, as it’s by far the worst of all those.

 

This article was written quite a while ago (9 years), please keep this in mind when using the information written here. Links, code and commands might be outdated or broken.

Random articles

  • How to setup a (or multiple) server/LAMP-stack inside a virtual machine for local development with Vagrant and PuPHPetHow to setup a (or multiple) server/LAMP-stack inside a virtual machine for local development with Vagrant and PuPHPet
  • EOL lists of Ubuntu, Debian and CentOS for your server planningsEOL lists of Ubuntu, Debian and CentOS for your server plannings
  • How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 14.04 LTSHow to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 14.04 LTS
  • [Link] Set up Nginx with PHP 5.5 easily[Link] Set up Nginx with PHP 5.5 easily
  • [Link] How to set up HipHop, Nginx and Laravel in Ubuntu 12.04 LTS (in a Vagrant box)[Link] How to set up HipHop, Nginx and Laravel in Ubuntu 12.04 LTS (in a Vagrant box)
  • Generate Vagrant boxes with Laravel, HipHop, Nginx, WordPress, MySQL, MariaDB, MongoDB, RabbitMQ etc. with one clickGenerate Vagrant boxes with Laravel, HipHop, Nginx, WordPress, MySQL, MariaDB, MongoDB, RabbitMQ etc. with one click
  • Install Laravel 4 on Ubuntu 12.04 LTS (a how-to tutorial)Install Laravel 4 on Ubuntu 12.04 LTS (a how-to tutorial)
  • How to install latest PHP 5.4.x on Ubuntu 12.04 LTS (Precise Pangolin)How to install latest PHP 5.4.x on Ubuntu 12.04 LTS (Precise Pangolin)
  • How to setup a local server (in a virtual machine) with Vagrant in PHPStormHow to setup a local server (in a virtual machine) with Vagrant in PHPStorm
linuxloginPHPtutorialUbuntu
Share this

52 Comments

  • Internal
    July 3, 2022 11:16 am

    Supervisor

    Reply
  • Cambridgeshire
    July 3, 2022 5:24 am

    override

    Reply
  • methodologies
    July 2, 2022 8:37 pm

    Liaison

    Reply
  • Sleek
    July 2, 2022 8:06 am

    withdrawal

    Reply
  • Tools
    July 2, 2022 7:34 am

    Directives

    Reply
  • Refined
    June 28, 2022 12:20 pm

    circuit

    Reply
  • Accounts
    June 25, 2022 12:47 pm

    compressing

    Reply
  • payment
    June 24, 2022 9:38 pm

    back

    Reply
  • Keyboard
    June 24, 2022 12:21 pm

    Borders

    Reply
  • Customizable
    June 23, 2022 9:06 pm

    cross-platform

    Reply
  • encryption
    June 23, 2022 7:25 am

    SMTP

    Reply
  • hybrid
    June 23, 2022 3:46 am

    Christmas

    Reply
  • digital
    June 21, 2022 3:19 am

    Jewelery

    Reply
  • Wisconsin
    June 21, 2022 1:43 am

    Lari

    Reply
  • data-warehouse
    June 19, 2022 10:11 pm

    XSS

    Reply
  • Kenya
    June 19, 2022 8:10 pm

    Rhode

    Reply
  • hack
    June 19, 2022 10:02 am

    parse

    Reply
  • and
    June 18, 2022 6:25 am

    Dakota

    Reply
  • Integrated
    June 18, 2022 12:18 am

    Bacon

    Reply
  • attitude-oriented
    June 16, 2022 5:17 pm

    calculating

    Reply
  • ivory
    June 16, 2022 9:20 am

    Accounts

    Reply
  • Buckinghamshire
    June 14, 2022 7:18 pm

    Internal

    Reply
  • Serbian
    June 14, 2022 2:42 pm

    override

    Reply
  • ivory
    June 14, 2022 12:18 am

    Peru

    Reply
  • tan
    June 12, 2022 8:49 pm

    matrix

    Reply
  • International
    June 12, 2022 5:56 pm

    Kansas

    Reply
  • Regional
    June 11, 2022 10:34 pm

    Handmade

    Reply
  • clicks-and-mortar
    June 11, 2022 2:08 pm

    network

    Reply
  • override
    June 11, 2022 10:03 am

    EXE

    Reply
  • communities
    June 11, 2022 9:18 am

    Intelligent

    Reply
  • generate
    June 10, 2022 8:06 pm

    Account

    Reply
  • calculating
    June 9, 2022 10:08 pm

    generating

    Reply
  • Ville
    June 9, 2022 11:35 am

    AI

    Reply
  • Granite
    June 9, 2022 5:51 am

    Applications

    Reply
  • Implementation
    June 8, 2022 6:30 pm

    optical

    Reply
  • Health
    June 6, 2022 12:30 am

    Refined

    Reply
  • Nauru
    June 4, 2022 9:03 pm

    optical

    Reply
  • Home
    June 3, 2022 11:02 pm

    protocol

    Reply
  • Garden
    June 3, 2022 9:30 pm

    Card

    Reply
  • analyzer
    June 1, 2022 7:57 am

    Belarussian

    Reply
  • Toys
    May 31, 2022 11:02 pm

    See

    Reply
  • New
    May 31, 2022 8:58 pm

    tan

    Reply
  • leverage
    May 31, 2022 1:46 am

    Djibouti

    Reply
  • brand
    May 29, 2022 9:24 pm

    Herzegovina

    Reply
  • back
    May 28, 2022 9:17 pm

    Switchable

    Reply
  • Rand Namibia Dollar
    January 17, 2022 12:13 am

    index

    Reply
  • digital
    December 15, 2021 4:44 pm

    red

    Reply
  • Liaison
    November 16, 2021 7:19 pm

    Fish

    Reply
  • cultavix
    November 13, 2015 9:44 am

    Can I disable registrations? I’d like to add my own users manually. Thanks :)

    Reply
  • ChromeDude
    August 24, 2015 11:36 pm

    Hi, thanks so much for this script. Installation was quick, easy, and worked perfectly first time without any hassle (unlike so many things these days). I’m using this script for a sort of semi-CMS, and I’m just wondering how I’d go about integrating this with my existing dashboard.php file, other than echoing every single line of it? Would I be able to use an include function and how would I secure that?

    Reply
  • Nick
    August 12, 2014 5:47 pm

    Does this version or any of the other versions of this script allow logging of the IP address of the user?

    Reply
  • Thomas
    December 19, 2013 1:18 am

    How would I most easily and securely modify the checkPasswordCorrectnessAndLogin function (in the 0-one-file template) to temporarily disable login attempts after 2 or 3 incorrect attempts?

    Reply

Leave A Comment Cancel reply

php

“Belt” adds very clever everyday functions to PHP, comes with JavaScript naming styles and eventually solves the needle/haystack problem

This little projects is basically super-simple, but somehow really really clever and definitly a time-saver: Belt is a typical Composer-loaded

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

Compare 250+ cloud server plans with Cloud Cost Calculator

How cool is that ? The Cloud Cost Calculator compares more than 250 cloud server plans of Amazon, Rackspace, DigitalOcean,

composer

A short & simple Composer tutorial

In this little Composer tutorial we’ll walk through the absolute basics of Composer, the PHP dependency management tool. Composer has

php

PHP 5.6.0 RC1 is available

The first Release Candidate of PHP 5.6 is available here on php.net, as usual also for Windows systems. The RC

shadow dom

Crossbrowser-safe HTML5 video (IE6+) with a few lines of code and just one .mp4 video file

No time to read the full article ? Get the code directly here on GitHub: panique/html5-video. Publishing a video on

Interesting stats on SONY’s hacked passwords

In 2011 SONY’s Playstation network got hacked, 77 million accounts have been compromised, and more than 1.000.000 passwords – saved

All new features of WordPress 3.9 in this 2 minute video

This article was written quite a while ago (8 years), please keep this in mind when using the information written

photoshop-cc-deal

Adobe offers Photoshop for $9.99 per month (limited deal)

Currently Adobe offers the very latest version of Photoshop (which is Photoshop CC) for just $9.99 or 12,99€ (EU zone:

vagrant

Generate Vagrant boxes with Laravel, HipHop, Nginx, WordPress, MySQL, MariaDB, MongoDB, RabbitMQ etc. with one click

Excellent new web tool: Protobox allows extremely easy setup of Vagrant boxes using a wonderful web UI. Beside the standard

1/4

Categories

Search

gamescom 2014 trailers
GAMESCOM 2014: Awesome Next-Gen ingame graphics
shadow dom
A quick video introduction into Shadow-DOM, the game-changing DOM-subtree-technology
The architecture of StackOverflow
phpstorm-8
When PHPStorm’s cache eats up your harddisk space
Hacked french TV channel exposed passwords in TV interview (video, screenshots, links)
php
PHP.net hacked, but most things are fine again
php
How to install PHP curl extension (in 5 seconds)
php
[Link] How to create, read, update and delete (CRUD) with PDO, MySQLi and MySQL the right way (prepared statements)
java
Interesting: code of the same application in PHP, Python, Ruby, Closure, node.js, Java and Go
php
12 tools for better PHP quality
Meet the developers behind Ableton (14min video)
phpstorm 7.0 php
How to setup and use XDEBUG with PHPStorm 6/7 (locally in Windows 7/8 and Mac OS X)
hack-php
Wow! Facebook devs have rewritten and fixed PHP, releasing it as new language called “Hack” today
Increase your HTML / CSS coding speed with EMMET
php
PHP 5.6 announced, statically typed (!) “new” PHP announced by Facebook devs

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
 
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept All”, you consent to the use of ALL the cookies. However, you may visit "Cookie Settings" to provide a controlled consent.
Cookie SettingsAccept All
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT