I am writing a script in shell for a Wordpress website, which takes the plugins, themes and uploads and puts them on a backup-website where I usually test and break stuff.
To make it easier for me to always have the latest version on the development website, I am running this script so that I don't have to manually import export everything, everytime.
At the moment I am running:
rsync -avzhe ssh -t ${HOST_REMOTE}:${PATH_REMOTE}/plugins/ ./plugins/
rsync -avzhe ssh ./plugins/ ${HOST_TARGET}:${PATH_TARGET}/plugins/
I am wondering if there is any way I could re-write this so that it could download the files from the remote directly to the target, without having to download them locally anymore.
Thank you very much for any input relevant to the subject.
Related
I'm writing a PHP app, and our team has our servers set up so that I have to copy code onto a second server every time I edit a file. Naturally this is against the DRY concept, and simply a monotonous chore.
When I make a change to the file, and go to refresh the webpage to see the changes, both of these servers have to be updated, or else there is a chance that I will be seeing the old version on the server that hasn't been updated yet. So I'm copying/pasting/saving hundreds of times a day while I develop this app!
I'm using Eclipse Luna 4.4.1. In the Remote Systems Explorer, the system type is "SSH Only." This is the same for server 2.
I would like there to be some kind of functionality where each time I save sample.php on server 1, the same file sample.php will be automatically updated and saved with the same code on server 2. I don't want to have to do anything else other than just save the file on server 1; after doing that I'd like for the file on server 2 to be automatically updated.
Both servers are running on nginx OS.
I've been reading a lot about this here on SE, but many of the question/answers are 5+ years old, and I wonder if there is an optimal way to do this today. I don't have much experience with Java, but I'm happy to do this any way that will work. Any plugin or other way would be great.
Take a look at running rsync over ssh, and put it on a cron to run the update on a periodic interval as you desire.
Here is an example of an rsync process I run to copy database backups (type / contents of the file are mostly irrelevant here):
rsync -ar -e "ssh -l <username>" <local_path_of_files_to_watch> hostname:<target_path_where_files_land>
This is what my command looks like to rsync databases from a remote system that monitors radio traffic and records decoded messages to a daily log file:
rsync -av --remove-source-files --progress --stats -e "ssh -l stratdb" 192.168.0.23:/var/log/stratux.sqlite.*.gz /Users/stratdb/sqlite-dbs/.
If you want this process to run without having to define a password, you'll want to setup .ssh with shared keys to allow passwordless login from server 1 -> server 2 for this process (Ideally this is done from a user that has limited capabilities on both servers).
There are some continues deployment processes you could use that would do builds and copies and the like (e.g. Jenkins) if you need really robust and highly configurable solution... but if you just need to brute-force copy files from one server to another with a single easy command (ad-hoc) or automagically.. I'll investigate rsync
When I did run my web site on my old server, I launched Transmit on my Mac (OS X 10.11.6), connected to my server, Control-Click-Open the remote php file, made the fix and save. The file got updated on the server in a second. That was great to run some php/mysql/google_service test that I can't run locally.
Now I have just moved my project on an Amazon server, AWS. Every time I need to run a test (for example on the S3_Bucket, that I can't run locally), or modify a variable, change a flag... I have to do it on my local php/html/java/css/apis project, zip it, upload it via the Elastic Beanstalk panel, wait about half a minute, then run it. I have found no way to edit a single file in an easy way (Open, Write, Save) as I did before through Transmit. I can't go ahead this way. It's wasting my time.
Do you know any better way to develop/test/run my project on AWS?
Have you considered using Docker?
https://aws.amazon.com/about-aws/whats-new/2015/04/aws-elastic-beanstalk-cli-supports-local-development-and-testing-for-docker-containers/
Or use MAMP?
https://www.mamp.info/en/
In my application i have to deploy my application on client system.
So is there any way to run my php application without installing xampp...
Because the client should access it as a readymade app without installing anything...
This is the description of my project...
We have to develop an application where the client will have our application he will connect to remote server
Then he will download the data from remote server...
Then he uses that downloaded data using that app
Here my requirement is the user may not have the knowledge of installing the xampp...
So is there any way to run the application in user system just by copying some files
U may suggest me a one click solution (like using installer which will include installation of xampp and copying my data into user system)
I really dont want to use any external software to render no database PHP pages so I did some digging and found that if you run php -S localhost:port in your working directory you basically start a server there.
S is a capital S and not s
I'm a big fan of server2go. I've used it to deploy PHP applications on CD/DVD. It comes with MySQL and is relatively easy to configure. I've even replaced their splash screen with my own so no one knows I'm using it. It's donationware, but I was impressed enough to donate:
server2go-web
With this application, you don't have to install all that other stuff. It's self-contained in this executable and directory.
EDIT: To clarify, server2go does not install anything on the client machine. It runs as an exe only when you specifically want it to. When you click on the .exe file, it launches your PHP application in a browser window, then you can right-click on the server2go icon in the system tray and close it when you're done.
EDIT2: One gotcha: if you want to save data to the MySQL db on the client machine, you'll need to copy serve2go to a directory on the client machine or run it on a writable USB stick. If you run this application off CD/DVD, it will be able to read data from the database, but not write.
The better way is to use PHP Desktop Application. It will allow you to run your PHP Script like a Desktop application and you don't need to install Xampp or any other web server to run.
PHP Desktop Application
After downloading the .Zip file unzips it to any folder that you like. After unzipping, Go to the folder, and there you can see a folder "www". Delete all the files contained in it and move all your php script to it.
Once you moved all your files into it. Run the .Exe file named "PHP desktop-chrome"
It will open your PHP Script really like a Desktop Application.
This script doesn't require any kind of server software like Xampp, Wamp, Etc installed in your PC.
You can either host the php application or install the application into one system as server and call in client system using the ip of the server system like the following
http://**ip address/php file name
If you don't want your client to install anything then you should create Client Server architecture, there is no another way.
PHP Application are not meant to be deployed on multiple clients. It's meant to be deployed on a webserver (your own server with sth. like IIS or XAMPP) so the clients can access it via their browser and doesn't have to install anything more.
If you want to deploy applications on the client pc's i recommened an other programming language like Java or C/C++.
I simply used xampp zip version so i copied my application into htdocs and the whole xampp is given to the customer so he simply running the application eazily without installation.
Make sure you have installed php from https://www.php.net/downloads.php. Once installed add it to path. Lastly type php -S localhost:8000
PHP needs to be installed on the machine it is running at in order to make sure it works. Since the app may grow and may require extension installing, PHP upgrading over time, hosting this on a client machine is not a very easy task in terms of management. You may want to host your project on a server and write a small bash script sending requests to the API.
If, for some reason you cannot host this on a server where your clients would send requests via the bash scripts, then you may want to install only PHP. If it does not need to listen to HTTP requests, then you do not need a server, you can just implement the PHP application and create a bash script so the user will be able to run it from the UI of their operating system.
No, you need some kind of server - Wamp, Xampp, etc.
You can host it online, and then he can just browse it from his PC.
i have developed in-house software for hotel management system using PHP/MYSQL. Our Client wants Software in .exe format and used in desktop. i use various softwares for .exe conversion but it only support php but i want's to connect with MySQL Database. Please anyone can help to create .exe conversion with MySQL Database..
Download PHP Desktop Chrome.
Copy all your code from site directory to Phpdesktopchrome/www directory.
Run Phpdesktopchrome.exe, it will execute like a browser with PHP compiler.
Download Innosetup Software for make exe file.
Install and run Innosetup and select Phpdesktop chrome files to create a EXE file in Option.
Install wampserver in client system with database import.
Enjoy.
There are many compliers available on web by which you can create EXE in PHP.
This program runs through dos and windows only... :) so this is good news for windows user
First Download zip from Here.
Now unzip it and open Command prompt and then go to its directory location.
Start -> run then type ‘cmd’
Use the “cd..” command to change directory.
Place PHP script to be compiled next to bamcompile.exe place it in same directory.
In the cmd prompt, at that directory, type:
bamcompile test.php
variations:
bamcompile -c test.php gives compression.
-e:something.dll allows a DLL to be embedded
Ready made examples are given in Zipped files which you have downloaded,just try it out.
Another application wapache is also there but i dont know much about it.
DOWNLOAD WAMP server from wampserver.com.
its very good for offline use server for desktop, then just copy and paste you script abd .sql file into it. and you are Done.
If your client using highspeed interenet then they can connect the server to online. but they need super computer for more traffic, another option is LAN.
If the program is for office use and no need to connect a lot of computer and internet then use LAN and WAMP.
------ Another possible you can use --------
Install WAMP then copy then .exe file "click start button > all program > and paste into startup folder". server will run automatic windows OS start or restart but it take 2-3 min. (green light)
go to wamp folder > www > make a folder for your program then paste your script.
open any browser then in address bar type "localhost or 127.0.0.1 (localhost IP for offline)" , scroll down and you will see "Your Projects" and under of this you will see your folder which you had create into wamp server > www folder. click on it and here you gooooo....
Now your client can do work with your script. Bookmark it and also create a shortcut into desktop for direct use.
Hope this may help you. thank you.
If you are getting any problem to do this work, then email me here - (krishnabiker#yahoo.com)
I think you should just convince your client not to use a .exe installer. It makes no sense.
You could have an installer that installs a local webserver and a local MySQL, and then opens a web browser and browses the local webserver. This would work, but it means your application runs on only one machine, and can't be used by two people.
On the other hand, you could install an application that talks to a central MySQL database, hosted on the LAN. But then why not install the entire application (webserver, MySQL etc) on the LAN, and have the clients access it across the LAN as a web application? Still no reason for a local install.
I would suggest:
See if you can persuade your client to move to an entirely web-hosted solution. Emphasize how easy updates are - from one central location, not from each machine; or
See if you client won't be happy with a .exe that installs a link to a URL (on the LAN).
VERY SHORT ANSWER: NOT POSSIBLE
Tell your client that it is a client-server application not a desktop app.
One idea is to have portable PHP/MYSQL/APACHE that can be stored in a CD or used and create an autorun fro it..
Tell your client you can do better than that, you can create a batch file for his use!
Then create a program.bat file with one line that runs the php (should be something like "php ").
:)
We need to bundle your project files in MSI ( windows installer ) along with PHP frameworks, MySQL and Apache.
Everything can be included in a single MSI file or you can keep server part in one MSI (PHP framework+Apache framework+ MySQL) and your Project file along with Yiiframework in another MSI.
I already made server part MSI in order to create one of my previous web project. In that project i had to configure Mysql DB (my.ini) and Apache configuration file (.conf). It worked fine.
For a desktop application I recommend that you change your database settings (if you can) and switch to SQLite3 DB. They are portable files and does not need a database server to run.
Use http://www.usbwebserver.com/ and from a stick or an CD/DVD you will be able to run your application. It is a portable version similar to W
Im running a file host thats grown beyond the capacity of a single server, and I need to implement multiple server storage of files. I'd like to do this as cheap as possible, so those fancy mass storage methods are out of the question. I simply want to move a file thats uploaded by the user to the "gateway" server, which hosts all the http and mysql, to one of the media servers. It can either be done at the end of the user's request, or via cron every couple of minutes.
At this point the only method Im truly familiar with, is using ftp_put php function, and simply ftping the file to a different server, but I've had problems with this method in the past, especially for larger files, and a lot of the files that will be getting transferred will be over 100mb.
Can anyone suggest a good solution for this? Preferably Im looking for a purely software solution... hopefully nothing more than a php/bash script.
One method that requires no programmatic setup, and is quite secure is to mount a folder from the other server, and use php to save to that directory like you would normally.
You don't have to use sshfs, there are a bunch of other ways to provide the same solution. I would use sshfs for this situation as it works across ssh, and therefore is secure and relatively easy to setup.
To achieve this (using sshfs):
Install sshfs
Mount a ssfs file to a folder accessable to php
Use a php script to store the files within the sshfs mount, and therefore on the other server.
Another method is to setup an rsync command between the two using crontab.
you can write a bash script that run in cron
and use command line like scp or sftp or rsync
example :
[bash]# scp filename alice#galaxy.example.com:/home/alice
Copy "filename" into alice's home directory on the remote galaxy.example.com server
Use cron, a bash script, and rsync.
cron: "Cron is a time-based job scheduler in Unix-like computer operating systems. 'cron' is short for 'chronograph'."
bash: "Bash is a free software Unix shell written for the GNU Project."
rsync: "rsync is a software application for Unix systems which synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate."
In summary, place the rsync command in a bash script and get cron to run it at regular intervals.
See here for some examples: