Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Installing new Strato server
02-14-2015, 09:28 PM,
#1
Installing new Strato server
With this thread I want to log the things I do when installing/upgrading my site to a new server. There are several reasons to do so, like wanting a better performance, wanting lower price, wanting more resources.

In general the following steps I want to take:
- Installing server
- Setting up the server with all necessary stuff
- Testing the server from my own notebook
- Moving the domains to the new server
- decomissioning the old server

For each step I will start a new thread under this topic.
Reply
02-14-2015, 09:54 PM,
#2
Step 1 : install server
Step 1: install new server

For this I use the Strato portal. In there you can log in. The I will log in on my own server.
This can be done with the host mailed to me when it was constructed and the password SMSed to me.

First: I want to have Ubuntu 14.04 LTS 64bit + Plesk 12.0
What was installed was the version without Plesk, so I had to reinstall.
What is installed can be verified in the "Serverconfiguration, under Reinstall".

It is a good praktice to log in as root and set the password to some very strong password.

So:
$ ssh root@<h....>.stratoserver.net
$ passwd
and set the password

Next go to plesk to log in there as wel:

https://h....stratoserver.net:8443

The initial root password is here needed as wel.
In the plesk panel there is a possibility to set the new password.
Do so and log in as well.


What I want to do next is to disable login etc. from other networks than my own.

In Plesk, under "Server management", "Tools and settings", in the list "Tools and Resources" I go to the Filewall.
I will modify the settings to as follows:

Disable all except:
All incoming from all:
www server
SMTP server
POP3 server
IMAP server
Mail password change server
System policy for outgoing traffic
All incoming from my own IP address:
SSH server
PLESK administrative interface


Then apply changes. (Plesk administrative interface can be in the all, should be done the first time, to verify things are working and allowing you still plesk-access when needed)
Reply
02-14-2015, 10:09 PM, (This post was last modified: 02-24-2015, 05:26 AM by aart.)
#3
Step 2: guard scripts
The next thing I do is set up mailing differences on the server script. This is done to catch unauthorized changes.

ssh as root.

mkdir check
cd check
put this code in the file:
Code:
#!/bin/sh
cd /root/check
touch previous

find /var/www -wholename '*statistics*' -prune -o -type f -exec ls -l --time-style=+%Y%m%d_%H%M%S "{}" \; | \
grep -v _httpd.include | \
grep -v /var/www/webalizer > current
find /etc/. -type f -exec ls -l --time-style=+%Y%m%d_%H%M%S "{}" \; >> current
find /var/spool/. -type f -exec ls -l --time-style=+%Y%m%d_%H%M%S "{}" \; >> current
chmod 400 current
cmp previous current
if [ $? = 0 ]
then
  echo Same
else
  (
   echo Subject: Differences on server `hostname`
   echo ""
   echo "Verschillen gevonden"
   diff previous current
  ) | /usr/lib/sendmail -v webmaster@digdas.net
fi
mv current previous

Save this and add it to crontab. (once an hour is sufficient)
Reply
02-21-2015, 06:57 AM, (This post was last modified: 02-25-2015, 06:49 AM by aart.)
#4
Step 3: JBoss
Next I am installing / copying JBoss

For this I first set up mysql on the old server, to open up for the new server. This step includes setting the firewall connections open for port 3306 only, and making sure the accounts I am using on the new server have database permission. The first can be done with plesk,. the latter with myphpadmin. The new user is added.

Then I copy the complete contents of the jboss-user (where jboss is running) to the new server.
The next step is to get an oracle jdk on the host (copy oracle and place it)

The shell-scripts of the jboss user to stop and start need to be adapted to have the latest jdk as JAVA_HOME.

Also the datasources of the new server are changed not to point to localhost but to the old machine.

After this steps JBoss should be able to run and to connect to the database.
Reply
02-22-2015, 01:27 AM, (This post was last modified: 02-25-2015, 06:50 AM by aart.)
#5
Step 4: Create domains
Next step: Create domains.

In plesk I am generating a new client. This client will be used for my digdas-websites.

Next to that I will generate a client for all Remedial Teaching related sites.
So in Plesk: create client. I am starting without a domain. This is added later in the domain administration.

Plesk will warn that the domains are not connected to this server. That is right, they are connected to the old server. That will be modified later.
Reply
02-22-2015, 05:19 AM, (This post was last modified: 02-25-2015, 06:50 AM by aart.)
#6
Step 5: Connecting apache to jboss
Apache now needs to connect to jboss, so that the URLs get connected correctly.

