SSH to wamp server apache / php from Linux Sub-System - php

I am trying to ssh to my Wamp Server 3.0.6 installation on Windows 10 from Linux SubSystem but it is asking me for a password. Trying to do a mysqldump of all databases but I don't have anymore an apache console so need to use this one. What password would this contain. I tried blank password, my own linux subsystem password but it's not that one.
Linux subsystem

You will not be able to SSH to the WAMP installation. SSH is something available from within the OS (not normally in Windows but in Linux). So on your Linux machine you have a SSH server installed and this allows you to connect to it via SSH.
What you want to do, is use the MySQL client on the Linux machine to access the MySQL server that is running on the Windows Machine.
For this you firstly need to ensure that the Windows machine has port 3306 open in the firewall and that the MySQL server has a user like 'user'#'%' or 'user'#'linux.machine.ip'.
Then on the Linux machine you can do:
mysqldump -u user -p -h windows.machine.ip database > backup.sql
That being said, it's likely going to be easier for you to run this command on the Windows machine:
mysqldump -u root -p database > backup.sql
I have not used WAMP in years but the MySQL client software is in something like wamp/bin/mysql, look for mysqldump.exe and from this folder can run the above command in command prompt.
As you'd not need to configure remote access to the MySQL server from within Windows. You can then just SFTP into the Linux box and upload the file or SCP to copy the file from Windows to Linux.
Regarding the default password for your MySQL install, it should be root with no password but bear in mind that the MySQL server needs a user account with remote access.
Also, if you're running that Linux box in a VM on the Windows box, check out Samba shares as you could share the Linux file system with the Windows machine, would make it easy to copy things back and fourth.

Related

Wrong Path of Mysql in Xampp

I am using Mysql for long time via xampp software and it is working fine. Now i installed Mysql software, While configuring Mysql software i give port 3307, to run it independently from Mysql in Xampp which is using 3306. But it is not working , I got following error when i run xampp I got screen with following error saying
MySQL Service detected with wrong path
Change XAMPP MySQL and Control Panel settings or
Uninstall/disable the other service manually first
Found Path: "C:\Program Files\MySQL\MySQL Server 5.1\bin\mysqld" --defaults- file="C:\Program Files\MySQL\MySQL Server 5.1\my.ini" MySQL
Expected Path: c:\xampp\mysql\bin\mysqld.exe --defaults-file=c:\xampp\mysql\bin\my.ini mysql
Simple if you using windows Go to Administrative cmd and type the following command
sc delete MySQL
Try with windows command prompt with administrative mode
sc delete MySQL .
from above commands

Setting php environment variable on windows with vagrant

i'm trying to run "php artisan" comands on Windows, but the system returns an error that php variable path isn't set.
The problem is that i don't have php installed directly on the Windows system, but it is installed on the vagrant box.
Any ideas how to set the windows php environment variable to the vagrant boxe's php?
thanks
If you use Vagrant, you need to set all variables there. To do this, you need to use SSH. You can try built-in vagrant ssh command or any SSH client for Windows (WinSCP for example, connect and then press Ctrl+T for WinSCP Terminal).
Default credentials for vagrant ssh are:
Host: 127.0.0.1
Login: vagrant
Password: vagrant
Port: 2222

How to run mysql commands from terminal on a MAMP install?

I just installed mamp (xampp) from the mamp.info page and it is working on my mac (both apache, php, phpmyadmin, and mysql). The only problem is when i try to run
mysql -u root -p
Which connects to mamp from the mac os terminal, i get a command error. I have installed and uninstalled mamp and xampp for mac multiple times to no avail.
I am following this tutorial; http://www.raywenderlich.com/2941/how-to-write-a-simple-phpmysql-web-service-for-an-ios-app and i can't get past a certain part because i don't want to use php admin, and i think it'd be cool to use it from the terminal.
My question; how do i configure mamp or xampp for mac to work from the terminal?
Put this at the end of your .bash_profile script (create it if it doesn't already exist):
export PATH=$PATH:/Applications/MAMP/Library/bin

SSH using NetBeans to Ubuntu

I want to edit a website hosted on Ubuntu 12.04 Server from Windows 8.1 through NetBeans 7.3.1 using SSH
I tried this but getting this error.
I can successfully SSH to that Ubuntu machine through other PCs.
This issue is not related to NetBeans. Host Name ubuntu provided is not a valid hostname.
Try running this command on Command Prompt (cmd):
ping ubuntu
It will most likely return with this error message:
Ping request could not find host ubuntu. Please check the name and try again.
It works on other PCs you mentioned in the question because:
They have the host in their hosts file (C:\Windows\System32\drivers\etc\hosts). E.g:
192.168.0.16 ubuntu
They are using different DNS servers
You can get the IP address of the Ubuntu machine by logging into it and getting the IP address from the response of the following command:
ifconfig
You can update your hosts file using the IP.

How to connect remote Linux box through PHP in windows environment

I'm on a Windows XP machine, with Wamp installed. Currently, I am using putty to connect my remote Linux boxes.
I want to execute Linux commands through php shell_exec() method (cp, ls, ...).
Does anybody know how to connect my Linux box first and then run those commands in a Windows environment?
Any advice's would be highly appreciated...
You can't run Linux commands in Windows.
You can run them over SSH, using putty. It seems you have that running.
You can forward the connection over ssh. Look in the putty screen, go to Connection > SSH > Tunnels.
Then you add a tunnel:
source port: 1234
destination port: localhost:80
type is Local
So you open Internet Explorer, type in the addres bar: http://localhost:1234 the port 1234 is then forwarded to the port 80 on the remote linux pc.
You can also forward it to the WAMP by setting
destination port: *ip of the wamp server*:80
Then you can acces the Windows pc from outside the network, as long as putty is running.
It sounds like you want a PHP script on Windows to run SSH commands on a remote Linux server. For this, see the PHP SSH2 extension.
Bindings to the libssh2 library which provide access to resources
(shell, remote exec, tunneling, file transfer) on a remote machine
using a secure cryptographic transport.
This will allow you to connect to the Linux server via SSH and execute commands on the remove server (cp, ls, etc.). Here's some sample code:
$connection = ssh2_connect('shell.example.com', 22);
ssh2_auth_password($connection, 'username', 'password');
$stream = ssh2_exec($connection, 'hostname');
echo "Output: " . stream_get_contents($stream);
It's worth noting that this probably isn't the safest or most reliable way to go about this task.
I don't think you can execute linux commands on a windows machine.
You might want to consider using OpenSSH for Windows
and skip the php.
But you will get you a Windows Shell. C:\\> and no ls or cp, but otherwise full control.
You could also get experimental and run a Virtual machine with linux and share your windows drive with it.
remote server linux - - ssh - - > local virtual linux - - - shared folder - - > windows
You could either:
Install CYGWIN
Install SSH2 extension for PHP
There is an extended SSH2 class I use, which can be found here: SSH2 with Exception Handling.

Categories