Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I m thinking about right deployment strategy for PHP (or any) web application.
I have versioned code (git) which contains source codes like LESS, non minified JavaScript etc.
As ideal steps I see this ones:
Build app to /build directory - including compile LESS, minify JavaScript and others. In build directory will be everything ready for deployment.
Run other necessary scripts like tests etc. in /build directory
After this steps I'm a bit confused what to do next.
Whole /build directory should be copied to staging/production server, but before I was actually building app I've used to copy only files which changed from last Git commit. Copying all files seems to be inefficient for me. However versioning /build directory doesn't seem to be right thing as well.
Other possibility is to create /build directory but it seems to be too messy to have built and non built files together and all versioned.
How do you build and deploy web applications?
If you use Jenkins/Hudson CI then you can use different publish plugins which may be executed after successful build. Most of plugins allow you to say exactly what you want to be published and over what protocol.
Basically you run full build on Jenkins, then deliver your build files and artifacts to production server.
Look at Publish Over SSH or Publish Over FTP. Both plugins allow you to configure "Transfer Set" and if you uncheck "Clean remote" checkbox then plugins will only send out files that are different from your production host.
PS: I made an assumption that you use CI server of some sort given tag "continuous-integration"
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I'm developing a website, and im doing it on its final destination domain, not on localhost, and its almost finished.
Now I've come to the point where I'm beginning to get worried about what I do when users start using the site and some problems occur, or maybe I want to add a features to the site.
Is there any best practices which will allow be to minimize risks ruinin website and customer UX during updates, how to do it correctly?
If your website is small and easy:
Create a development domain/subdomain
Code and test there
Record all database structure changes (do database changes on a db copy)
Record your actions you use to test your website
As soon as you are ready to release a new version there are two options:
Update db replica and switch domains
Turn main domain off, update code and db, turn on
If website is not that easy, there should be local development, testing, staging and production environments set up independendly. You dev, then you test what you did, then you copy and install your code on real data before pushing it live on production.
To track changes and easily deploy new version to each of environments there are many tools connected with version control systems like git
And there is a good answer on how to use dev-test-stage-production environments with git: git with development, staging and production branches
First of all you have to work on localhost, while developing any new feature, of fixing a bug.
I recommend you also to use GIT branches, so you can create a new branch to add feature of fix a bug.
After finish use GIT merge with your website master branch
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
What is the best way to deploy PHP Website with Bower components and Gulp tasks?
Is it good to install npm on production server for run Gulp tasks?
If not, is it good to commit minified files (CSS, JavaScript, compressed images) in Git?
If not, is it good to use rsync for prepare and (push) deploy project to remote server and then use post deploy script for set up chmods, update database etc?
Maybe there is better way to do that?
The safest way to make sure everything works on your production server is by deploying first to a staging environment. This could be very well the same server, just not accessible for everyone.
As an example: we have a website: www.website.com, which is the live environment.
Assume we have another subdomain called staging.website.com which points to the same server but has its own DocumentRoot (more on DocumentRoot) but it is protected by some form of authentication (or an IP firewall, in our company's case. If it is not authorized to see staging, it will just point to the www.website.com, very convenient).
You would first deploy to the staging, there run all the build scripts (Composer, Gulp, minify), test out if everything still works. If it does, you can just easily point the DocumentRoot of the live domain to the staging directory and it's done.
As for committing minified files, no. You should commit the original files and the builder scripts. The minified scripts will all be built every time you deploy your application.
You could use Rsync, but like I suggested you should build your application (chmod, database etc) during deployment. Not afterwards.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I'm fairly new to web development and I have only published one website before. With that website I only used some PHP and without framework. Now, I'm planning on using the laravel framework for my next, bigger, website. I'm wondering if there are differences between publishing a website when using a PHP framework? If so, what are the major differences and where can I read about it (googling has not helped me)?
You have countless options. Here are some I am aware of:
1. FTP'ing
Basically, you could just publish your site/app by FTP'ing it up to your server. The biggest issue will be the Database-changes. Here, the main influence is, whether are you able to run migrations or not? You would at least have to have ssh-access to your server with the required prerequisites installed. Otherwise, you would need to keep track of the changes in some other way, and change the db manually (which is not an good option IMO).
2. Automated deployments
There are server-deployment automation-tools, the one i know is capistrano. You can write scripts which do the deployment. These tools are also capable of running migrations, if you tell them to do so, but you would need to have ssh-access for that. Google will tell you the rest, here is a good tutorial.
2.1. Push-to-deploy
If you use SCM for your "bigger project" (which i would highly recommend), you could use push-to deploy technologies. This approarch basically uses Git-Hooks for triggering deployment-scripts. Deeployer could take care of that for you, if you do not want to develop your push-to-deploy-solution from scratch. Other alternatives are Rocketeer (Open Source) or DeployHQ (Paid)
2.2. Using laravel-taylored hosting/deployment/server-management services
Services like laravel-forge or envoyer offer zero-downtime automated deployments. I guess they are also based on push to deploy anyway. If you want to learn more about them, i recommend watching the corresponding laracasts-series (Forge, Envoyer). Be aware that they are not free.
I hope this overview gets you started. Happy deploying!
There is no difference between publishing a plain PHP website and one with a framework. Simple FTP up all your files and it will work, just remember to upload the framework files also.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 9 years ago.
Improve this question
Hello fellow Programmers,
I am still a relatively new programmer and have recently gotten my first on-campus programming position. I am the sole dev responsible for 8 domains as well as 3 small sized PHP web apps.
The campus has its web environment divided into staging and live servers -- we develop on the staging via SFTP and then push the updates to the live server through a web GUI.
I use Sublime Text 2 and the Sublime SFTP plugin currently for all my dev work (its my preferred editor). If I am just making an edit to a page I'll open that individual file via the ftp browser. If I am working on the PHP web app projects, I have the app directory mapped to a local folder so that when I save locally the file is auto-uploaded through Sublime SFTP.
I feel like this workflow is slow and sub-optimal. How can I improve my workflow for working with remote content? I'd love to set up a local environment on my machine as that would eliminate the constant SFTP upload/download, but as I said there are many sites and the space required for a local copy of the entire domain would be quite large and complex; not to mention keeping it updated with whatever the latest on the staging server is would be a nightmare.
Anyone know how I can improve my general web dev workflow from what I've described? I'd really like to cut out constantly editing over FTP but I'm not sure where to start other than ripping the entire directory and dumping it into XAMP.
Are you using source code control? If not, you should. I suggest using Git, for example hosted on Github.
For a simple setup like this you don't need to use any special deployment tools; you can also use Git for deployment.
Developing directly on the staging server is not a great idea. Try to set up a development environment environment on your laptop.
You can push from your development machine to Github. Then then on either staging or the live server you can connect via ssh and pull from Github.
This allows you you to use all the power of Git to create branches and tags and to rollback to an earlier version if you make a mistake.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I want to start automating more of my web development process so I'm looking for a build system. I write mostly PHP apps on Mac OS X and deploy Linux servers over FTP. A lot of my clients have basic hosting providers so shell access to their servers is typically not available, however remote MySQL access is usually present. Here is what I want to do with a build system:
When Building:
Lint JavaScript Files
Validate CSS Files
Validate HTML Files
Minify and concatenate JS and CSS files
Verify PHP Syntax
Set Debug/Production flags
When Deploying
Checkout latest version from SVN
Run build process
Upload files to server via FTP
Run SQL scripts on remote DB
I realize this is a lot of work to automate but I think it would be worth it. So what is the best way to start down this path? Is there a system that can handle builds and deploys, or should I search for separate solutions? What systems would you recommend?
All you ask for can be done with Phing
Phing is a deployment framework written in PHP and modeled after Apache Ant. It comes with a large set of ready-to-use deployment tasks, including database deployment, remote file transfers and VCS connectivity. If you are missing functionality, you can extend Phing with standard PHP.
Phing provides the following features:
Simple XML buildfiles
Rich set of provided tasks
Easily extendable via PHP classes
Platform-independent: works on UNIX, Windows, MacOSX
No required external dependencies
Built & optimized for ZendEngine2/PHP5
You might also want to have a look to Hudson, an extensible continuous integration server.
The supported features are available here.
Among the other languages, it supported PHP. This article presents some nice plugins for PHP. The article is also suggesting Phing for the build. See Gordon's answer for details.