Envoy and connecting via ssh with username with capitals - php

I recently installed laravel envoy task runner, when I try to run a task with command envoy run deploy I get the following error:
GabotronES#gabriel-ubuntu-1:/var/www/dtcburger.es$ envoy run deploy
Are you sure you want to run the [echo] task? [y/N]: y
[GabotronES:206.189.X.XX]: ssh: Could not resolve hostname gabotrones:206.189.X.XX: Name or service not known
[✗] This task did not complete successfully on one of your servers.
It says it can't resolve hostname gabotrones but my ubuntu user is GabotronES, in my Envoy.blade.php I have also user GabotronES in #servers directive, is this because envoy doesn't allow username with capitals to connect via ssh?
#servers(['web' => 'GabotronES:206.189.X.XX'])
*censored my IP just in case

I don't think the capitals are the issue.
Please try this syntax:
#servers(['web' => 'GabotronES#206.189.X.XX'])
You can also try to connect directly from the command line, to check if things work as expected.

Related

PHP fails to access the docker socket via curl

My Code fails to reach the Docker Socket
$client = new GuzzleHttp\Client();
$test = $client->request('GET','http://v1.40/containers/json',[
'curl' => [CURLOPT_UNIX_SOCKET_PATH => '/var/run/docker.sock']
]);
I only get a generic cURL error 7 from that and I´ve checked that the socket is available and working inside the Container with the cURL command from the cmd. Its only when i try to connect via PHP it fails ominously and frankly im out of ideas.
So just in case someone stumbles upon this in the future and has the same or a similar problem.
Guzzle was not the problem in this case but phpfpm. I did not realize that the phpfpm workers in the official php docker image used the www-data user by default. The way I used is to change the user in the www.conf (default /usr/local/etc/php-fpm.d/www.conf in docker)
user = root
group = root
you will have to append the -R flag to the run command to allow running the workers as root.

Deployer - no tty present and no askpass program specified - How to deploy with Deployer

I have trouble deploying with Deployer 4.0.2 and I am in need for help of somebody more experienced than me in this.
I want to deploy a repository of mine to a Ubuntu 16.04 server.
I am using laravel homestead as a development environment, where I also installed deployer. From there I ssh into my remote server.
I was able to deploy my code with the root user, until I hit a RuntimeExceptionthat aborted my deployment.
Do not run Composer as root/super user! See https://getcomposer.org/root for details
That made me create another user called george, whom I gave superuser rights. I copied my public key from my local machine to a newly generated ~/.ssh/authorized_keys file, that gave me permission to access the server via ssh.
Yet when I run dep deploy with the new user:
server('production', '138.68.99.157')
->user('george')
->identityFile()
->set('deploy_path', '/var/www/test');
I get another RuntimeException:
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Now it looks like the new user george cannot access the ~/.ssh/id_rsa.pubkey. So I copy them from the root folder into my home folder and also add the public key in the Github SSH settings.
cp root/.ssh/id_rsa.pub home/george/.ssh/id_rsa.pub
cp root/.ssh/id_rsa home/george/.ssh/id_rsa
Only to get the same error as before.
In the end I had to add github to my list of authorized hosts:
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
Only to get the next RuntimeException
[RuntimeException]
sudo: no tty present and no askpass program specified
I managed to comment this code in the deploy.php
// desc('Restart PHP-FPM service');
// task('php-fpm:restart', function () {
// // The user must have rights for restart service
// // /etc/sudoers: username ALL=NOPASSWD:/bin/systemctl restart php-fpm.service
// run('sudo systemctl restart php-fpm.service');
// });
// after('deploy:symlink', 'php-fpm:restart');
to get the deployment process finally done, and now I ask myself, if the restart of php-fpm is really necessary, for me to continue debugging this deployment tool? Or can I live without it?
And if I need it, can somebody help me understand what I need it for? And maybe as a luxury also provide the solution to the RuntimeException?
Try this:
->identityFile('~/.ssh/id_rsa.pub', '~/.ssh/id_rsa', 'pass phrase')
It works great for me - no need for an askpass program.
It helps to be explicit in my experience.
As for your phpfm restart task .. I haven't seen that before. Shouldn't be needed. :)
EDIT:
That you provide a password is probably a good sign that you ought to refactor your Deployer code a bit if you keep it under source control.
I am loading site specific data from a YAML file - which I am not submitting to source control.
The first bit of my stage.yml :
# Site Configuration
# -------------
prod_1:
host: hostname
user: username
identity_file:
public_key: /home/user/.ssh/key.pub
private_key: /home/user/.ssh/key
password: "password"
stage: production
repository: https://github.com/user/repository.git
deploy_path: /var/www
app:
debug: false
stage: 'prod'
And then, in my deploy.php :
if (!file_exists (__DIR__ . '/deployer/stage/servers.yml')) {
die('Please create "' . __DIR__ . '/deployer/stage/servers.yml" before continuing.' . "\n");
}
serverList(__DIR__ . '/deployer/stage/servers.yml');
set('repository', '{{repository}}');
set('default_stage', 'production');
Notice that, when you use serverList, it replaces your server setup in deploy.php

