简体   繁体   中英

How to set up apt to use it for web app deployment

If I want to use apt packages for deploying my web app to different linux servers, what steps should I take? Starting from a PHP/MySQL application, I would like to be able to install it as a package like this:

apt-get update
apt-get install mywebapp-package

I suppose I have to set up a repository somewhere and add my packages to it, but how does this work? How to create the package itself? What do I have to do to make any server find my repository? Some googling only turned up confusing information, maybe I'm looking for the wrong buzzwords. Any help would be much appreciated!

Here's how to create an apt-package https://askubuntu.com/questions/27715/create-a-deb-package-from-scripts-or-binaries

It's really quite straightforward ... within your app folder there's a debian subfolder ... the ./debian/install file contains a really straightforward map of files to final locations

# debian/install must contain the list of scripts to install 
# as well as the target directory
echo myscript.sh usr/bin > debian/install 

You can use the makefile to create installation and post installation tasks. If you've never compiled ac/c++ program with make before ... basically in the app folder you run "./configure" and then "make" or "make install" to compile / unpackage the program ... dh_make has a slightly different process and some defaults but it's a pretty similar workflow ... The following is a really simple makefile from the GNU Make Reference

objects = main.o kbd.o command.o display.o \
               insert.o search.o files.o utils.o

     edit : $(objects)
             cc -o edit $(objects)
     main.o : main.c defs.h
             cc -c main.c
     kbd.o : kbd.c defs.h command.h
             cc -c kbd.c
     command.o : command.c defs.h command.h
             cc -c command.c
     display.o : display.c defs.h buffer.h
             cc -c display.c
     insert.o : insert.c defs.h buffer.h
             cc -c insert.c
     search.o : search.c defs.h buffer.h
             cc -c search.c
     files.o : files.c defs.h buffer.h command.h
             cc -c files.c
     utils.o : utils.c defs.h
             cc -c utils.c
     clean :
             rm edit $(objects)

Basically the default "make" task compiles the program edit ... and the dependencies are automatically detected from the filenames in this struct

For a webapp here's a makefile from an OSS project that includes pulling from Github http://build.shr-project.org/Makefile

Basically if you work on the project and put all your install tasks into a makefile ... and have the "make" default task unpackage your app and install the apache / nginx vhost and restart / reload the relevant server when done ... then apt is a totally viable way to handle it ... there's a lot of programs out there to manage apt packages simultaneously on hundreds of systems ... https://serverfault.com/questions/79093/managing-upgrades-on-hundreds-of-debian-servers

Canonical/Ubuntu's Landscape is a great tool for this type of thing ... I have used it before on a platform of about 20 servers ... not too sure of the specifics of setting up your own upstream repository and signing the key etc so apt can manage the package fully but I'm sure it's pretty straightforward once you've got your dpkg going

Debconf / apt offers a pretty good use case for many types of apps ... however if it's an app that's in continuous deployment and you have to keep making upgrades (rule of thumb for me is if you make an upgrade more than once a week or 5x month) ... then you may be better off with a continuous deployment tool ... both Capistrano and Fabric are excellent (used Cap, with multi-stage extension ... it's great, Fabric I've only heard great things) ... but I still wouldn't trust Cap on hundreds of Debian servers ... it's really all about the scale of your project ... above say 10 or maybe 20 servers cap is just too slow and ponderous to really manage deployments well (IMHO, obviously anything can be done by anyone, and I have not really studied this enough, but both Ruby Rake and Capistrano etc are DAMN SLOW and unreliable compared to Gnu Make and debconf, especially out in the wild)

Specifically with respect to general server automation, I would suggest you check out Puppet and Chef , both of which are pretty viable looking tools. Not used either but all our admin scripts are in Ruby and definitely Chef's knife tool is unbelievably handy for configuring servers in a scripted fashion

I would suggest using something like Capistrano or Fabric to deploy your application instead of apt-get. These tools are made for deploying applications and are able to deploy to multiple servers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM