Getting Eclipse’s EGit to work with my own git server

I’ve been thinking about setting up my own git server for a while, and finally got it up and running last week. Since I do a lot of hacking with Eclipse, I naturally want Eclipse’s EGit to work with my own git server. Here are a couple of noteworthy points:

  • As of this writing, if you want ssh authentication with EGit, ecdsa type key is NOT going to work. rsa ssh key works. I found this out the hard way, since I’m trying to transition from rsa to ecdsa. Therefore I initially didn’t generate rsa keys on my computers. I had to run “ssh-keygen -t rsa -b 4096” and made sure that Eclipse – Preferences – General – Network connections – SSH2 – General tab – Private keys has id_rsa entered;
  • I followed instructions from here to get a few bare repo that I need initialized. Initially I had the misunderstanding that once I push code to the server, I should be able to see the files on the remote server’s repo directory. That turns out to be NOT the case. There is some magic going on under the objects directory that make things happen, such that although the code directories and files are not visible to the naked eye, I could push/fetch/pull to the remote server without problems. When I have time, I need to dig deeper and have a better idea how it all works. For now, I’m happy that I have it working that I can work with the same code base on different dev computers.
  • I followed exercise here for testing and found it helpful.

Happy coding y’all.

Eclipse PDT PHP Web Application Run Configuration

I had some trouble setting up Run Configurations in Eclipse for PHP (PDT plugin). Here is my note for future reference.

Machine: Ubuntu 15 64-bit, with Eclipse Mars. sudo apt-get install php5 installed apache2 for me, so no additional web server install is necessary.

  • Enable userdir mod:
    sudo a2enmod userdir
  • Your /etc/apache2/mods-enabled/userdir.conf should look like this, if not, make it so:
    <ifmodule mod_userdir.c>
            UserDir public_html
            UserDir disabled root
    
            <directory /home/*/public_html>
                    AllowOverride FileInfo AuthConfig Limit Indexes
                    Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
                    <limit GET POST OPTIONS>
                            Require all granted
                    </limit>
                    <limitexcept GET POST OPTIONS>
                            Require all denied
                    </limitexcept>
            </directory>
    </ifmodule>
    
    
  • Comment out the user directories section in /etc/apache2/mods-available/php5.conf, like so:
    # Running PHP scripts in user directories is disabled by default
    # 
    # To re-enable PHP in user directories comment the following lines
    # (from <ifmodule ...> to </ifmodule>.) Do NOT set it to On as it
    # prevents .htaccess files from disabling it.
    #<ifmodule mod_userdir.c>
        #<directory /home/*/public_html>
            #php_admin_flag engine Off
        #</directory>
    #</ifmodule>
    
  • Create a public_html directory under your home directory;
  • Run sudo apt-get install php5-xdebug;
  • Run sudo apt-get install php5-mysql, as necessary;
  • Modify /etc/php5/mods-available/xdebug.ini so it has the following lines:
    zend_extension=xdebug.so
    xdebug.remote_enable=1
    
  • In Eclipse, create your PHP web application project under public_html in your home directory;
  • In Eclipse, while under PHP Perspective, click the drop down next to the green run button, and select “Run Configurations…”;
  • Create a new configuration for PHP Web Application. Pay attention to the following two things:
    a. In the Server tab, Server section, the PHP Server should be “Default PHP Web Server”, this is fine.
    eclipsePDT1
    b. Click the “Configure…” button, you’ll see this. Fill in proper “Document Root” value, in my case, /home/haidong/public_html
    eclipsePDT2
    c. Click the Debugger tab, and pick “XDebug”
    eclipsePDT3
    d. Go back to the original configuration screen, pick the proper file, and fill in th URL info, like below
    eclipsePDT1

By the way, Happy 2016 all!