Saturday, 15 March 2014

Selinux - Allowing Httpd Home Directory


I have just realised that as a default configuration, selinux does not allow to show the content of the http home directory on CentOS. In order to solve this problem, please use the following command.


setsebool -P httpd_enable_homedirs true

You can update the selinux config file (/etc/selinux/config ) so that the rule is automatically applied in every system boot. 

SELINUX=enforcing
SELINUXTYPE=targeted 
setsebool -P httpd_enable_homedirs true

Cheers

Tuesday, 18 February 2014

Running Jenkins on Tomcat with SSL


1) Download java rpm using wget. ( Download java using wget )
2) Login root using su root. Then install it using rpm -ivh rpmname.rpm
3) Be sure that you can access java, javac, keytool commands.
4) Download tomcat and jenkins
5) Move jenkins var to tomcat webapps dir using mv jenkins.war ${TOMCAT_DIR}/webapps
6) Create self signed certificate using keytool -genkey -alias tomcat -keyalg RSA -keystore ${KEYSTORE_FILE_PATH} -validity 365
7) It is going to ask questions about your organisation and such. Please answer them. Pick your password as well
8) In ${TOMCAT_DIR}/conf/server.xml find the line starting with <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"... Uncomment it and add the following attribute values keystoreFile="${KEYSTORE_FILE_PATH}" keystorePass="password"
9) Start tomcat using ${TOMCAT_DIR}/bin/startup.sh. Check both http://localhost:8080/jenkins and http://localhost:8443/jenkins if everything is ok.

Prevent SSH root login

For preventing the root login from ssh, please open the ssh config file using the following command.


vi /etc/ssh/sshd_config

Find the line starting PermitRootLogin. Uncomment it (remove # character) and change value to following

PermitRootLogin no 

Hope it helps

Maven - add existing jars to local repository

In order to add existing jars into the local maven repository, please use the command below.

mvn install:install-file -Dfile=${JAR_FULL_PATH} -DgroupId=${UNIQUE_GID}  -DartifactId=${UNIQUE_ARTIFACTID} -Dversion=${VERSION} -Dpackaging=jar 

And add the dependency in pom.xml as follows.

<dependency>
   <groupId>${UNIQUE_GID}</groupId>
   <artifactId>${UNIQUE_ARTIFACTID}</artifactId>
   <version>${VERSION}</version>
</dependency>

The second way to achieve this is to add system scoped dependency with the system path. 

<dependency>
   <groupId>${UNIQUE_GID}</groupId>
   <artifactId>${UNIQUE_ARTIFACTID}</artifactId>
   <version>${VERSION}</version>
   <scope>system</scope>
   <systemPath>${basedir}/${JAR_RELATIVE_PATH}</systemPath>
</dependency> 

Please be cautious about this, since it breaks maven's dependency system. Most probably, you will see a warning in the maven build output as follows.

Some problems were encountered while building the effective model for X
[WARNING] 'dependencies.dependency.systemPath' for X should not point at files within the project directory, ${basedir}/Y will be unresolvable by dependent projects  


Hope it helps.


Thursday, 5 September 2013

Mysql table size


Hello,

In order to figure out the table sizes in mysql database, use the following query


SELECT table_name AS "Table",  round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB"  
FROM information_schema.TABLES  
WHERE table_schema = "elyapimi" ;


Hope it helps you out,

Cheers




Tuesday, 3 September 2013

Html Img Vertical Alignment

Hello,

I have just bumped into an interesting problem about centering an image vertically in html.
Thanks to 6 Methods For Vertical Centering With CSS for coming up various solutions. Just used the Line-Height method.



.img-wrapper
{

line-height: 200px; // for me, this value is bigger than the image height
}



.img-wrapper img
{

vertical-align:middle;
}




Hope this helps,










Wednesday, 21 August 2013

Tomcat 7 SSL configuration

Hello,

I am going to explain how the ssl is configured in tomcat 6-7 (which works along with apache for https). 

1) use the following open ssl command in order to produce the p12 keystore file 


openssl pkcs12 -export -in mycert.crt -inkey mykey.key  -out mycert.p12 -name tomcat -CAfile myCA.crt  -caname root -chain

You are going to be asked for an export password which you are going to use in the next step. Just type your password.

2) In ${TOMCAT_HOME}/conf/server.xml change the following lines 

 <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />

to


  <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
        maxThreads="150" scheme="https" secure="true"
        clientAuth="false" sslProtocol="TLS" 
        SSLCertificateFile="${SSL_CRT_FILE_PATH}" 
        SSLCertificateKeyFile="${SSL_PRIKEY_FILE_PATH}" 
        keystoreFile="${SSL_P12_KEYSTORE_FILE_PATH}" 
        keystorePass="${EXPORT_PASS_IN_STEP_1}" keystoreType="pkcs12"                                                                  />

Restart your tomcat and try it out using 8443 port. (https://localhost:8443/yourAppPath/)
Check tomcat ssl configuration for more information.

Hope this helps you out!
Cheers