GithubHelp home page GithubHelp logo

falldi / urlshortener Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 104 KB

Simple url shortener on PHP and MySQL or PostgreSQL. Without any additional libraries.

ApacheConf 0.89% Nginx 5.40% CSS 6.46% PHP 81.33% JavaScript 5.93%

urlshortener's Introduction

Workflow

  1. Site-visitor (V) enters any original URL to the Input field, like http://anydomain/any/path/etc;
  2. V clicks submit button;
  3. Page makes AJAX-request;
  4. Short URL appears in Span element, like http://yourdomain/abCdE (don't use any external APIs as goo.gl etc.);
  5. V can copy short URL and repeat process with another link

Requirements

  • Pure Nginx or Apache with mod_rewrite
  • PHP 5.4+
  • MySQL 5.6+ or PostgreSQL 9.2+
  • Redis if you want use cache
  • PHP extensions:
    • pdo_mysql or pdo_pgsql
    • Redis extension if you want use cache
    • To make sure that you have installed all add-ons, run the following command
$ php -m | grep -e pdo -e redis
pdo_mysql
pdo_pgsql
pdo_sqlite
redis

Deployment

Web-server configuration

You should configure one web-server Nginx or Apache

Nginx

  1. Run php-fpm on 9000 port
  2. Insert into you nginx.conf server section from configuration/nginx.conf
  3. Change listen to you port
  4. Change root to you directory as root of project

Apache

  1. Create new Virtual host(separate domain or another port)
  2. Set root directory as root of project
  3. Change AllowOverride directive of you apache httpd.conf to All(needs for .htaccess file)

Database configuration

You should configure one database MySQL or PostgreSQL

  1. Specify host/user/password/database in config.ini file at database section
  2. Specify db as mysql or pgsql in config.ini file at database section
  3. Create relation under specified database from configuration/database.sql

Internal implementation notes

  1. If you want use cache - enable it in config.ini file and specify hostport of Redis. Cache store shortUrl <-> longUrl as Redis strings
  2. Error handling must be implemented using logger into file, but not it show error message into output for development purpose
  3. Url validator

License

The content of this project itself is licensed under the Creative Commons Attribution 3.0 license license, and the underlying source code used to format and display that content is licensed under the MIT license.

urlshortener's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.