I did this on one of the websites I created.

First step is to enable mod_proxy_ajp. This is done in the plesk-configuration of the webserver. Just enable this module.

Next step is to configure the connection:

The following file: /var/www/vhosts/system/digdasbook.nl/conf/vhost.conf
with the following content:
Code:
ProxyPass /bitcoin ajp://localhost:8009/bitcoin
The data is also to be placed in vhost_ssl.conf

Then the config needs to be processed:
Code:
$ /usr/local/psa/admin/bin/httpdmng --reconfigure-all
$ service apache2 restart
Now jboss is shown for the url: http://www.digdasbook.nl/bitcoin

As this works, I will create a script which does this automatically from a definition-file

I have a config file which contains:
[port#] [name of war file] [site(s) to have this war on]
Eg.
Code:
8009 portal  digdas* others*

To process this I have created the following script:
Code:
#!/bin/sh

# Step 1: clear old "new"-files
cat jboss | while read port war line
do
  for siteX in $line
   do
    for site in `ls -d /var/www/vhosts/system/$siteX/conf 2> /dev/null`
     do
      if [ -f "$site/vhost.new" ]
       then
        rm "$site/vhost.new"
       fi
     done
   done
done
# Step 2: Fill "new" files
cat jboss | while read port war line
do
  for siteX in $line
   do
    for site in `ls -d /var/www/vhosts/system/$siteX/conf 2> /dev/null`
     do
      echo "ProxyPass /$war ajp://localhost:$port/$war" >> "$site/vhost.new"
     done
   done
done
# Step 3: replace config files with new file
cat jboss | while read port war line
do
  for siteX in $line
   do
    for site in `ls -d /var/www/vhosts/system/$siteX/conf 2> /dev/null`
     do
      if [ -f "$site/vhost.new" ]
       then
        cp "$site/vhost.new" "$site/vhost.conf"
        mv "$site/vhost.new" "$site/vhost_ssl.conf"
       fi
     done
   done
done
# Step 4: instruct Apache to work with the new config
/usr/local/psa/admin/bin/httpdmng --reconfigure-all

Now it is a matter of changing the file jboss - containing the war-configuration and running the process_Jboss.sh script.
Reply
02-24-2015, 04:13 AM, (This post was last modified: 02-25-2015, 06:51 AM by aart.)
#7
Step 6: moving over the databases
The databases

The simple part is to copy the database. For this on the old server I have opened the SSH-port for the new server.
Then I issue the command:

Code:
passwd=secret
ssh jboss@h2200964.stratoserver.net mysqldump -u jboss -p$passwd jboss | mysql -u jboss -p$passwd jboss

This will copy the database to the new server. I also change the datasources in jboss to point to the new database.
This all is done on the new server.

Also I will open mysql in the firewall to allow the old server.

As the database is switched over, the jboss-datasource files on the old server are changed to connect to the new server's mysql.

As jboss on both the old and the new server are pointing to the new database, switching over the domain can be done (for jboss) anytime now.
Reply
02-24-2015, 05:41 AM, (This post was last modified: 02-25-2015, 06:51 AM by aart.)
#8
Step 7: copying and setting up owncloud
For owncloud I want to create a new user and store the data in this user itself.

So I create a user-directory "owncloud" and copy the complete tree of owncloud onto that from the old server. This includes the data directory (which is the directory with changing files)

Code:
cd /home/owncloud
mkdir owncloud
cd owncloud
ssh root@h2200964.stratoserver.net 'cd /var/www/vhosts/digdascloud.nl/httpdocs/owncloud ; tar -cvf - .' | tar -xvf -

Next I will move the data directory apart from the php-scripts etc.
Code:
mv /home/owncloud/owncloud/data /home/owncloud/data

Also the database needs to be copied:
Code:
passwd=secret
ssh jboss@h2200964.stratoserver.net mysqldump -u owncloud -p$passwd owncloud | mysql -u owncloud -p$passwd owncloud

The following need to be changed:
- for the domain the path /home/owncloud/ should be added to the php.ini of the website.
- Follow symbolic links should be added to the apache server
- The data directory should be editable by the webserver username.

When this all is in place, owncloud will run.

Do not forget to install libreoffice
Code:
apt-get install libreoffice


When the server's address will be changed over, the following script should be run:
Code:
passwd=secret
ssh jboss@h2200964.stratoserver.net mysqldump -u owncloud -p$passwd owncloud | mysql -u owncloud -p$passwd owncloud
cd /home/owncloud
ssh root@h2200964.stratoserver.net 'cd /var/www/vhosts/digdascloud.nl/httpdocs/owncloud ; tar -cvf - data' | tar -xvf -
chown -R webserver:group data

Now is a good idea to test the upgrade of owncloud to a new version.
I am creating a copy with tar, so this upgrade can be done later again.
Code:
tar -cvf owncloud.tar owncloud
Reply
02-25-2015, 06:01 AM, (This post was last modified: 02-25-2015, 06:52 AM by aart.)
#9
Step 8: Copy Serendipity
For serendipity I also want to create a new user and store the data in this user itself.

So I create a user-directory "serendipity" and copy the complete tree of serendipity onto that from the old server. This includes the data directory (which is the directory with changing files)

Code:
cd /home/serendipity
mkdir serendipity
cd serendipity
ssh root@h2200964.stratoserver.net 'cd /var/www/vhosts/digdascloud.nl/httpdocs/serendipity ; tar -cvf - .' | tar -xvf -

Next I will move the uploads directory apart from the php-scripts etc.
Code:
mv /home/serendipity/serendipity/uploads /home/serendipity/uploads
ln -s /home/serendipity/uploads /home/serendipity/serendipity

Also the database needs to be copied:
Code:
passwd=secret
ssh jboss@h2200964.stratoserver.net mysqldump -u serendipity -p$passwd serendipity | mysql -u serendipity -p$passwd serendipity

The following need to be changed:
- for the domain the path /home/serendipity/ should be added to the php.ini of the website.
- Follow symbolic links should be added to the apache server
- The uploads directory should be editable by the webserver username.

The directory needs to be changed in the database:
Code:
echo "
UPDATE 'serendipity_config' SET 'value'='/home/serendipity/serendipity/' WHERE value='/var/www/vhosts/digdascloud.nl/httpdocs/kiki/' " | mysql -u serendipity -p serendipity

When this all is in place, serendipity will run.



When the server's address will be changed over, the following script should be run:
Code:
passwd=secret
ssh jboss@h2200964.stratoserver.net mysqldump -u serendipity -p$passwd serendipity | mysql -u serendipity -p$passwd serendipity
cd /home/serendipity
ssh root@h2200964.stratoserver.net 'cd /var/www/vhosts/digdascloud.nl/httpdocs/serendipity ; tar -cvf - data' | tar -xvf -
chown -R webserver:group data
mv /home/serendipity/serendipity/uploads /home/serendipity/uploads
ln -s /home/serendipity/uploads /home/serendipity/serendipity

echo "
UPDATE 'serendipity_config' SET 'value'='/home/serendipity/serendipity/' WHERE value='/var/www/vhosts/digdascloud.nl/httpdocs/kiki/' " | mysql -u serendipity -p serendipity
Reply
02-25-2015, 06:47 AM, (This post was last modified: 02-26-2015, 05:47 AM by aart.)
#10
Step 9 : Installing/copying myBB
For myBB I also want to create a new user and store the data in this user itself.

So I create a user-directory "myBB" and copy the complete tree of myBB onto that from the old server.
Code:
cd /home/myBB
mkdir myBB
cd myBB
ssh root@h2200964.stratoserver.net 'cd /var/www/vhosts/digdascloud.nl/httpdocs/myBB ; tar -cvf - .' | tar -xvf -


Also the database needs to be copied:
Code:
passwd=secret
ssh jboss@h2200964.stratoserver.net mysqldump -u mybb -p$passwd mybb | mysql -u mybb -p$passwd mybb

The following need to be changed:
- for the domain the path /home/myBB/ should be added to the php.ini of the website.
- Follow symbolic links should be added to the apache server


When this all is in place, myBB will run.



When the server's address will be changed over, the following script should be run:
Code:
passwd=secret
ssh jboss@h2200964.stratoserver.net mysqldump -u mybb -p$passwd mybb | mysql -u mybb -p$passwd mybb
cd /home/myBB
if [ -d myBB ]
then
  rm -rf myBB
fi
mkdir myBB
cd myBB
ssh root@h2200964.stratoserver.net 'cd /var/www/vhosts/digdascloud.nl/httpdocs/myBB ; tar -cvf - .' | tar -xvf -
cd ..
chown -R webserver:group myBB
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)