Storing wallet key for automatic transactions
It depends on the type of wallet you are using in the server. 
you can write your own node to publish transactions (very hard)
you can use 3rd party services like blockchain info (easy)
you can use a wallet that has an api (like bitcoin-core has json rpc) 
then you write a program that call this wallet to generate tx
it uses the build in security of the wallet