Post centos installation after a minimal installation

Reading Time: 1 minute

1. Auto network discovery there is an app called dhclient. It will easily discovery ip address and launch network right away dhclient -v

commandresult2

2.  install Gnome gui

yum -y groupinstall “X Window System” “Desktop” “General Purpose Desktop”

3.start gui on startup

nano /etc/inittab

change id to 5

# Default runlevel. The runlevels used by RHS are: 
#   0 - halt (Do NOT set initdefault to this) 
#   1 - Single user mode 
#   2 - Multiuser, without NFS (The same as 3, if you do not have networking) 
#   3 - Full multiuser mode 
#   4 - unused 
#   5 - X11 
#   6 - reboot (Do NOT set initdefault to this) 
#  id:3:initdefault:

4.installing vmware tools in vmware choose Install VMware tools

su
yum -y install perl
mkdir /mnt/cdrom
mount /dev/cdrom /mnt/cdrom
cd /mnt/cdrom
mkdir /installs
cp VMware*.tar.gz /installs
cd /installs/
tar -zxvf VMware*.tar.gz
cd vmware-tools-distrib
./vmware-install.pl
/usr/bin/vmware-toolbox

restart pc for the default values I kept pressing on entep  r

Creating and converting an ssl certificate in numerous formats

Reading Time: 1 minute

Creating a key file 

openssl genrsa -des3 -out tugrul.key 1024

Creating CSR(Certificate Signing Request) file

openssl req -new -key tugrul.key -out tugrul.csr

Creating a CRT  Self-Signed SSL Certificate

openssl x509 -req -days 365 -in tugrul.csr -signkey tugrul.key -out tugrul.crt

Converting a Certificate File to PKCS#12(PFX) Format

 openssl pkcs12 -export -out tugrul.p12 -inkey tugrul.key -in tugrul.crt -certfile tugrul.crt

for pfx format alter “-out tugrul.p12” as “-out tugrul.pfx ”

Converting .crt file into the Microsoft .cer format

Double Click the crt file and Skip to the Details tab

ssl1

then choose the format you wish to be exported as

ss2

 

LAMP Stack on Windows

Reading Time: 2 minutes

Apache 2.4 Installation

Download Apache 2.4.16 win32 from Apache lounge – http://www.apachelounge.com/download/

Unzip entire content to C: and keep the folder name as given

Visual C++ Redistributable for Visual Studio 2015 package for Win32 and install it – https://www.microsoft.com/en-us/download/details.aspx?id=48145

Go to unzipped Apache folder –> conf edit httpd.conf and edit those lines;

Listen *:80

remove # from the line of  LoadModule rewrite_module modules/mod_rewrite.so

AllowOverride All

run Command line and go to Apache2.4 bin folder

then issue httpd -t

you will see Syntax OK message

then run the apache as service — but run the command line as admin!

httpd -k install

issue services.msc command in run and start apache server and go to localhost and see the landing page then voila if all works out1

PHP 5.6 Installation

Download Php 5.6 threadsafe win32, http://windows.php.net/download#php-5.6

make sure you install win32 thread safe package(includes apache php lib file) and x86 one not X64 otherwise it does fail for some reason! e.g – php-5.5.18-Win32-VC11-x86.zip

unzip everything in C folder php

then go to the folder and rename php.ini-development to php.ini

open php.ini file, find and alter those lines

this is important make sure you enter the correct path and its not backslashes!!

extension_dir = "C:/php/ext"

uncomment necessary extensions

extension=php_bz2.dll
extension=php_curl.dll
;extension=php_fileinfo.dll
extension=php_gd2.dll
;extension=php_gettext.dll
;extension=php_gmp.dll
;extension=php_intl.dll
;extension=php_imap.dll
;extension=php_interbase.dll
;extension=php_ldap.dll
extension=php_mbstring.dll
;extension=php_exif.dll      ; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll
;extension=php_oci8_12c.dll  ; Use with Oracle Database 12c Instant Client
;extension=php_openssl.dll
;extension=php_pdo_firebird.dll
;extension=php_pdo_mysql.dll
;extension=php_pdo_oci.dll
;extension=php_pdo_odbc.dll
;extension=php_pdo_pgsql.dll
;extension=php_pdo_sqlite.dll
;extension=php_pgsql.dll
;extension=php_shmop.dll

add php folder to your environment variable

041-installing-php

reopen apaches httpd conf file and add index.php

DirectoryIndex index.php index.html

and add the below line to the end of file

# PHP5 module
LoadModule php5_module "c:/php/php5apache2_4.dll"
AddType application/x-httpd-php .php
PHPIniDir "C:/php"

