Installing Sugar CRM community Amazon EC2
Posted: May 19, 2012 Filed under: Amazon AWS, EC2, IT Survival, SugarCRM | Tags: Amazon AWS, EC2, SugarCRM Leave a comment »This is pretty simple and I will have to be doing it quite a lot in the next coming months, so this is more an aide de memoire
It is presumed that you already have a server with Apache and PHP installed. If not you need to yum apache and php.
At the time of writing we were looking at the RC2 release (brave I know
)
cd ~
mkdir software
cd software
wget http://downloads.sourceforge.net/project/sugarcrm/1%20-%20SugarCRM%206.5.0/SugarCommunityEdition-6.5.0/SugarCE-6.5.0RC2.zip
unzip SugarCE-6.5.0RC2.zip
mv SugarCE-Full-6.5.0RC2 /var/www/html/sugar65ce
I create this link so the URL can stay the same irrespective of the version
ln -s /var/www/html/sugar65ce/ crmcom
chown -R apache:apache sugar65ce/
cd sugar65ce
chmod 766 config.php
chmod 766 custom/
Web browse to the domian
http://domain-name.com/crmcom/install.php
Take all the default options, because of the chmod above you should get no errors
Provide all the database details when prompted ( I personally have called the database sugarcrm_com and we are also a professional user of CRM)
* * * * * cd /var/www/html/sugar65ce; php -f cron.php > /dev/null 2>&1
Blackberry BES Admin password does not work
Posted: May 16, 2012 Filed under: Amazon AWS, Blackberry Server, EC2, IT Survival Leave a comment »WOW
The Balckberry BES server certainly has some issues. The password for the Admin user failed to work. I know I got it correct as I use a choice of very secure password for my installs.
After much searching I discovered the prescribed way to get this back working is to re-install.
Well that was not going to happen. So I ran up another BES server and then just stole the password from the database that was encoded.
Please note that I am using the “BlackBerry Administration Service” for the authentication rules as per the installation of the BES server
If you are using the AD authentication there is a knowledge base here that will help you I think. I have not used it to reset the password, but I did use it successfully to generate a password. Blackberry KB18161
Back to you error though, this will work on BES 5.0 SP3 and Microsoft SQL 2005. I don’t think the SQL server has an effect but just so you know the versions.
Open up an SQL connection the BES SQL server, I use studio manager but as long as you have the SQL connection who cares.
This will update a user called Admin and set the password to blackberry
UPDATE BASUsers
SET LoginPassword = ‘D8BBFD88EB76EF129C4AA7C812AEB7664D2BE09B6D51D8555E0FC9F54515F88FC2F3BD209887BE064B0F2C11F7C9E6E86BA733667BA3BE4A459968FDB6DF8526:489F5C4B’
WHERE (LoginName = ‘Admin’)
This worked for me, there are other posts on forums but unfortunately the encrypted password does not work. RIM probably changed the encryption between releases.
Good luck and it does work
Alistair
Install S3Fuse and mount local disk Amazon EC2
Posted: May 11, 2012 Filed under: Amazon AWS, EC2, IT Survival | Tags: Amazon AWS, EC2, S3, S3cmd, S3Fuse, s3tools Leave a comment »There is a need to mount a S3 bucket to an EC2 server. Please NOTE that mounting drives should not be used in high read write environments. If all you want to do is push a backup to the disk because S3cmd will not do it for you then by all means use this. Do not use it for files that are server via a heavily used web server. (these are not my findings but from a startup company that I was talking to at the 2012 London AWS summit)
The install instructions for fuse are pretty concise so as per usual this will be about those little gotya’s (if that’s how you spell it
)
The are some pre-requisites as always but these are listed on the site. For S3Fuse installation instructions
So from the install instructions with some slight amendments of course
yum install gcc libstdc++-devel gcc-c++ fuse fuse-devel curl-devel libxml2-devel openssl-devel mailcap make
cd ~
mkdir software
cd software
As usual you need to get the latest stable release and at the time of writing 1.61.1 was stable
wget http://s3fs.googlecode.com/files/s3fs-1.61.tar.gz
tar xvzf s3fs-1.61.tar.gz
cd s3fs-1.61
./configure –prefix=/usr
make
make install
S3Fuse should now be installed. We need to test this now. So we need to mount a bucket to the server. You will need your Amazon AWS ID and secret. I am assuming that you know how to do this already but if you need a hint for the URL https://aws-portal.amazon.com/gp/aws/securityCredentials
You need to create a .passwd-s3fs file. This is best done as root as it should be stored in the home directory and should of course be secured done.
cd ~
echo accessKeyId:secretAccessKey > .passwd-s3fs
chmod 600 ~/.passwd-s3fs
to test mount a bucket you either need to know the bucket name or use s3cmd to list the bucket names etc… see installing and using s3cmd
Once you know which bucket you want to mount then
cd /mnt
mkdir bucketname - this is only a suggestion but it keeps it consistent and therefore easy to debug
then issue the s3fs commands
/usr/bin/s3fs mybucket /mnt -ouse_cache=/tmp
e.g.
the bucket name is call domainname-website-export so
(all s3 buckets as you know have to be unique and therefore I have adopted the practice of starting every bucket with the domain name)
cd /mnt
mkdir website-export
/usr/bin/s3fs -o allow_other domainname-website-export /mnt/website-export -ouse_cache=/tmp
NOTE the -o allow – makes the mounted directory accessible by other users of the server.
you should now be able to cd /mnt/website-export and create a file
Now to permanently mount the drive when the server boots up etc… the command for the fstab is as follows :
s3fs#bucketname /mnt/mount_folder fuse allow_other 0 0
e.g.
vi /ect/fstab
vi hint i
s3fs#domainname-website-export /mnt/website-export fuse allow_other 0 0
vi hint Esc :wq
mount -a
You should now have a mounted drive, that is accessible by any user of the server.
Instance reachability check failed
Posted: May 4, 2012 Filed under: Amazon AWS, EC2, IT Survival | Tags: Amazon AWS, EC2 Leave a comment »This is one error you do not want to see when you are booting up an EC2 instance the dreaded
Instance reachability check failed. Pass 0/2 checks or 1/2 check. Especially when this is you backup copy of a live system.
Believe me when I tell you that this strategy is being changed very quickly and S3 will be used for backup sets.
So how the hell do you fix this issue. Well if you are in the following situation all may not be lost.
This is based on the Ec2 instance being EBS backed if it is S3 then sorry not sure how you will get it working.
This method will allow you to get you data from the system and then allow you to rebuild the server, e.g. apache webserver.
This has worked on a Linux server, I have not tried it on a Windows server but it should work. Hopefully I will nerver have to try
Start by creating a disk volume from the snapshot
When the dialogue shows enter the details in terms of size. I made the volume the same size as the snapshot.
Make a note of the zone as you will need to launch an instance in this zone.
Yes to create the Volume.
Now Launch a new instance in the zone when the volume was created, this is where the micro instance come into their own. Once this is operational you need to attach the newly created volume to the instance.
Navigate to the volume screen and pick the volume, at the top of the screen use the drop down box to display Attach Volume and pick the newly created instance.
This will attach the volume to the server.
Log-on to the server, since this is Linux you need to mount the disk.
To make this complete and just in case you are a bit rusty, this is how you do this.
fdisk -l
will give you an output something like this
Disk /dev/xvda1: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0×00000000
Disk /dev/xvda1 doesn’t contain a valid partition table
Disk /dev/xvdf: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0×00000000
Disk /dev/xvdf doesn’t contain a valid partition table
The important line is the /dev/xvdf – this indicated the mounted volume
To mount the volume, as root (sudo su)
cd /
mkdir u10
mount -t ext4 /dev/xvfd /u10
Note if you get an error regarding the format change to ext3 or another disk format, but this should work.
You can now cd into u10 and you have access to the file system.
Good luck if this has happened to you
Alistair
Install Oracle Express in Amazon AWS
Posted: April 3, 2012 Filed under: Amazon AWS, EC2, IT Survival | Tags: Amazon, AWS, Oracle Express 1 Comment »I took this configuration out of my Project.net installation as some of you may want to run Oracle express in Amazon for other things, the main reason that this was a little tricky is that the project software needs a constant host name and therefore the Oracle needs a little help
Launch an instance, and connect. You need to change the host name, to do this.
vi /etc/sysconfig/network
Change the host name line to
HOSTNAME= A FQDN
The network needs to be restarted
cd /etc/init.d
./network restart
Download the oracle xe express database from the Oracle web site, I have yet to figure out how to do this via a command line in Linux, so download via a web browser and then upload to the server, this can be done via the pscp.exe that is shipped with putty, there are loads of tutorials on the net that will tell you how to do this.
Once uploaded and as per usual I have created a software folder, and uploaded the rpm to this folder.
cd ~
mkdir software
You need a swap space on the server to allow Oracle to be installed this can be found at survivalguides create swap space written by yours truly.
Install Oracle XE via RPM or DEB depending on your Linux distribution
cd ~/software
service iptables stop
rpm -i oracle-xe-10.2.0.1-1.0.i386.rpm
Run “/etc/init.d/oracle-xe configure” to configure Oracle
Specify the HTTP port that will be used for Oracle Application Express [8080]:8080
Specify a port that will be used for the database listener [1521]:1521
Specify a password to be used for database accounts. Note that the same password will be used for SYS and SYSTEM. (* make sure you remember this password *)
Do you want Oracle Database 10g Express Edition to be started on boot (y/n) [y]: y
vi /etc/profile
Insert the following lines at the bottom
export ORACLE_HOME=/usr/lib/oracle/xe/app/oracle/product/10.2.0/server
export ORACLE_HOMEexport ORACLE_SID=XEexport NLS_LANG=AMERICAN.AL32UTF8
export PATH=$PATH:$ORACLE_HOME/bin
You need to run the profile to get the variables
. /etc/profile
Note the space between . /
It is also worth adding these lines to the .bashrc file in the home directory
service oracle-xe stop
Again an Amazon quirk is the localhost name so add the host name that was created at the start of the procedure to the hosts file.
vi /etc/hosts
service oracle-xe start
To test that this is a connection to the database use the standard Oracle test command
tnsping xe
You can also use the sqlplus client
sqlplus sys/(password for oracle)@xe as sysdba
This should give you an SQL prompt.
exit
This will get you out of the sqlplus client.
Once the server is restarted this will stop working, again another Amazon little gotya, this is because the IP address changes and so can the host name. To get around this you need to change the tnsnames.ora file to match the new name of the server.
vi /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/tnsnames.ora
My tns file looks like this
# tnsnames.ora Network Configuration File:
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = project.acme.com)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
This is a read only file so you will need to use
:wq!
To save the file
You also need to change the listener.ora file as this also contains the host name of the server.
vi /usr/lib/oracle/xe/app/oracle/product/10.2.0/server/network/admin/listener.ora
My file looks like this
# listener.ora Network Configuration File:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /usr/lib/oracle/xe/app/oracle/product/10.2.0/server)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
(ADDRESS = (PROTOCOL = TCP)(HOST = project.acme.com)(PORT = 1521))
)
)
DEFAULT_SERVICE_LISTENER = (XE)
This is a read only file so you will need to use
:wq!
To save the file
You need to create the following file, to recreate the hosts file every time the server is rebooted, this will allow the oracle to work properly.
The script file I called createhostfile.ksh and the contents is
#!/bin/bash
getip=`/sbin/ifconfig eth0 | grep ‘inet addr’ | awk ‘{print $2}’ | sed -e ‘s/.*://’`
newhost=”${getip} project.acme.com“
rm -f /etc/hosts
echo “127.0.0.1 localhost localhost.localdomain” > /etc/hosts
echo $newhost >> /etc/hosts
Note that I called my server project, you will need to replace this with what you have call your server.
To create the file
cd /etc
vi createhostfile.ksh
paste the script above
chmod 755 createhostfile.ksh
Now we can change the oracle-xe file that is used to start and stop oracle.
vi /etc/init.d/oracle-xe
After all of the comment insert the following line
/etc/createhostfile.ksh
This will call the host file creating every time that oracle is started.
Installing S3CMD on Amazon Server
Posted: April 2, 2012 Filed under: Amazon AWS, EC2, IT Survival | Tags: Amazon, AWS, S3, S3 tools 1 Comment »S3CMD is the command line tool for Amazon that allows you to connect and use S3 storage in the Amazon infrastructure.
The guide as always has some expectation of experience in Linux but where possible does give the commands that are required.
cd ~
mkdir software
cd software
wget http://sourceforge.net/projects/s3tools/files/s3cmd/1.0.1/s3cmd-1.0.1.tar.gz
tar xzf s3cmd-1.0.1.tar.gz
yum install python24-devel
cp -R s3cmd-1.0.1 /opt/s3cmd
cd /opt/s3cmd
python setup.py install
This should install the tool, you know need to configure the software. You will need you AWS access ID and secret key.
s3cmd –configure
Enter the details required. You will then be prompted with some questions
Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password: Enter
Path to GPG program [/usr/bin/gpg]: Enter
When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP and can’t be used if you’re behind a proxy
Use HTTPS protocol [No]: Enter
On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can’t connect to S3 directly
HTTP Proxy server name: Enter
I am usually pretty security conscious and therefore you have to decide on whether you should answer yes to some of the questions, it is all dependent on what you are storing on S3.
How to use the software can be found on the web site of the tool. http://s3tools.org/s3cmd
Some brief commands and examples
s3cmd ls - Lists the buckets
s3cmd ls s3://bucketname/ - will list what is in the bucket note the trailing /
s3cmd put localfilename s3://bucketname/ – will put the file into the bucket
s3cmd put localfilename s3://bucketname/foldername/ -
will put the file into the bucket into a folder name. This will create the folder in the s3 bucket if it does not exist
s3cmd get s3://bucketname/filename local path - will get the file and place it in the local path specified
s3cmd sync s3://bucketname/foldername/ localfoldername/ - syncs the s3 bucket folder to the local folder works much like rsync
s3cmd sync localfoldername/ s3://bucketname/foldername/ - syncs the local folder name to the s3 bucket folder.
s3cmd mb s3://new-bucket-name/ - creates a new bucket
Create Blackberry BES server on Amazon AWS windows server
Posted: March 28, 2012 Filed under: Amazon AWS, Blackberry Server, EC2, IT Survival | Tags: Amazon, AWS, BES, Blackberry, EC2 1 Comment »To continue the theme of hosting servers in the cloud, we are building a Blackberry server in the Amazon infrastructure.
There are a few funnies with the installation and therefore as always I wanted to share them. There is some expectation through out this document of experience. In Window administration, DNS, Active Directory and a little MSSQL.
Please note that when creating users in the BES server choose the not active directory method as this will fail when the server is rebooted as the IP address changes. There is a solution I am sure to getting Active directory working when the IP address changes I am sure but as always I don’t have time to fathom that part out. If anyone ever finds out how to fix that part let me know.
Windows Server Installation
Once you have an active instance
Run the EC2 Service program
Un-check the Set Comuter Name tick box
Check the output event log (you can use the advanced button to specify more output here if you wish)
Change the computer name to the subdomain of the FQDN name that you will be using
e.g. BES — The FQDN will be BES.ACME.COM where the company is ACME.COM
You will need to restart the server.
We now need to promote the server to an Active Directory server as the BES server needs access to a doamin server
This is a windows 2008 server so Administrator Tools –> Server Manager
Click Roles and then Add Role
Choose Active Directory Domain Services
Next, Next, Install
The installation starts, when complete you are given a link to run dcpromo.exe
Next, Next, Create a new domain in a new forest
When prompted to enter the FQDN use the servername and the domain that you will use to contact the server.
e.g. acme.com
When prompted for Forest functional level pick 2008 R2
When prompted for additional options, ensure that the DNS server is ticked, YOU need to use the dynamically assigned ip address as this is an Amazon server
An error regarding delegation will be displayed just accept with YES
The prompt is then for a strong password, make sure that this is noted down
Next until the installation is finished
The server needs rebooting
Log-on as the Administrator to the domain when rebooted
The installation of the Active directory service will create the server as a DNS server aslo, we need to allow PTR records to be created.
Launch the DNS manager and add an new PTR zone, because the IP range on Amazon is 10.x.x.x you can create a PTR zone 10.XXXXX
The DNS entries on the network adapter need changing to Dynamically assign, this allows the Blackberry phone to web browse
Now add the role of web server to BES environment, SQL requires some of the IIS functionality to operate. Again do this through the server manager tool. Include the FTP server element as this maybe useful when transferring files.
SQL Server Installation
Due to the size of the environment we are using the full SQL server version
Ignore the compatability error as the service pack will fix these issues, and install the server, there is no special installation, you just need the Database
services and the SQL management client
I like using mix moded authentication for the SQL server
Install the latest service pack that is applicable to the SQL server that you are installing
Outlook 2007 Installation
Because this server is for Google integration we need to install outlook 2007
Install the latest service packs for Outlook
User Set-up
The last pre-requisite that is needed is a user that will be used to run the BES server, this can not be the Administrator account
I have created a user called Bes Admin in both the active directory and Google, keep it simple ![]()
The user needs to be in the Administrators of the server group (normally a local admin would do)
Install Google Apps Connector
Install the google app connector, this must be done before you install the BES software.
Log on to the server as Bes Admin
Open up the Google Apps Connector for Blackberry and press File Locations
Set the Location to where you wish the data to be saved
Press the profile button and enter the details
BES Server Installation
You need to enter your own details on this part of the install but it is not hard.
To inport the CAL use the following command
bcp BESMgmt.dbo.LicenseKeys in D:\BESKeys.txt -c -T
Where BESMgmt is the datbase name, I took the default option when installing
D:\BESKEYS.txt is the license key file
NOTE the license keys need to be as follows
KEY<tab>0
KEY<tab>0
e.g.
bescal-jlsjdflkjsdlf0234903290 0
bescal-jlsjdflkjsdlf02349032asd 0
Install Project.net Amazon EC2
Posted: March 10, 2012 Filed under: Amazon AWS, EC2, IT Survival Leave a comment »The installation of Project.net is covered extremly well in the wiki of the site. There are some slight changes required for installation on Amazon mainly around the host name.
If you use the standard Amazon AMI Linux image, this comes with JAVA pre-installed and saves you the pain of installing JAVA on Linux.
This as per usual is not complete and therefore should be used carefully and it is still unproven and could be full of errors.
Install a Linux server and install Oracle as per the Survival Guides Install Oracle Express on Amazon AWS
Once this has been done you can no start on the installation as per the wiki. project.net wiki
Download the project.net software.
cd ~
cd software
mkdir projectnet
cd projectnet
wget http://downloads.sourceforge.net/project/projectnet/Project.net%20Production/Project.net%209.2.5/Custom_Installation_925.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fprojectnet%2F&ts=1331395530&use_mirror=heanet
unzip Custom_Installation_925.zip
cd ~
cd software
To make this easier for the instructions we will move the folder to /tmp
mv projectnet /tmp/
cd /tmp/projectnet/database/create-scripts/versions/9.2.0/new
yum install dos2unix
find . -type f -exec dos2unix {} \;
vi pnetMasterDBBuild.sh
Change the following
PNET_BUILD_DB_SCRIPTS_PATH=/tmp/projectnet/database/create-scripts/versions/9.2.0/new
PNET_BUILD_DB_DATABASE_NAME = XE (XE is for because we are using the express database)
PNET_BUILD_DB_DATAFILE_PATH=/usr/lib/oracle/xe/oradata/XE/
PNET_BUILD_SYSTEM_ACCOUNT=system
PNET_BUILD_SYSTEM_PASSWORD=xxxxxxxxx
PNET_BUILD_USER_NAME=pnet
PNET_BUILD_USER_PASSWORD=xxxxx
PNET_BUILD_APP_USER_NAME=pnet_user
export PNET_BUILD_APP_USER_PASSWORD=xxxxxxx
chmod 755 pnetMasterDBBuild.sh
./pnetMasterDBBuild.sh
To monitor the installation use the following command. It is assumed that you did not change the location and name of the log file in the pnetMasterDBBuild.sh file.
tail -f /tmp/pnet_test_db_build.log
Towards the end of the script it appears to stall when it gets to the entry
=====================================
Applying 9.2.0 upgrade patch
=====================================
If you tail the log file you will see that the script requires some entries, pressing enter forces the script to run
You need to press enter until you get the Done message.
This is direct from the Wiki for a little bit until I say otherwise, the wiki is good but it does have the assumption that you know you way around Linux. These instructions blend the two together.
Copy /tmp/pnet/v9.2.0_OS/lib/jce6/*.jar to the jre/lib/security directory of the Java runtime location.
cp /tmp/projectnet/lib/jce6/*.jar /usr/lib/jvm/jre/lib/security
Apache tomcat needs to be installed now
cd ~
cd software
wget http://apache.mirrors.timporter.net/tomcat/tomcat-6/v6.0.35/bin/apache-tomcat-6.0.35.tar.gz
tar xzvf apache-tomcat-6.0.35.tar.gz
mv apache-tomcat-6.0.35 /opt/
ln -s /opt/apache-tomcat-6.0.35 /opt/tomcat
ln -s /opt/apache-tomcat-6.0.35 /opt/apache-tomcat
We need to set the paths for the CATALINA_HOME
vi /etc/profile
and this to the bottom of the file
export CATALINA_HOME=/opt/tomcat
export PATH=$PATH:$CATALINA_HOME
You can also change the .bashrc file in the home directory
To test the starting of Tomcat use the following
cd $CATALINA_HOME/bin
./startup.sh
./shutdown.sh
You should get no errors.
The Tomcat server needs configuring now.
cd $CATALINA_HOME/conf
vi tomcat-users.xml
Add a new user named “manager” and “manager” role associated with it (Note: it is strongly recommended that you use secure passwords in place of those listed below):
TAKE A NOTE OF THE MANAGER PASSWORD as it is needed later on in the configuration
The file should look like this
<role rolename=”tomcat”/>
<role rolename=”role1″/>
<role rolename=”manager”/>
<user username=”tomcat” password=”tomcat” roles=”tomcat”/>
<user username=”both” password=”tomcat” roles=”tomcat,role1″/>
<user username=”role1″ password=”tomcat” roles=”role1″/>
<user username=”manager” password=”manager” roles=”manager”/>
cp /tmp/projectnet/lib/mail.jar $CATALINA_HOME/lib
cp /tmp/projectnet/lib/activation.jar $CATALINA_HOME/lib
cp /tmp/projectnet/lib/jdbc/ojdbc14.jar $CATALINA_HOME/lib
mkdir $CATALINA_HOME/endorsed
cp /tmp/projectnet/lib/endorsed/serializer.jar $CATALINA_HOME/endorsed
cp /tmp/projectnet/lib/endorsed/xalan.jar $CATALINA_HOME/endorsed
cp /tmp/projectnet/lib/endorsed/xercesImpl.jar $CATALINA_HOME/endorsed
cp /tmp/projectnet/lib/endorsed/xml-apis.jar $CATALINA_HOME/endorsed
cd $CATALINA_HOME/conf
vi server.xml
Find the port that are marker 8080 and change them to 9090
/8080 and n will find all the entries in the file
Be careful as the file is full of commented lines and there is only one live line
This is taken directly from the wiki
Instructions (Linux systems)
- Add the following lines near the top of TOMCAT_HOME/bin/catalina.sh
if [ -z "$JAVA_OPTS" ]
then
JAVA_OPTS="-Xms256m -Xmx<see above>m -XX:MaxPermSize=384m -Xss<see
above>k -Djava.awt.headless=true"
else
JAVA_OPTS=${JAVA_OPTS}" -Xms256m -Xmx<see above>m -XX:MaxPermSize=384m
-Xss<see above>k -Djava.awt.headless=true"
fi
You need to use this line if you are using following java versions “1.6.0_26, 1.6.0_27 ….. 1.6.0_31″
JAVA_OPTS=”-server -Djava.awt.headless=true -Xms256m -Xmx<>m -XX:MaxPermSize=384m -Xss<>k”
To start tomcat automatically you need to use the following script. This was lifted directly from the wiki, I would suggest using the wiki version for the latest code. This one works though
vi /etc/inin.d/tomcat
#!/bin/sh
#
# Startup script for Tomcat 6.0, the Apache Servlet Engine
#
# chkconfig: - 80 20
# description: Tomcat 6
# processname: tomcat
# pidfile: /var/run/tomcat6.pid
# config:
#
# Source function library.
if [ -x /etc/rc.d/init.d/functions ]; then
. /etc/rc.d/init.d/functions
fi
# Get Tomcat config
# PID_FILE - must match CATALINA_PID in catalina.sh
PID_FILE=/opt/apache-tomcat/bin/startstop.pid
# Path to the tomcat launch script (direct don't use wrapper)
TOMCAT_SCRIPT=/opt/apache-tomcat/bin/catalina.sh
# Tomcat name
TOMCAT_PROG=tomcat
# SYSTEM lock file
SYSTEM_LOCK_FILE=/opt/apache-tomcat/bin/startstop.lock
# How long to wait for shutdowns
SHUTDOWN_WAIT=15
# if TOMCAT_USER is not set
if [ -z "$TOMCAT_USER" ]; then
TOMCAT_USER="pnet"
fi
# Since the daemon function will sandbox $tomcat
# no environment stuff should be defined here anymore.
RETVAL=0
# See how we were called.
start() {
echo -n "Starting $TOMCAT_PROG: "
if [ -f $SYSTEM_LOCK_FILE ] ; then
if [ -f $PID_FILE ]; then
read kpid < $PID_FILE
if checkpid $kpid 2>&1; then
echo "process allready running"
return -1
else
echo "lock file found but no process running for pid $kpid, continuing"
/bin/rm -f $SYSTEM_LOCK_FILE $PID_FILE
fi
fi
fi
export CATALINA_PID=$PID_FILE
if [ -x /etc/rc.d/init.d/functions ]; then
daemon --user $TOMCAT_USER $TOMCAT_SCRIPT start
else
su - $TOMCAT_USER -c "$TOMCAT_SCRIPT start"
fi
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch $SYSTEM_LOCK_FILE
return $RETVAL
}
stop() {
echo -n "Stopping $TOMCAT_PROG: "
if [ -f $SYSTEM_LOCK_FILE ] ; then
if [ -x /etc/rc.d/init.d/functions ]; then
daemon --user $TOMCAT_USER $TOMCAT_SCRIPT stop
else
su - $TOMCAT_USER -c "$TOMCAT_SCRIPT stop"
fi
RETVAL=$?
if [ $RETVAL = 0 ]; then
count=0;
if [ -f $PID_FILE ]; then
read kpid < $PID_FILE
let kwait=$SHUTDOWN_WAIT
until [ `ps --pid $kpid | grep -c $kpid` = '0' ] || [ $count -gt $kwait ]
do
echo "waiting for processes to exit";
sleep 1
let count=$count+1;
done
if [ $count -gt $kwait ]; then
echo "killing processes which didn't stop after $SHUTDOWN_WAIT seconds"
kill -9 $kpid
fi
fi
rm -f $SYSTEM_LOCK_FILE $PID_FILE
fi
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 2
start
;;
condrestart)
if [ -f $PID_FILE ] ; then
stop
start
fi
;;
*)
echo "Usage: $TOMCAT_PROG {start|stop|restart|condrestart}"
exit 1
esac
exit $RETVAL
The user that starts tomcat in the script is pnet, I have changed this to root just to get it working. I will go back and create pnet as a user and then make it work. One thing I always do in Linux and many think, use the most privileged user as this eliminates the whole authority issues and allows you to concentrate on the scripting errors.
To get this script working make sure that you have don the ln steps above
service start tomact
If it starts successfully
chkconfig –add tomcat
chkconfig tomcat on
Now download ActiveMQ
wget http://mirror.ox.ac.uk/sites/rsync.apache.org/activemq/apache-activemq/5.6.0/apache-activemq-5.6.0-bin.tar.gz
tar xvzf apache-activemq-5.6.0-bin.tar.gz
cd apache-activemq-5.6.0
mv apache-activemq-5.6.0 /opt/
cd /opt
ln -s apache-activemq-5.6.0/ apache-activemq
cd apache-activemq
The assumption is that you are running 32 bit Linux, I will leave you to guess what the 64 bit directory is called
/opt/apache-activemq/bin/linux-x86-32
vi wrapper.conf
Look for the following lines
set.default.ACTIVEMQ_HOME=../..
set.default.ACTIVEMQ_BASE=../..
And change them to
set.default.ACTIVEMQ_HOME=/opt/apache-activemq
set.default.ACTIVEMQ_BASE=/opt/apache-activemq
cd /opt/
ln -s /opt/apache-activemq/bin/linux-x86-32/activemq /etc/init.d/activemq
service activemq start
If the service starts correctly
chkconfig –add activemq
chkconfig activemq on
We now have all of the environment set up
To test if it works browse to
http://domainname.com:9090/manager/html
the username is manager and the password is the password that was set in the tomcat-user.xml file above
Installing project.net is next.
There are a few ways to do this according to the wiki, this is the way I have done it, it is your preference. I don’t claim to be a tomcat expert and therefore can not give an opinion on the best way to deploy the packages. I think though not overwriting the ROOT is good practice though.
I am sure that there is a way to install the pnet.war file directly from the EC2 server, but again my lack of
Last thing to setup, is to serve the site via Apache, this should speed the site up considerably.
yum install httpd
service httpd start
If it starts OK
chkconfig –add httpd
chkconfig httpd on
Compile and Install Apache, PHP, MySql Client, PHPAdmin Amazon AWS AMI for Drupal
Posted: February 27, 2012 Filed under: Amazon AWS, EC2, IT Survival | Tags: apache httpd, pcre Leave a comment »We are launching a Drupal web site and as per best practices require that the web server be built only with the relevant modules required. This mean compiling the Apache code from source, to achieve this there are a few steps to go through as you would expect.
This is also running on the Amazon AWS platform and therefore additional packages need to be installed as some of the base images are very vanilla. The install is based in the Centos based Amazon AMI.
Again as always apology for some of the basic nature of the syntax i.e. cd .. but these guides are meant for all levels of Linux user and I only class myself as intermediate at best.
Please note that some of the configuration has – - but Word Press displays — this affects the copying of the syntax. So please be aware that you will have to change these parts after you have copied and pasted
You need the following packages on the server to complete the installation
yum install gcc make libtool gcc-c++ pcre pcre-devel zlib-devel
If you plan on using PHP you will need
yum install libxml2 libxml2-devel
If you plan on using mysql with the installation (please note that this will just load the client and my mysql server in on another server)
Experimental at the moment, I started to install Drupal and found I needed mysqli, this appear to be bundled with mysql-server
yum install mysql mysql-devel mysql-server
The start of the installation
cd ~
mkdir software
cd software
download the apr and apr-utility
wget http://mirrors.ukfast.co.uk/sites/ftp.apache.org//apr/apr-1.4.6.tar.gz
wget http://mirrors.ukfast.co.uk/sites/ftp.apache.org//apr/apr-util-1.4.1.tar.gz
tar xzvf apr-1.4.6.tar.gz
tar xzvf apr-util-1.4.1.tar.gz
cd apr-1.4.6
./configure
make
make install
cd ..
cd apr-util-1.4.1
./configure –with-apr=/usr/local/apr
make
make install
To ensure that the server starts make sure you use this command, this creates all the links required for the shared libraries.
ldconfig
To install the Apache server
cd ..
The is some notes here that you need to read
PHP 5.3.x does not work with Drupal 6.x and therefore we need to install PHP 5.2.x as will be seen below. The trouble is that 5.2.x will only run on Apache 2.2.x so be careful which way you are going.
Using PHP 5.2.x
wget http://mirrors.ukfast.co.uk/sites/ftp.apache.org//httpd/httpd-2.2.22.tar.gz
tar zxvf httpd-2.2.22.tar.gz
cd httpd-2.2.22
./configure –enable-so \
–enable-authz_host=shared \
–enable-mod_dir=shared \
–enable-log_config=shared \
–enable-mime=shared \
–enable-rewrite=shared \
–enable-setenvif=shared \
–enable-alias=shared \
–enable-expires=shared \
–enable-headers=shared \
–enable-deflate=shared \
–enable-include=shared \
–with-included-apr=/usr/local/apr
make
make install
Using PHP >= 5.3.x
wget http://mirror.catn.com/pub/apache//httpd/httpd-2.4.2.tar.gz
tar zxvf httpd-2.4.2.tar.gz
cd httpd-2.4.2
./configure –prefix=/opt/httpd \
./configure –enable-so \
–enable-authz_host –enable-mod_dir –enable-log_config \
–enable-mime –enable-rewrite –enable-setenvif –enable-alias \
–enable-expires –enable-headers –enable-deflate –enable-include \
–with-included-apr=/usr/local/apr
Note the /opt/httpd (I can not find anywhere a best practice on where to compile the installation so I have chosen /opt as this is for none base packages and even though Apache is always linked with Linux it could be considered third party
). If there is anyone who disagrees please let me know and I will change the instructions accordingly.
I found out that if you leave the prefix out you get the default install which is never a bad thing. It will install it in /usr/local/apache2
make
make install
To test if the server starts
cd /usr/local/apache2/bin
./apachectl -k start
Web browse to the server and a page displaying It Works! should appear
./apachectl -k stop
Now the PHP installation
cd ~
cd software
PHP 5.3 or above does not work on Drupal 6 TAKE NOTE this was one that caught me
5.2.17
wget http://museum.php.net/php5/php-5.2.17.tar.gz
tar xzvf php-5.2.17.tar.gz
cd php-5.2.17
5.3.10
wget http://uk3.php.net/get/php-5.3.10.tar.gz/from/this/mirror
tar xzvf php-5.3.10.tar.gz
cd php-5.3.10
There was an error when trying to use Drupal in that it needed mysqli connection. Ammened 1st May 2012, some of this was taken from the MySQL reference Enabling Both mysql and mysqli in PHP the other bits were as before
./configure –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/usr/include/mysql –with-mysqli=/usr/bin/mysql_config
Straight from the reference
Edit the Makefile and search for a line that starts with EXTRA_LIBS. It might look like this (all on one line):
EXTRA_LIBS = -lcrypt -lcrypt -lmysqlclient -lz -lresolv -lm -ldl -lnsl -lxml2 -lz -lm -lxml2 -lz -lm -lmysqlclient -lz -lcrypt -lnsl -lm -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lcrypt
Remove all duplicates, so that the line looks like this (all on one line):
EXTRA_LIBS = -lcrypt -lcrypt -lmysqlclient -lz -lresolv -lm -ldl -lnsl -lxml2
vi Makefile
Find the line that needs changing
/EXTRA_LIBS
Copy the line and paste it
YY
P
Put a # against the old line, this will comment it out
My file now looks like this
#EXTRA_LIBS = -lcrypt -lcrypt -lrt -lmysqlclient_r -lrt -lm -ldl -lnsl -lxml2 -lz -lm -lxml2 -lz -lm -lmysqlclient_r -lz -lcrypt -lnsl -lm -lssl -lcrypto -lxml2 -lz -lm -lcrypt -lxml2 -lz -lm -lxml2 -lz -lm -lxml2 -lz -lm -lcrypt
EXTRA_LIBS = -lcrypt -lrt -lmysqlclient_r -lm -ldl -lnsl -lxml2 -lz -lssl -lcrypto
NOTE that even though the first lins is shown on 2 lines it is one line in the file
make
make install
5.2.17
cp php.ini-recommended /usr/local/lib/php.ini
5.3.10
cp php.ini-production /usr/local/lib/php.ini
Now Apache needs to understand what to do with a php file, this involves editing the httpd.conf file
cd /usr/local/apache2/conf
vi httpd.conf
Make sure that the following line is included
LoadModule php5_module modules/libphp5.so
You must then add the following lines
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Whilst in this file, if you are using php the chance are that your fist page will be index.php you need to ammend the following for index.php to be called
Find the following (hint /DirectoryIndex)
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
And change it to
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
You will need to revisit this file again to setup virtual directories but we will leave this until later
Save the file and then start the web server
cd /usr/local/apache2/bin
./apachectl -k start
To test to see if php is working
echo “<?php” > /usr/local/apache2/htdocs/phpinfo.php
echo “// Show all information, defaults to INFO_ALL” >> /usr/local/apache2/htdocs/phpinfo.php
echo “phpinfo();” >> /usr/local/apache2/htdocs/phpinfo.php
echo “// Show just the module information.” >> /usr/local/apache2/htdocs/phpinfo.php
echo “// phpinfo(8) yields identical results.” >> /usr/local/apache2/htdocs/phpinfo.php
echo “phpinfo(INFO_MODULES);” >> /usr/local/apache2/htdocs/phpinfo.php
echo “?>” >> /usr/local/apache2/htdocs/phpinfo.php
cd /usr/local/apache2/htdocs/
chmod 755 phpinfo.php
Open the address of the server in web browser remembering to end in phpinfo.php. You should see a web page of information regarding the installation. If you are successful then DELETE the phpinfo.php file.
Now we want to change the user who runs the web server to apache.
groupadd apache
useradd -g apache apache
cd /usr/local
chown -R apache:apache apache2/
Change the user that will run the server in the conf file
cd /usr/local/apache2/conf
vi httpd.conf
Amend the following lines
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon
Change these lines to read
User apache
Group apache
Restart the web server
cd ..
cd bin
./apachectl restart
To install phpadmin
cd ~
cd software
tar xzvf phpMyAdmin-3.4.10.1-english.tar.gz
mv phpMyAdmin-3.4.10.1-english phpMyAdmin
cp -R phpMyAdmin /usr/local/apache2/
cd /usr/local/apache2/htdocs
ln -s /usr/local/apache2/phpMyAdmin xxxxxxxxxxxxx
Where xxxxxxxxxx is a more secured named folder
cd ..
chown -R apache:apache phpMyAdmin
cd /usr/local/apache2/phpMyAdmin
mkdir config
chown -R apache:apache config
chmod o+rw config
cp config.sample.inc.php config/config.inc.php
chmod o+rw config/config.inc.php
Navigate to the address http:/xxxxxxxx/yyyy/setup/index.php
where xxxxxxxxxx is the ip of host name and yyyy is the symbolic link created in the steps above. This will display the phpAdmin screen
You will get an error regarding not having the GZIP, BZIP and ZIP enabled, this is because we compiled PHP without these requirements. If you want the functionality you will need to recompile PHP and install it again.
./configure –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql=/usr/include/mysql –with-mysqli=/usr/bin/mysql_config –with-bz2 –with-zlib –enable-zip –enable-mbstring –with-mcrypt
Click New Server and fill in the areas that are required. This post does not go into these areas as my knowledge of phpAdmin is limited. Once the configuration file has been created, follow the instructions below
cd /usr/local/apache2/phpMyAdmin/config
mv config.inc.php ../
cd ..
chmod 400 config.inc.php
chown apache:apache config.inc.php
Navigate to http:/xxxxxxxx/yyyy/index.php
The login details are the credentials that you created for the mysql server. There are bits and pieces that need further installation to make phpAdmin work 100% but that is for another post
To install webmin
cd ~
cd software
wget http://sourceforge.net/projects/webadmin/files/webmin/1.580/webmin-1.580.tar.gz
tar xzvf webmin-1.580.tar.gz
cd webmin-1.580
./setup.sh /usr/local/webmin
Now that we have a working web server etc.. we need to lock the server down to a degreee. This is done with the creation of virtualhost in the httpd.conf file. More about how to configure VirtualHosts
The final part of the puzzle is to install and configure iptable to only allow 80,443,22,20,21 into the server and not allow any ports outbound except 22,80,443 again this is outside the scope of this post.
Hope that this helps and as always drop me a line if you spot and error or have some better suggestions.
Good luck and as I find new things out then you will be the first to know (well the second after me
)
Alistair
Create Swap Space on Amazon EC2 Image
Posted: February 4, 2012 Filed under: Amazon AWS, EC2 | Tags: Amazon AWS, EC2, rds, swapfile 2 Comments »I am creating an Oracle XE database server in Amazon, I know that Amazon has Oracle RDS but I need an inexpense solution for this particular application.
Upon downloading the oracle-xe rpm and trying to install it discovered that you need a swap file space. How therefore do you create a swap file space ?????
sudo su
dd if=/dev/zero of=/swapfile bs=1024 count=1048576
( this should give you 1024MB but in the Amazon world it registers 1023MB AAAARRRGGGHHHH !!!!!) I therefore used the following
Please note to delete a swap file use
swapoff /swapfile
rm /swapfile
dd if=/dev/zero of=/swapfile bs=1536 count=1572864
/sbin/mkswap /swapfile
/sbin/swapon /swapfile
/sbin/swapon -s
I found this on a site burried away and though I would add this to post to bolster the chances of you finding something



