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/

IMPORT AND EXPORT DATABASE IN POSTGRES

Create postgres database using command line:- createdb -h localhost -p 5432 -U postgres dbname Import database psql -h localhost -U username -d dbname -f /filepath/filename.sql Import AWS RDS dump file in local database: Example :  pg_restore -v -h [endpoint of instance] -U [master username] -d [new database name] [database].dump pg_restore -v -h localhost -U postgres -d Blogger blogger.dump Export database pg_dump -U postgres databasename > filename.sql Export or Take a AWS RDS dump file: Example :   pg_dump -Fc -v -h [endpoint of instance] -U [master username] [database] > [database].dump pg_dump -Fc -v -h example-database.ctctk95487r5.us-east-1.rds.amazonaws.com -U rohit Blogger > blogger.dump password:  rohit Or pg_restore -U username -d dbname -1 filename.dump Or pg_restore -h localhost -U root -W -F t -d dbname db_dump_file.tar  Or pg_restore -h localhost -p 5432 -U postgres -d databasename -v "pro.dump" See also, https

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 Gemfile gem "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