then issue httpd -t to make sure syntax is correct

then start the service in services.msc

Mysql Installation

Download the mysql community edition + workbench bundle full stack — https://dev.mysql.com/downloads/windows/installer/5.6.html

How to write exponential numbers

Reading Time: 1 minute

While I was working on completion of my CS notes, I was looking for writing exponent numbers and googled it. In Turkish results I’ve come to have found this solution

Write n2 and hightligh the number, then later on keep pressing on Alt and 0178 will give you this outcome n², ALT 0179 will give you n³

configure ssl

Reading Time: 1 minute

Export from JKS to PKCS #12.
keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12 -deststoretype PKCS12 -srcalias <jkskeyalias> -deststorepass <password> -destkeypass <password>
mv keystore.p12 /root
cd /root

convert to key
openssl rsa -outform der -in private.pem -out private.key

nano /etc/httpd/conf.d/ssl.conf

find the line <VirtualHost _default_:443>

uncomment ServerName and type servername:443

uncomment:
SSLEngine on

SSLCertificateFile /root/downloadedcertificate.crt

SSLCertificateKeyFile /root/private.key

save and exit
restart httpd

service httpd restart

then test

ssl2

then

Configure SSL on Apache and Glassfish and forward traffic to Glassfish

Reading Time: 2 minutes

keytool -keysize 2048 -genkey -alias tugrulaslan.net -keyalg RSA –dname “CN=tugrulaslan.net,O=company,L=Istanbul,S=Istanbul,C=TR” -keystore keystore.jks

keytool –certreq –alias tugrulaslan.net –keystore keystore.jks –file cert_req.csr

keytool -import -alias tugrulaslan.net -keystore keystore.jks -trustcacerts -file yourdomain.com.crt

send that csr to generate your ssl file then download x509 certificate from geotrust

then move the certificate to /root

IMPORT SSL INTO KEYSTORE

 

download x509 format

and save first server certificate as root.crt

save last intermediate.crt and transfer all files to your ftp

then copy them to domain folder

then

keytool -import -alias intermediate -keystore keystore.jks -trustcacerts -file intermediate.crt

keytool -import -alias root -keystore keystore.jks -trustcacerts -file root.com.crt

keytool -import -alias yourdomain -keystore keystore.jks -trustcacerts -file yourdomain.com.crt

then nano domain.xml

here change all s1as as your domain name and fire  up your server

export key file

keytool -importkeystore -srckeystore keystore.jks -destkeystore keystore.p12 -deststoretype PKCS12 -srcalias jkskeyalias  -deststorepass password -destkeypass password

openssl pkcs12 -in keystore.p12  -nokeys -out cert.pem
openssl pkcs12 -in keystore.p12  -nodes -nocerts -out key.pem
convert pem to key
openssl rsa -outform der -in private.pem -out private.key

then move the key file to /root for security

edit /etc/httpd/conf.d/ssl.conf below

<VirtualHost _default_:443>

ServerName tugrulaslan.net
SSLProxyEngine on
ProxyPreserveHost On
ProxyPass / https://localhost:8181/
ProxyPassReverse / https://localhost:8181/

SSLEngine on

SSLCertificateFile /root/X509CERTIFICATE FROM GEOTRUST.crt

SSLCertificateKeyFile /root/private.key(EXPORTED FROM KEYTOOL)

</VirtualHost>

sslapacheglassfish

 

if you only want https when http request is received then do the following in /etc/httpd/conf/httpd.conf

<VirtualHost *:80>
   ServerName <span class="highlight">example.com</span>
   Redirect permanent / https://example.com/
</VirtualHost>

add firewall

<tt class="COMMAND">iptables -A OUTPUT -p tcp -m tcp --dport 80 -j ACCEPT</tt>
<tt class="COMMAND">iptables -A OUTPUT -p tcp -m tcp --dport 433 -j ACCEPT 

service iptables save

service iptables restart</tt>
<tt class="COMMAND"></tt>

Apache Mod_proxy to forward http traffic to Java App server 8080

Reading Time: 1 minute

In my vps server I wanted to forward http port 80 to glassfish 8080 ports without having glassfish config changed. So I assume httpd apache server is installed. So

cd /etc/httpd/conf

nano httpd.conf

Add the below lines and save and restart apache

<VirtualHost *:80>
# Your domain name
ServerName Domain_NAME_HERE

ProxyPreserveHost On


ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/

# The location of the HTML files, and access control information
DocumentRoot /var/www
<Directory /var/www>
Options -Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>

Result

apacheforward

Source: https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6/html/Administration_and_Configuration_Guide/Install_the_Mod_proxy_HTTP_Connector_Into_Apache_HTTPD.html

 

