I have several servers - backend, frontend and api.
To deploy the code on the servers I use Rocketeer.
I use multiple servers for one connection:
'connections' => array(
'production' => array(
'servers' => array(
array(
'host' => 'xxx.xxx.xxx.xxx', // backend
'username' => 'admin',
'password' => 'xxxxxx',
'key' => '',
'keyphrase' => '',
),
array(
'host' => 'xxx.xxx.xxx.xxx', // api
'username' => 'admin',
'password' => 'xxxxxx',
'key' => '',
'keyphrase' => '',
),
array(
'host' => 'xxx.xxx.xxx.xxx', // frontend
'username' => 'admin',
'password' => 'xxxxxx',
'key' => '',
'keyphrase' => '',
),
),
),
).
For each server performs its tasks.
To determine the current connection, I use the following code in hooks.php
$connection = $task->getConnection();
$server = $connection->connections->getServer();
$credentials = $connection->connections->getServerCredentials($connection->connections->getConnection(), $server);
switch($credentials['host']){
case 'xxx.xxx.xxx.xxx':
$task->runForCurrentRelease('...');
break;
}
The data are uploaded to servers sequentially.
After deploying to last server I can't execute command on previous servers.
How can I execute commands on different servers after deploying? (for example: restart nginx, restart memcached etc.)
I believe this is what you're looking for: http://rocketeer.autopergamene.eu/#/docs/docs/II-Concepts/Events
You should be able to create your own listener for each set of commands.
Related
Initially, I started to develop a web application using Zend Framework 2 and Doctrine2 with MySQL but the customer wants that the database would be Oracle. So, I have to change the database from MySQL to Oracle.
To do that, I have modified my doctrine.local.php file from this version
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' =>'Doctrine\DBAL\Driver\PDOMySql\Driver',
'params' => array(
'host' => 'localhost',
'port' => '3306',
'user' => 'user_gnsys',
'password' => '******',
'dbname' => 'gnsys',
),
'doctrine_type_mappings' => array(
'enum'=>'string'
)
),
)
)
);
To this other version ...
return array(
'doctrine' => array(
'connection' => array(
'orm_default' => array(
'driverClass' => 'Doctrine\DBAL\Driver\OCI8\Driver',
'params' => array(
'host' => 'localhost',
'port' => '1521',
'dbname' => 'GNSYS',
'driver' => 'oci8',
'user' => 'c##gnsys',
'password' => '********',
'servicename' => 'demo31',
),
'doctrine_type_mappings' => array(
'enum'=>'string'
)
),
)
)
);
Next, I try to validate my schema using the next command:
josecarlos#R2D2:~/Workspace/Web/gnsys$ php public/index.php orm:validate-schema
And I've got the next exit ...
How can I remove all these "Notice" that I've got on the exit? Have I forget to update another file?
I fixed the problem installing oci8 library.
Is it possible to make an SSL encrypted connection via ZF2 to my MySql Server?
And if yes, how is it possible?
I can't find anything for ZF2 PDO SSL connection on the web.
return array(
'db' => array(
'adapters' => array(
// The first (default) database connection
'zf2' => array(
'driver' => 'pdo',
'dsn' => 'mysql:dbname=zf2;host=sandbox-db-vm',
'username' => 'root',
'password' => 'password',
),
// Now the second database connection
'zf2ssl' => array(
'driver' => 'pdo',
'dsn' => 'mysql:dbname=zf2;host=sandbox-db-vm',
'username' => 'ssl_user',
'password' => 'ssl_test',
PDO::MYSQL_ATTR_SSL_KEY => '/etc/mysql-ssl/client-key.pem',
PDO::MYSQL_ATTR_SSL_CERT => '/etc/mysql-ssl/client-cert.pem',
PDO::MYSQL_ATTR_SSL_CA => '/etc/mysql-ssl/ca-cert.pem'
),
),
),
'service_manager' => array(
// Let's make sure our adapters get instantiated
'abstract_factories' => array(
'Zend\Db\Adapter\AdapterAbstractServiceFactory',
),
),
);
I'm using FuelPHP and I can't set up my database so it would work. I know that i'm using right information but i'm not sure if I put it in right place.
<?php
return array(
'default' => array(
'connection' => array(
'dsn' => 'mysql:host=modernt#moderntalking.lt;dbname=modernt',
'username' => 'modernt',
'password' => 'pass',
),
),
);
This is my db.php in APP/config/db.php
Environment configurations are merged, and the environment wins.
So if you have ./app/config/db.php containing return array('a'); and you'll have ./app/config/development/db.php containing return array('b');, then after reading your config, you'll end up with "b".
So if you use environment based config (like DB does by default), only add configuration to the global file that is truely global, otherwise it gets overwritten in the merge.
Check this
'dsn' => 'mysql:host=moderntalking.lt;dbname=modernt',
// a MySQL driver configuration
'development' => array(
'type' => 'mysqli',
'connection' => array(
'hostname' => 'localhost',
'port' => '3306',
'database' => 'fuel_db',
'username' => 'your_username',
'password' => 'y0uR_p#ssW0rd',
'persistent' => false,
'compress' => false,
),
'identifier' => '`',
'table_prefix' => '',
'charset' => 'utf8',
'enable_cache' => true,
'profiling' => false,
'readonly' => false,
),
// a PDO driver configuration, using PostgreSQL
'production' => array(
'type' => 'pdo',
'connection' => array(
'dsn' => 'pgsql:host=localhost;dbname=fuel_db',
'username' => 'your_username',
'password' => 'y0uR_p#ssW0rd',
'persistent' => false,
'compress' => false,
),
'identifier' => '"',
'table_prefix' => '',
'charset' => 'utf8',
'enable_cache' => true,
'profiling' => false,
'readonly' => array('slave1', 'slave2', 'slave3'),
),
'slave1' => array(
// configuration of the first production readonly slave db
),
'slave2' => array(
// configuration of the second production readonly slave db
),
'slave3' => array(
// configuration of the third production readonly slave db
),
Basic procedure of setup FuelPHP..may be its help you .Thank you
First, check your environment configuration in app/bootstrap.php:
/**
* Your environment. Can be set to any of the following:
*
* Fuel::DEVELOPMENT
* Fuel::TEST
* Fuel::STAGING
* Fuel::PRODUCTION
*/
Fuel::$env = (isset($_SERVER['FUEL_ENV']) ? $_SERVER['FUEL_ENV'] : Fuel::DEVELOPMENT);
Then modify the db.php file accordingly (app/development/db.php, app/production/db.php, app/staging/db.php, app/test/db.php)
when i try connecting to my sql server database from my zf2 application as shown below,
return array(
'db' => array(
'driver' => 'Pdo',
'dsn' => 'sqlsrv:dbname=album;hostname=192.168.0.20',
'username' => 'user',
'password' => 'pass',
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
),
),
'service_manager' => array(
'factories' => array(
'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
),
),
);
I get this error,
File:
/usr/local/zend/apache2/htdocs/zf2-tutorial/vendor/zendframework/zendframework/library/Zend/Db/Adapter/Driver/Pdo/Connection.php:289
Message:
Connect Error: could not find driver
Am i missing something here? Or rather this does not work at all on the linux oriented machines ?
Try taking out this line: "// PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''".
Your connection say you are trying to connect to MSSQL and not MySQL.
return array(
'db' => array(
'driver' => 'Pdo',
'dsn' => 'sqlsrv:dbname=album;hostname=192.168.0.20',
'username' => 'user',
'password' => 'pass',
'driver_options' => array(
// PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES \'UTF8\''
),
),
'service_manager' => array(
'factories' => array(
'Zend\Db\Adapter\Adapter' => 'Zend\Db\Adapter\AdapterServiceFactory',
),
),
);
I always prep it like this without trouble, using dist files to set the right connection params as you work through deployment:
local config file
'database' => array(
'connection' => array(
'mysql_master' => array(
'driver' => 'Pdo_Mysql',
'host' => 'host',
'dbname' => 'analytics',
'username' => 'user',
'password' => 'pass',
'charset' => 'UTF8',
'driver_options' => array(
PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'UTF8'",
),
),
),
),
Then in my Module.php, I define such a factory (in the getServiceConfig array):
'Zend\Db\Adapter\Adapter' => function ($sm){
$config = $sm->get('config');
$dbParams = $config['database']['config']['mysql_master'];
$adapter = new \Zend\Db\Adapter\Adapter($dbParams);
return $adapter;
},
Hope this helps. If this doesn't work, something else is going on.. let me know, I can help.
Cheers.
Alex
The problem is that you don't have the necessary driver installed. I had the same problem with postgres, and this solved it for me:
apt-get install php5-pgsql
However, I am not 100% sure what driver must be installed to make Sql Server work. I did read that it's no longer supported. See this: PHP PDO to MS SQL Server on Ubuntu Server. In a nutshell, your best bet is to rather use:
sudo apt-get install php5-sybase
and then connection string:
"dblib:host=sever;dbname=dbname"
From what I gather, that should connect you to a Sql Server database, but again, I can't gaurantee this because I don't have a setup to test it with. Hope that helps...
I hope this helps you some... I'm currently following along to the Zend Framework 2 skeleton application guide. My database parameters needed to be passed in the following way:
'db' => array(
'driver' => 'SQLSRV',
'hostname' => 'SqlServerName',
'Database' => 'SqlDatabaseName',
'uid' => 'UsertoConnectwith',
'pwd' => 'Passwordofusertoconnectwith'
),
I'm trying to setup my fuelphp on ubuntu12, nginx in a development environment.
Everything was working for me except when I try to do php oil refine migrate.
I was faced with the following error message:
Error - invalid data source name in COREPATH/classes/database/pdo/connection.php on line 94
My development/db.php:
return array(
'default' => array(
'connection' => array(
'dsn' => 'mysql:host=localhost;dbname=fuel_intro',
'username' => 'root',
'password' => '',
),
),
);
I searched the Internet and fuelphp docs, and still no luck.
Any help will be appreciated.
It seems you're doing database configuration incorrectly. It shouldn't be 'host:localhost', it should be like 'hostname'=>'localhost'. And please use mysql or PDO instead of mysql... (because mysql_* functions are deprecated.
It should be something like:
'default' => array(
'type' => 'mysqli',
'connection' => array(
'hostname' => 'localhost',
'port' => '3306',
'database' => 'fuel_db',
'username' => 'your_username',
'password' => 'y0uR_p#ssW0rd',
'persistent' => false,
'compress' => false,
),
'identifier' => '`',
'table_prefix' => '',
'charset' => 'utf8',
'enable_cache' => true,
'profiling' => false,
),
Take a look at:
http://fuelphp.com/docs/classes/database/introduction.html for further information.