clone a new project from a repository on Server
$ git clone //server_path
Show the information on repository in local
$ git remote show origin
Show the branch information
$ git branch
Show list of the configuration
$ git config -l
Switch to a branch
$ git checkout <branch_name>
Push to another branch on Server
$ git push origin local_branch:server_branch
Update latest commit
$ git pull
Edit latest comment
$ git commit --amend -m "New commit message"
Show all version
$ git log
Show current version
$ git show
Delete latest commit
$ git reset --soft 'HEAD^'
Revert latest commit
$ git reset --hard HEAD
Fix error "The following untracked working tree files would be overwritten by merge"
Use -n or --dry-run to preview the damage you'll do.
$ git clean -n
$ git clear -n <file_path>
To create a "feature branch" from the dev branch
$ git checkout -b myfeature dev
Delete a branch
$ git branch -d myfeature
Wednesday, May 7, 2014
Wednesday, January 1, 2014
How to: Ruby on Rails + Ubuntu + Apache with Passenger
Now you can use gem to install Rails:
Install Phusion Passenger (an Apache module that lets you run Rails apps easily):
The passenger-install-apache2-module script will guide you through what you need to do to get Passenger working. It should tell you to copy these lines into your /etc/apache2/apache2.conf:
Create a file in /etc/apache2/sites-available/ for your site (something like 'irorio.local.jp') and insert this:
sudo gem install rails
Install Phusion Passenger (an Apache module that lets you run Rails apps easily):
sudo gem install passenger sudo passenger-install-apache2-module
The passenger-install-apache2-module script will guide you through what you need to do to get Passenger working. It should tell you to copy these lines into your /etc/apache2/apache2.conf:
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.2/ext/apache2/mod_passenger.so PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.2 PassengerRuby /usr/bin/ruby1.8
Create a file in /etc/apache2/sites-available/ for your site (something like 'irorio.local.jp') and insert this:
<VirtualHost *:80> alias /iapps /home/taind/svn/branch/irorio/irorio-api/public ServerName irorio.local.jp DocumentRoot /home/taind/svn/branch/irorio/irorio DirectoryIndex index.php SetEnv APPLICATION_ENV development <Directory /home/taind/svn/branch/irorio/irori> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory> <Location /iapps> PassengerBaseURI /iapps PassengerAppRoot /home/taind/svn/branch/irorio/irorio-api </Location> <Directory /home/taind/svn/branch/irorio/irorio-api/public> Options -MultiViews Allow from all </Directory> RailsEnv development #RailsBaseURI /iapps </VirtualHost>
Sunday, November 3, 2013
How To Create a SSL Certificate on nginx for Ubuntu 12.04
Step One—Create a Directory for the Certificate
The SSL certificate has 2 parts main parts: the certificate itself and the public key. To make all of the relevant files easy to access, we should create a directory to store them in:
We will perform the next few steps within the directory:
Step Two—Create the Server Key and Certificate Signing Request
Start by creating the private server key. During this process, you will be asked to enter a specific passphrase. Be sure to note this phrase carefully, if you forget it or lose it, you will not be able to access the certificate.
Follow up by creating a certificate signing request:
This command will prompt terminal to display a lists of fields that need to be filled in.
The most important line is "Common Name". Enter your official domain name here or, if you don't have one yet, your site's IP address. Leave the challenge password and optional company name blank.
Step Three—Remove the Passphrase
We are almost finished creating the certificate. However, it would serve us to remove the passphrase. Although having the passphrase in place does provide heightened security, the issue starts when one tries to reload nginx. In the event that nginx crashes or needs to reboot, you will always have to re-enter your passphrase to get your entire web server back online.
Use this command to remove the password:
Step Four— Sign your SSL Certificate
Your certificate is all but done, and you just have to sign it.
Keep in mind that you can specify how long the certificate should remain valid by changing the 365 to the number of days you prefer. As it stands this certificate will expire after one year.
You are now done making your certificate.
Step Five—Set Up the Certificate
Now we have all of the required components of the finished certificate.The next thing to do is to set up the virtual hosts to display the new certificate.
Let's create new file with the same default text and layout as the standard virtual host file. You can replace "example" in the command with whatever name you prefer:
Scroll down to the bottom of the file and find the section that begins with this:
Refs https://www.digitalocean.com/community/articles/how-to-create-a-ssl-certificate-on-nginx-for-ubuntu-12-04
The SSL certificate has 2 parts main parts: the certificate itself and the public key. To make all of the relevant files easy to access, we should create a directory to store them in:
sudo mkdir /etc/nginx/ssl
We will perform the next few steps within the directory:
cd /etc/nginx/ssl
Step Two—Create the Server Key and Certificate Signing Request
Start by creating the private server key. During this process, you will be asked to enter a specific passphrase. Be sure to note this phrase carefully, if you forget it or lose it, you will not be able to access the certificate.
sudo openssl genrsa -des3 -out server.key 1024
Follow up by creating a certificate signing request:
sudo openssl req -new -key server.key -out server.csr
This command will prompt terminal to display a lists of fields that need to be filled in.
The most important line is "Common Name". Enter your official domain name here or, if you don't have one yet, your site's IP address. Leave the challenge password and optional company name blank.
You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. ----- Country Name (2 letter code) [AU]:US State or Province Name (full name) [Some-State]:New York Locality Name (eg, city) []:NYC Organization Name (eg, company) [Internet Widgits Pty Ltd]:Awesome Inc Organizational Unit Name (eg, section) []:Dept of Merriment Common Name (e.g. server FQDN or YOUR name) []:example.com Email Address []:webmaster@awesomeinc.com
Step Three—Remove the Passphrase
We are almost finished creating the certificate. However, it would serve us to remove the passphrase. Although having the passphrase in place does provide heightened security, the issue starts when one tries to reload nginx. In the event that nginx crashes or needs to reboot, you will always have to re-enter your passphrase to get your entire web server back online.
Use this command to remove the password:
sudo cp server.key server.key.org
sudo openssl rsa -in server.key.org -out server.key
Step Four— Sign your SSL Certificate
Your certificate is all but done, and you just have to sign it.
Keep in mind that you can specify how long the certificate should remain valid by changing the 365 to the number of days you prefer. As it stands this certificate will expire after one year.
sudo openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
You are now done making your certificate.
Step Five—Set Up the Certificate
Now we have all of the required components of the finished certificate.The next thing to do is to set up the virtual hosts to display the new certificate.
Let's create new file with the same default text and layout as the standard virtual host file. You can replace "example" in the command with whatever name you prefer:
sudo nano /etc/nginx/sites-available/example
Scroll down to the bottom of the file and find the section that begins with this:
# HTTPS server
server {
listen 443;
server_name example.com;
root /usr/share/nginx/www;
index index.html index.htm;
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
}
sudo service nginx restart
Refs https://www.digitalocean.com/community/articles/how-to-create-a-ssl-certificate-on-nginx-for-ubuntu-12-04
Monday, October 7, 2013
Install RabbitVCS on Ubuntu 12.10
First install some prerequisites.
Download the tarball, untar it and run the setup script
Still inside the rabbitvcs-0.15.2 directory, cd to the nautilus-3.0 under the clients directory and copy the RabbitVCS.py to the extensions dir
Logout and log back in. Now create a folder and right click on it to see the RabbitVCS menu, perform a checkout.
Refs: http://linuxdrops.com/install-rabbitvcs-svn-git-client-on-ubuntu-12-1012-0411-1011-04/
$ sudo apt-get update $ sudo apt-get install python-nautilus python-configobj python-gtk2 python-glade2 python-svn python-dbus python-dulwich subversion meld gconf-editor
Download the tarball, untar it and run the setup script
$ wget http://rabbitvcs.googlecode.com/files/rabbitvcs-0.15.2.tar.bz2 $ tar jxvf rabbitvcs-0.15.2.tar.bz2 $ cd rabbitvcs-0.15.2/ $ sudo python setup.py install --install-layout=deb
Still inside the rabbitvcs-0.15.2 directory, cd to the nautilus-3.0 under the clients directory and copy the RabbitVCS.py to the extensions dir
$ cd clients/nautilus-3.0 $ sudo cp RabbitVCS.py /usr/share/nautilus-python/extensions/
Logout and log back in. Now create a folder and right click on it to see the RabbitVCS menu, perform a checkout.
Refs: http://linuxdrops.com/install-rabbitvcs-svn-git-client-on-ubuntu-12-1012-0411-1011-04/
Thursday, September 26, 2013
Frequently used commands in Rails vs Slim
render :text => 'test'
# set layout
layout 'layout'
# print odd and even in table
tr class=cycle('list_line_odd', 'list_line_even')
# ruby inside javascript block [slim template]
javascript:
var config = {
custom: "#{my_value ? 'truthy' : 'falsy'}",
current_user: #{raw current_user.to_json}
};
Monday, September 23, 2013
Solving “502 Bad Gateway” with nginx & php-fpm
After upgrading php-fpm, my PHP-based sites were returning “502 Bad Gateway” errors. Here’s how I managed to solve it.
Check to make sure that php-fpm is running with
The thing to notice here is that the order in which you install the packages is important. In the past I have found that installing them in the wrong order causes the packages to be configured incorrectly.
Next, get php-fpm to listen on the correct host/port. In /etc/php5/fpm/pool.d/www.conf change the following line from:
To:
Restart php-fpm with
Ref: http://wildlyinaccurate.com/solving-502-bad-gateway-with-nginx-php-fpm
Check to make sure that php-fpm is running with
ps auxww | grep php– if you can’t see any php-fpm processes in the output, then you may need to re-install php-fpm. If php-fpm is running okay, then skip this first step.
sudo apt-get remove php5 php5-cgi php5-fpm sudo apt-get install php5 php5-cgi php5-fpm
The thing to notice here is that the order in which you install the packages is important. In the past I have found that installing them in the wrong order causes the packages to be configured incorrectly.
Next, get php-fpm to listen on the correct host/port. In /etc/php5/fpm/pool.d/www.conf change the following line from:
listen = /var/run/php5-fpm.sock
To:
listen = 127.0.0.1:9000
Restart php-fpm with
sudo /etc/init.d/php5-fpm restartand everything should work normally again.
server {
listen 80;
server_name your_domain.com;
root /your_document_root;
index index.php;
access_log /your_document_root/logs/access_log;
error_log /your_document_root/logs/error_log;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php last;
break;
}
}
location ~ \.php$ {
include fastcgi_params;
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
# fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_param SCRIPT_FILENAME /your_document_root$fastcgi_script_name;
fastcgi_index index.php;
}
}
Ref: http://wildlyinaccurate.com/solving-502-bad-gateway-with-nginx-php-fpm
Install RabbitVCS Svn, Git Client On Ubuntu 12.10/12.04/11.10/11.04
Overview
There are some cool interfaces for subversion control for windows however when it comes to desktop linux distros, you find very few that can match their windows counterpart like TortoiseSVN. RabbitVCS is one such client that comes with all the bells and whistles. Here is a post about installing it.
There are some cool interfaces for subversion control for windows however when it comes to desktop linux distros, you find very few that can match their windows counterpart like TortoiseSVN. RabbitVCS is one such client that comes with all the bells and whistles. Here is a post about installing it.
First install some prerequisites.
Download the tarball, untar it and run the setup script
Still inside the rabbitvcs-0.15.2 directory, cd to the nautilus-3.0 under the clients directory and copy the RabbitVCS.py to the extensions dir
$ cd clients/nautilus-3.0
Logout and log back in. Now create a folder and right click on it to see the RabbitVCS menu, perform a checkout.
Refs: http://linuxdrops.com/install-rabbitvcs-svn-git-client-on-ubuntu-12-1012-0411-1011-04/
Fix Error: Bomb icon
The bomb emblem means that there is some sort of error in the status checker. It is possible that error messages will show up in ~/.config/rabbitvcs/RabbitVCS.log but I'm not sure it will for your problem. I'm not sure what would cause your status checker to be getting errors but it could be that your svn or git dependencies are not correctly installed, or installed in a way that doesn't work with RabbitVCS. Are the bomb emblems showing up in git repositories or svn repositories or both?
One thing that might help is restarting the status checker. You can do this by killing the checkerservice.py process. Run "ps aux | grep rabbitvcs" and kill the process that says checkerservice.py. Once you do that, restart nautilus and see what happens.
$ sudo apt-get update $ sudo apt-get install python-nautilus python-configobj python-gtk2 python-glade2 python-svn python-dbus python-dulwich subversion meld gconf-editor
Download the tarball, untar it and run the setup script
$ wget http://rabbitvcs.googlecode.com/files/rabbitvcs-0.15.2.tar.bz2 $ tar jxvf rabbitvcs-0.15.2.tar.bz2 $ cd rabbitvcs-0.15.2/ $ sudo python setup.py install --install-layout=deb
Still inside the rabbitvcs-0.15.2 directory, cd to the nautilus-3.0 under the clients directory and copy the RabbitVCS.py to the extensions dir
$ cd clients/nautilus-3.0
$ sudo cp RabbitVCS.py /usr/share/nautilus-python/extensions/
Refs: http://linuxdrops.com/install-rabbitvcs-svn-git-client-on-ubuntu-12-1012-0411-1011-04/
Fix Error: Bomb icon
The bomb emblem means that there is some sort of error in the status checker. It is possible that error messages will show up in ~/.config/rabbitvcs/RabbitVCS.log but I'm not sure it will for your problem. I'm not sure what would cause your status checker to be getting errors but it could be that your svn or git dependencies are not correctly installed, or installed in a way that doesn't work with RabbitVCS. Are the bomb emblems showing up in git repositories or svn repositories or both?
One thing that might help is restarting the status checker. You can do this by killing the checkerservice.py process. Run "ps aux | grep rabbitvcs" and kill the process that says checkerservice.py. Once you do that, restart nautilus and see what happens.
Subscribe to:
Posts
(
Atom
)