install Laravel on share folder

We have a appserver3 over LAN, means there is folder in remote server and I just map that folder in my my compurt and suppose it got the drive letter G. now when I excute the following
php artisan migrate --package=cartalyst/sentry
but it try to install db in my localhost. But I want to db operation in appserver3. please help me
I assume you have the web server and database up on your appserver3. You could add a new set of config files for your "appserver3" machine, and make sure the db host points to the appserver3's ip address. Something like this:
app/config/appserver3/database.php:
'connections' => array(
...
'host' => 'your appserver3 ip address',
...
)
Then you can run artisan command and specify the environment:
php artisan migrate --package=cartalyst/sentry --env=appserver3

mongodb service in PHP

I'm trying to connect to mongodb in php.
There's no problem if mongodb is start in shell with mongod command.
new Mongo("mongodb://".$_host.":".$_port,true)
But when i start mongodb server as a service, i can connect with the mongo command, but i cant connect in php.
new Mongo("mongodb://".$_host.":".$_port,true)
Is there any other arguments?
I'm using the last version of mongodb and the last version of php.
Can someone help me?
What are your command line parameters for the MongoDB service? Is it possible that you've specified a different configuration than what you get by default when manually running mongod? What parameters did you use to install MongoDB as a service?
Thanks for your answer and comment, i fix it.
The problem was in the service command line , i use this command
"C:\mongodb\bin\mongod" --bind_ip 127.0.0.1 --logpath "C:\data\db\mongodb.log" --logappend --dbpath "C:\data\db" --port 27100 --install
instead of
"C:\mongodb\bin\mongod" --bind_ip myIPadress --logpath "C:\data\db\mongodb.log" --logappend --dbpath "C:\data\db" --port 27100 --install
In the php code new Mongo("mongodb://".$_host.":".$_port,true) , $host = myIPadress
That why it was working in command line and not in the php code, it must be the same IPadress, don't use localhost or something like that if you don't use a default new Mongo()

Can't connect to MongoDB through PHP

I just wanted to take a look at Mongo-DB. But i just don't get it running. I've installed it with PECL and my phpinfo() tells me that the extension is loaded, but when i try to get a connection with
$mongo = new Mongo();
I get this:
Fatal error: Uncaught exception 'MongoConnectionException' with
message ': Transport endpoint is not connected'
Anybody have the same Problem? ... Or any Idea on this?
Please don't take this the wrong way, but have you actually got the server running? Only it looks like your error relates to a failure to connect and you've made no mention of the server or where it is located (localhost on the default port for example)
any server start method, such as "/etc/init.d/mongodb start" or "service start mongodb" will fail, if a stale lock file still exists. In Ubuntu/Debian this is /var/lib/mongodb/mongod.lock. Look for this and delte it, if it exists and seems to be an old one.
check out whether server is running or not..
/etc/init.d/mongodb start
then go to
root#kannan-desktop:~# mongo
MongoDB shell version: 1.6.3
connecting to: test
>
Don't forget to change the IP in your mongod.conf if it's a new installation.
custom string looks like that
mongodb://username:password#host:port/database
First Change the Default db path by following command
$ sudo mkdir -p /data/db/
$ sudo chown id -u /data/db
and then the final command is..
$ mongod --journal
Do not close terminal until you are working with mongoDB
It works for me...
just write mongod in your terminal and will work well

Categories