Month: March 2017

Youtube-dl Error

While downloading youtube video through youtube-dl command I was getting an error shown below.

amisha@amisha:~/you$ youtube-dl https://www.youtube.com/watch?v=Q-GOFPM01d0
Setting language
WARNING: unable to set language: <urlopen error [Errno 8] _ssl.c:510: EOF occurred in violation of protocol>
Q-GOFPM01d0: Downloading webpage
ERROR: Unable to download webpage: <urlopen error [Errno 8] _ssl.c:510: EOF occurred in violation of protocol>

Then I removed youtube-dl and installed it again.

sudo apt-get remove youtube-dl
sudo wget https://yt-dl.org/downloads/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+rx /usr/local/bin/youtube-dl

And after that it works fine. Hope this may help you.

 

 

Git Commands

mkdir invention
cd invention
git init
touch newton.txt
touch a.txt
git add newton.txt
git add a.txt
git rm -f a.txt
git commit -m “first commit”
git remote add red https://github.com/amisha2016/invention
git remote
git remote -v
git status
git stash
git status
git stash list
git stash apply
git push -u red master
git log
git stash
git revert HEAD~1
ls
git log
git reset –hard HEAD~1
ls
git log
git pull
git checkout -b v1
git checkout -b v2
git checkout v2
git branch (tell all branches in repo)
git branch -m master(rename current branch to master)
git branch -D v2
git merge v1
git diff

git clone https://github.com/amisha2016/fresh

Nominatim on local server

In my previous blog I have installed Nominatim in my home folder and changed the directory of local server from /var/www/html to /home/amisha.

To do the same you can refer my blog -> reference

That was creating lot of problem to me as I was not able to run any php file in /var/www/html directory. So, first of all I restore the local server to the default directory.

But I was not able to run the Nominatim located in the /var/www/html directory.

eee.png

After reading the settings.php file I came to know that