Installing Wildfly 8 on Centos

Reading Time: 2 minutes

I’ll show you how to set up Wildfly 8 server for standalone not for the domain mode

download the package and unzip

cd /opt
wget http://download.jboss.org/wildfly/8.2.0.Final/wildfly-8.2.0.Final.zip
unzip wildfly-8.2.0.Final.zip -d /opt/

rename the unzipped folder

mv wildfly-8.2.0.Final wildfly

create the wildfly user

groupadd wildfly
useradd -s /bin/bash -g wildfly wildfly

then prepare the config file path

mkdir -p /var/log/wildfly

change the ownership of folders

chown -R wildfly /opt/wildfly
chown -R wildfly /var/log/wildfly

then copy the conf folder

cp /opt/wildfly/bin/init.d/wildfly.conf /etc/default/wildfly

then edit it

nano /etc/default/wildfly

then find the below lines comment out and change

# General configuration for the init.d scripts,
# not necessarily for JBoss AS itself.
# default location: /etc/default/wildfly

## Location of JDK
JAVA_HOME="/usr/java/jdk1.7.0_75"

## Location of WildFly
JBOSS_HOME="/opt/wildfly"

## The username who should own the process.
JBOSS_USER=wildfly

## The mode WildFly should start, standalone or domain
JBOSS_MODE=standalone

## Configuration for standalone mode
JBOSS_CONFIG=standalone.xml

## Configuration for domain mode
#JBOSS_DOMAIN_CONFIG=domain.xml
#JBOSS_HOST_CONFIG=host-master.xml

## The amount of time to wait for startup
STARTUP_WAIT=60

## The amount of time to wait for shutdown
SHUTDOWN_WAIT=60

## Location to keep the console log
JBOSS_CONSOLE_LOG="/var/log/wildfly/console.log"

then copy the init script

cp /opt/wildfly/bin/init.d/wildfly-init-redhat.sh /etc/init.d/wildfly

then add the script to chkconfig and launch it

chkconfig --add wildfly
chkconfig wildfly on

then now we need to open the server to public. In its default settings external sources are disallowed to browse through the app server

nano /opt/wildfly/standalone/configuration/standalone.xml

change these lines

<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
</interface>
<!-- TODO - only show this if the jacorb subsystem is added  -->
<interface name="unsecure">
<!--
~  Used for IIOP sockets in the standard configuration.
~                  To secure JacORB you need to setup SSL
-->
<inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
</interface>

to these

<interfaces>
<interface name="management">
<inet-address value="${jboss.bind.address.management:0.0.0.0}"/>
</interface>
<interface name="public">
<inet-address value="${jboss.bind.address:0.0.0.0}"/>
</interface>
<!-- TODO - only show this if the jacorb subsystem is added  -->
<interface name="unsecure">
<!--
~  Used for IIOP sockets in the standard configuration.
~                  To secure JacORB you need to setup SSL
-->
<inet-address value="${jboss.bind.address.unsecure:127.0.0.1}"/>
</interface>

then start the server

[root@centos configuration]# /etc/init.d/wildfly start
Starting wildfly:                                          [  OK  ]

then now we will need management users

 

 

Installing Jdk 7 on Centos

Reading Time: 1 minute

download jdk on console

cd /opt
sudo wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/7u75-b13/jdk-7u75-linux-x64.tar.gz"

then unpack

tar zxvf jdk-7u75-linux-x64.tar.gz

then create folder

mkdir /usr/java

then move

mv jdk1.7.0_75/ /usr/java/

install java

alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_75/bin/java 1

install javac

alternatives --install /usr/bin/javac javac /usr/java/jdk1.7.0_75/bin/javac 1

install jar

alternatives --install /usr/bin/jar jar /usr/java/jdk1.7.0_75/bin/jar 1

install javaws

alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.7.0_75/bin/javaws 1

test the installation

[root@host-50-244-171-31 opt]# java -version
java version "1.7.0_75"
Java(TM) SE Runtime Environment (build 1.7.0_75-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.75-b04, mixed mode)

[root@host-50-244-171-31 opt]# javac -version
javac 1.7.0_75

then set java home

sh -c "echo export JAVA_HOME=/usr/java/jdk1.7.0_75 >> /etc/environment"

issue the command

source /etc/environment

test

[root@host-50-244-171-31 opt]# echo $JAVA_HOME
/usr/java/jdk1.7.0_75

this package is needed for javaws

yum -y install libX11-devel.x86_64

test javaws

[root@host-50-244-171-31 opt]# javaws -version
Java(TM) Web Start 10.75.2.13-fcs