Setting php environment variable on windows with vagrant - php

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

Related

Execute export command in windows

Hello I am trying to execute this command:
export PATH="$HOME/.composer/vendor/bin:$PATH"
in windows.
Please, check these notes
Note: For the local PHP environment I am using a Mac and Valet because it automatically sets up everything. If you are on Windows, you should consider Homestead or some flavor of a virtual machine.

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

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.

Vagrant phpmyadmin php show as plain text issue

I'm having some issues with phpmyadmin that i installed on a virtual machine using vagrant. I downloaded the vagrant file from puphpet it's a Centos with php, mysql, nodejs, and apache.
Default installation works fine, already edited my vhost file on my local machine to access centos /var/www folder and php it's working there, but phpmyadmin folder it's showing plain text rather than executing the php code of the index.php, the weird thing is that only phpmyadmin is not executing php code.
My local setup is Mac OS X el capitan, my vhost cents.dev point to /var/www folder.
Couldn't find any solution online.
I installed phpmyadmin using yum command, then made a link in my /var/www folder, that didn't work, the moved the phpmyadmin folder to /var/www and still doesn't work
phpinfo is:
Linux local.puphpet 2.6.32-504.8.1.el6.x86_64
Server API FPM/FastCGI
PHP 5.6.15 (cli)
PhpMyAdmin uses shorttags for php (<? instead of <?php).
Edit your php.ini to support that.
short_open_tag = On
And then restart your webserver
sudo service apache2 restart

PHPStorm CLI debugging on Vagrant instance

I'm trying to get PHPStorm to work with Xdebug to use with PHP scripts (CLI, not web pages!) on a vagrant instance on the same machine as PHPStorm is running on.
In their docs they say this:
To tell the PhpStorm which path mapping configuration should be used
for a connection from certain machine, the value of the PHP_IDE_CONFIG
environment variable should be set to serverName=SomeName, where
SomeName is the name of the server configured in Settings /
Preferences | Languages & Frameworks | PHP | Servers:
Windows: set PHP_IDE_CONFIG="serverName=SomeName" Linux / Mac OS X:
export PHP_IDE_CONFIG="serverName=SomeName"
However, it's unclear where I'm supposed to set this-- is it set somewhere in the PHPStorm app? Is it set as part of the bash profile in the vagrant box? In the vagrant xdebug conf?
A per LazyOne comment, PhpStorm since v8 supports debugging CLI scripts over SSH directly (via Remote PHP Interpreters)-- there you do not need to do anything like that. But you may need to setup SFTP deployment and use that when creating Remote PHP Interpreter (it depends: in some cases IDE cannot use/interpret path mappings from vagrant config file.
See:
https://confluence.jetbrains.com/display/PhpStorm/Remote+debugging+in+PhpStorm+via+SSH+tunnel
https://confluence.jetbrains.com/display/PhpStorm/Working+with+Remote+PHP+Interpreters+in+PhpStorm

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