📜 ⬆️ ⬇️

Shared on shared-hosting: pain and suffering or a simple routine?

Short for those in a hurry


The FTP Deployment : utility is written in php, takes as a parameter the path to the configuration and uploads files to a remote server, rather quickly and well.

Long and detailed for those who are interested.


We all love cool and convenient deployment methods using capistrano, rsync or, at worst, git pull. And if you need to upload projects to shared-hosting?

Yes, some providers provide ssh and git. But, frankly, they are few.
')
One day, I suddenly realized that I was used to good things, and I hate uploading projects via (S) FTP: no file was flooded; need to remember where configs are; This folder should not be laid out at all; here it is necessary to check the rights. I think many will easily continue this list.

I also have to say that I take great pleasure in using symbolic links to minimize space (and automatically update the code). A small shell script creates the context of a new project, in which there are already libraries, a kernel, statics and docroot with htaccess. It remains for me to put the correct configs and set everything up “as per the client”.

In the old days, I did all this on my local system, and then, using FileZilla or GnomeCommander, I poured it on the hosting. Now I switched to a small dedicated server, and I had to find a solution. I wanted ready and simple - and I found it!

Using FTP Deployment, the calculation of a long, dreary occupation turns into one team. Well, in fact, in two - nobody canceled the test launch :).

First step: in the project folder (or in any convenient place) you need to put the utility config. Ini or php - your choice. Let me translate into Russian comments in the example.

[my site] ;
; FTP-
remote = ftp://user:secretpassword@ftp.example.com/directory

; FTP
passiveMode = yes

; (, /var/www/production/project_path/)
local = .

; ? ( -t --test)
test = no

;
ignore = "
.git*
project.pp[jx]
/deployment.*
/log
temp/*
!temp/.htaccess
"
; ? ( -- )
allowDelete = yes

; ,
before[] = http://example.com/deployment.php?before

; ,
afterUpload[] = http://example.com/deployment.php?afterUpload

; ,
after[] = http://example.com/deployment.php?after

; ,
purge[] = temp/cache

; ( -- *.js *.css)
preprocess = no

; ,
deploymentFile = .deployment


In general, everything is quite obvious and understandable. The readme clarifies some ambiguities.

For example, in ignored files, pp [jx] means both ppj and ppx. Exclamation point - exception from the previous line. In the example, everything that is in temp is not loaded. But we create the folder and temp / .htaccess in it we load.

And finally, about the preprocessor. The utility can compress css using YUI Compressor, and js - using Google Closure Compiler. Both tools in the distribution, but require Java.

When the config is ready, you can conduct a test run.
 php deployment.php deployment.ini -t 

The utility will tell you what it is going to do and with what files. If you doubt the list of ignored - the most it.
image

If everything is good, you can deploy:
 php deployment.php deployment.ini 

image

At first, read carefully what a test run will write to you. For obvious reasons, you cannot upload ftp-deployment.ini to the server. Well, and generally, someone and config.php.bak in projects hangs out ...

I really liked the utility, I use it with pleasure and advise friends. If you know convenient alternatives in other languages ​​- I will be grateful.

Source: https://habr.com/ru/post/279555/


All Articles