Posts

Showing posts from February, 2017

KILL 80 PORT ON SERVER

How to kill 80 port on server:-Run :-

lsof -wni TCP:80

Then kill ps :-

       kill -9 ...

Or
       sudo kill `sudo lsof -t -i:80`



When getting error :-

bind() to 0.0.0.0:80 failed (98: Address already in use)
Run that command on server for killing the port 80:    sudo fuser -k 80/tcp https://easyengine.io/tutorials/nginx/troubleshooting/emerg-bind-failed-98-address-already-in-use/
When getting 404 error on server :-
        location / {            root /var/deploy/pdm_expert/pdm/public;         }
https://www.keycdn.com/support/404-not-found-nginx/

POSTGRES IMPORT AND EXPORT DATABASE

Create postgres database using command line:-createdb -h localhost -p 5432 -U postgres databasename Import databasepsql -h localhost -U username -d databasename -f /filepath/filename.sql Or for dump file extension:-pg_restore -U username -d dbname -1 filename.dumpor pg_restore -h localhost -U root -W -F t -d databasename database_dump_file.tar orpg_restore -h localhost -p 5432 -U postgres -d databasename -v "pro.dump" https://stackoverflow.com/questions/2732474/restore-a-postgres-backup-file-using-the-command-line Export databasepg_dump -U postgres databasename > filename.sql When we are getting error likeWhen we get error at the time of import the postgres database :- : FATAL:  Peer authentication failed for user "postgres"then:-
The problem is still your pg_hba.conf file (/etc/postgresql/9.1/main/pg_hba.conf). This line:local   all             postgres                                peer

Should be

local   all             postgres                               …

CHECK PASSENGER RUBY PATH

When we want to use the passenger with Nginx or Apache. Then we need to find the passenger ruby path. So, we can easily find the ruby path using :-passenger-config --ruby-command When we run then we will get like :-
Command: /home/rohit/.rvm/gems/ruby-2.1.10/wrappers/ruby
  Version: ruby 2.1.10p492 (2016-04-01 revision 54464) [x86_64-linux]
  To use in Apache: PassengerRuby /home/rohit/.rvm/gems/ruby-2.1.10/wrappers/ruby
  To use in Nginx : passenger_ruby /home/rohit/.rvm/gems/ruby-2.1.10/wrappers/ruby
  To use with Standalone: /home/rohit/.rvm/gems/ruby-2.1.10/wrappers/ruby /usr/bin/passenger start
Add that line in passenger.conf file

POSTGRES DATABASE YML FILE

When we create new app or we want to use pg database then sometimes we forgot the postgres database.yml file setting Gemfilegem "pg"

Database.yml

default: &default
  host: localhost
  adapter: postgresql
  encoding: unicode
  pool: 5

development:
  <<: *default
  username: postgres
  password: postgres
  database: rohit_development


test: &test
  <<: *default
  username: postgres
  password: postgres
  database: rohit_test

LOGIN USING PEM FILE ON AWS SERVER

Login using the PEM file on AWS server :-ssh -i /home/Desktop/pemfile.pem username@ipaddress Copy a file from a remote server to a local machine?scp -i /home/test.pem username@remote:/var/deploy/test.rb /home/Desktop Copy a file from a local machine to a remote server?scp -i /home/test.pem /home/Desktop/test.rb username@remote:/var/deploy

SOLVE PORT 22: CONNECTION REFUSED SSH LOGIN

When we login using ssh command from local. If we get some error like :-ssh root@131.14.150.283

ssh: connect to host 136.144.156.213 port 22: Connection refused

For solving that problem. Please go to the server droplet console on browser and run those commands :-


root@131-14-150-283:~$   sudo apt-get install openssh-server

Then run

root@131-14-150-283:~$   ps -ef | grep sshd

root@131-14-150-283:~$   sudo ufw allow 22

WE CAN FOLLOW THE LINK BELOW :-

https://www.digitalocean.com/community/questions/ufw-restart-required-after-droplet-reboot-to-allow-ssh

https://www.digitalocean.com/community/tutorials/how-to-use-the-digitalocean-console-to-access-your-droplet