@define(‘CONST_Website_BaseURL’, ‘http://&#8217;.php_uname(‘n’).’/’);

to

@define(‘CONST_Website_BaseURL’, ‘http://&#8217;.php_uname(‘n’).’/Nominatim/build/website/’);

Here, http://&#8217;.php_uname(‘n’) means username -> http://amisha/ or localhost

It was searching to the localhost/search.php but the actual path was localhost/Nominatim/build/website/search.php

ccc

Finally, the problem is solved.

 

 

 

Nominatim-> Search OSM with name

Nominatim-> Search OSM with name

Hie guys. Today, I am going to nomenclature my OSM map.:p

Implementation

You can clone the repo from https://github.com/openstreetmap/Nominatim

The detailed information of installation and set up of nominatim is given in ‘docs‘ directory.

Here, I will discuss the summary and struggles you may face while doing it.

$sudo apt-get install osmosis  /* For running continuous updates */

$sudo apt-get install php5-pgsql

After installing the software dependencies when I tried to import the data I encountered with the following error.

amisha@amisha:~/git/Nominatim$ ./build/utils/setup.php –osm-file ~/Downloads/ludh.pbf –all

PHP Warning:  require_once(DB.php): failed to open stream: No such file or directory in /home/amisha/git/Nominatim/lib/db.php on line 3
PHP Fatal error:  require_once(): Failed opening required ‘DB.php’ (include_path=’.:/usr/share/php:/usr/share/pear/share/php’) in /home/amisha/git/Nominatim/lib/db.php on line 3

It means ‘db.php’ requires file ‘DB.php’ for it’s execution. On goggled I came to know that ‘DB.php’ file comes with the installation of PEAR::DB. It means I have not installed it initially.

PEAR::DB Installation

$wget http://pear.php.net/go-pear.phar

$php go-pear.phar

$pear install DB

On executing the same command with the user <amisha> an error of permission denied came. Then I realized correct system user is postgres. It’s through not only.

amisha@amisha:~/git/Nominatim$ sudo -u amisha ./build/utils/setup.php –osm-file ~/Downloads/ludh.pbf –all
Create DB
createdb: database creation failed: ERROR:  permission denied to create database
ERROR: Error executing external command: createdb -E UTF-8 -p 5432 nominatim
Error executing external command: createdb -E UTF-8 -p 5432 nominatim

$ sudo -u postgres ./build/utils/setup.php –osm-file ~/Downloads/ludh.pbf  –all

Create DB
Setup DB
Postgres version found: 9.3
CREATE EXTENSION
ERROR:  could not access file “$libdir/postgis-2.2”: No such file or directory
ERROR: pgsql returned with error code (3)
pgsql returned with error code (3)

Again error in the same command but of different type. The above error explains itself only. So, what you are waiting for. Install postgis-2.2.

$ sudo apt-get install postgresql-9.3-postgis-2.2

While installing it I got an error of broken packages which I solved it with the help of my previous blog.

You can verify that whether database nominatim created or not.

postgres-# \l
List of databases
Name    |  Owner   | Encoding | Collate | Ctype |   Access privileges
———–+———-+———-+———+——-+———————–
gis       | amisha   | UTF8     | en_IN   | en_IN |
nominatim | postgres | UTF8     | en_IN   | en_IN |
postgres  | postgres | UTF8     | en_IN   | en_IN |
template0 | postgres | UTF8     | en_IN   | en_IN | =c/postgres          +
|          |          |         |       | postgres=CTc/postgres
template1 | postgres | UTF8     | en_IN   | en_IN | =c/postgres          +
|          |          |         |       | postgres=CTc/postgres
(5 rows)

After the installation and importing the database, I browse to the search.php file on the local server. But, unfortunately I got the Internal Server Error.

Internal Server Error

SQL Error: DB Error: connect failed

Details: [nativecode=pg_connect(): Unable to connect to PostgreSQL server: FATAL:  role “www-data” does not exist] ** pgsql://@/nominatim

This error came because the owner of nominatim database was postgres and in settings.php permissions was given to the <www-data> user. So, I changed the ownership of database to <www-data> also. You can do vice versa.

postgres=# create role “www-data”;
CREATE ROLE
postgres=# ALTER ROLE “www-data” WITH login;
ALTER ROLE

After re-loading the page the category of the error was same but with different type. This time it was not able to find the tables shown below.

in.png

It means that the defination of the tables and functions were missing. Command to create functions. I think errors loves me a lot that is why coming again and again.:P

$ ./build/utils/setup.php –create-functions

Functions
ERROR:  type geometry does not exist
ERROR: pgsql returned with error code (3)
pgsql returned with error code (3)

It means that the type geometry was missing which come with the extension postgis.

nominatim=# create extension postgis;
CREATE EXTENSION

$ ./utils/setup.php –create-functions
Functions
CREATE FUNCTION
CREATE FUNCTION
ERROR:  permission denied for language c
ERROR: pgsql returned with error code (3)
pgsql returned with error code (3)

The above command runs with the owner of the database <postgres>.

$sudo -u postgres ./utils/setup.php –create-functions

$ sudo -u postgres ./utils/setup.php –create-tables

ERROR:  type “wikipedia_article_match” does not exist
ERROR: pgsql returned with error code (3)
pgsql returned with error code (3)

I have ignored this error as it demands for the optional data to be import.

$ ./utils/specialphrases.php –wiki-import > specialphrases.sql

$sudo -u postgres ./utils/setup.php –osm-file ~/Downloads/ludhiana.pbf –all –osm2pgsql-cache 2300 | tee setup.log

The above command will cache the imported data.

Then browse to the file search.php and you will be able to see the Nominatim main page through local server.

nom.png

The tiles are coming from the osm.org website and the it is using the local database. You can check it over the settings.php file. Now, my next task is to server the local tiles in the nominatim. I don’t know whether it is possible or not. Will update you soon.

I hope you will like it.

 

 

 

 

 

Recover purged PYTHON

Actually, I was experimenting something for which I purge PYTHON. Seriously, I don’t know what happened to me why I have purged it. I was not able to see dashboard, launcher. A blank Desktop. But we learn something new from our mistakes. So, I encourged myself to recover it rather reinstalling new Ubuntu.

I tried a number of links to fix it. But none worked for me. After a long day continuing, I ran one command.

$sudo apt-get install -f

Here flag ‘f’ means that it will fix the broken packages. After that reinstall the python and the problem is solved. Now I am able to see my original Ubuntu-Desktop.

While installing any new package(here->postgresql-9.3-postgis-2.2) I was getting the error some dependencies are broken.

The following packages have unmet dependencies:
postgresql-9.3-postgis-2.2 : Depends: libgdal20 (>= 2.0.1) but it is not going to be installed
Depends: libgeos-c1v5 (>= 3.5.0) but it is not going to be installed
Depends: liblwgeom-2.2-5 (>= 2.2.0) but it is not going to be installed
Depends: libsfcgal1 (>= 1.2.0) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

$ sudo apt-get install libgeos-c1v5

But when I cross-checked I got to know that the package ” libgeos-c1v5″ was not installed. So, after installing all the problems were solved.

Moving the localhost root to your working directory

Behind the curtain, your web server uses http to display files located on a machine. In our example, Apache is showing a file called index.html located in a subdirectory of our Apache installation. It would be better if we could work in whatever directory we please. (The file’s actually called index.html.en because of language switching, but let’s stick to index.html for now.)

Let’s create a directory and point our web server to the directory:

  • Create a directory called htdocs in your home directory, namely at /home/username/htdocs, where username stands for your user account’s real user name.
  • Open your Apache configuration file, located at /etc/apache2/sites-available/000-default.conf. Provide administrator credentials as needed. (If you aren’t using a recent version of Ubuntu or another Debian-based distro, try looking under /etc/apache2/httpd.conf or /etc/httpd/conf/httpd.conf.)
  • Within the file, find the following line: DocumentRoot /var/www/html. Change this line so that it points to your own htdocs directory: DocumentRoot /home/username/htdocs
  • At this point you should add some file access restrictions. Add the following lines under the DocumentRoot line, substituting your name for USERNAME:
<Directory />
                Options FollowSymLinks
                AllowOverride None
                Require all denied
        </Directory>
        <Directory /home/USERNAME/htdocs/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Require all granted
        </Directory>
  • Save the file.
  • Restart Apache with this terminal command: sudo apachectl restart. Provide your administrative password when prompted.
  • Reload localhost in your browser. If all went according to plan, you’ll see the directory’s index (as pictured below). By default the index is a list of all the files in the directory, but we’ll show you next how to customize the index page.
Download OpenProj

Download OpenProj

OpenProj is an open source project management software application.

We need to install java to successfully install Openproj.

To install java follow the link below.

Java installation

Then install Openproj as shown on  this video.

After this, you have to do some changes with java i.e

Open $HOME/.openproj/run.conf and Change

JAVA_OPTS="-Xms128m -Xmx768m"

TO

JAVA_OPTS="-Djava.vendor=Sun -Xms128m -Xmx768m"

You are done with it.