deploying a php project - java

A newbie to php development looking for help in deploying a php project in Apache server.
I am wonering how to put the php project that is in MVC structure into my Apache server. Say suppose it's a java project then i would export the whole project (with libs, source files etc) as a war file and then deploy the war in the server. My question is, in what format should the php project be put in so that it is up and active running on the server.
Help on this would be really useful to have my project up and running for users. Thanks !

Short answer: Nothing such as WARs in Java or other kinds of "packaging" is needed for PHP scripts. Your server has a special directory set as document root for the web server, you simply place your files inside it (or a subdirectory in it) and you're done.
There are however multiple ways how to bring your files into that directory.

I would use GIT. Make an account to GitHub and create a repository. Look up tutorials on how to commit your files into GIT.
Git Tutorial (GitHub)
Then go to your server and set up GIT folder there and connect to your repository.
Then you will be able to do GIT PULL and update your PHP code within seconds.
OR you can do the annoying style and manually upload files one by one via FTP server.

The first option would be to use a repository, such as GitHub or Assembla. I've used both, and I'd recommend Assembla - but it depends on preferences and requirements. A repository will allow you to commit files to it on a regular basis, and keep all of your work synced together in one location. You can then set up your server to sync with your repository.
If you don't wish to have a repository, then you can simply send all of the files that construct your PHP project to a .zip file. That .zip file can then be uploaded to Apache server, unzipped, and you'll be good to go (providing you have your server configured correctly to match the needs and requirements of the application). You should only need to .zip if you're using cPanel/Plesk, for example.
Alternatively, upload via FTP using a client such as Filezilla.

Related

How does Jetty deployment on Azure App Service work?

I have a Java web app that I run on an Azure App Service instance. To deploy it, I use a Bitbucket repo with a .war file inside it. When I commit a new .war file to this repo, it is supposed to be deployed automagically by the service. However, more often than not, I have to either restart, re-deploy, or even upload the .war file via FTP for the deployment to be completed successfully.
I have a single Jetty instance residing in this service, hence my .war file is named ROOT.war. AFAIK, when uploaded to the service (whether via Bitbucket or FTP), this .war file should be unarchived into the same directory, which is /site/wwwroot/webapps. In my case, this doesn't happen. The web app works with the ROOT.war file sitting alone inside /site/wwwroot/webapps. And every once in a while, I get a ROOT folder under /site/wwwroot/webapps, with two default files index.jsp and background.png. I don't have the slightest idea what causes the ROOT folder to appear with these default files. The only clue I have is that it happened a couple of times after I changed an environment variable.
Also after the ROOT folder appears with the empty server files, the only way I can re-deploy the app is to manually delete this ROOT folder via FTP or the console provided in the portal, and only then my re-deploy request succeeds with my web app.
So, if it isn't clear enough, my question is what is going on here? I can't make anything out of the behaviors I'm facing. I feel like I'm using this Azure service blindly, and can't get to fix anything when something goes wrong. Are there any resources that may explain what happens in the background when a web app is deployed?
So, Azure API Apps are a PAAS, not IAAS service. You can access the PaaS platform by coming to yoursite.scm.azurewebsites.net, where you can browse the file system in CMD or Powershell, and you can see the running processes. This may feel like you are on a single VM, but you are not. The data you see here is replicated down into your API App instances. You can control how many instances you have through scaling your API App.
I have commonly seen your issue with deploying, then ROOT being empty(working internally to see this fixed...).
The best method that works every time for me, is to stop your API App, manually UNZIP your ROOT.war. Move the files into /ROOT/, then to start your API App.
You can simply place ROOT.war, and let the system unpack it when you turn it back on, but this can sometimes lead to that empty ROOT directory, then requiring another restart.
All of this has me moving to Spring-Boot instead. No unpacking required. Simply configure your web.config and drop the jar file.
https://learn.microsoft.com/en-us/azure/app-service-web/web-sites-java-custom-upload#springboot
I had the same problem. The solution is to call the endpoint after de deploy.
Stop the Azure App Service.
Deploy the ROOT.war artifact in the /webapps folder.
Start the Azure App Service.
Call the URL of the App Service once.
The four-step is very important and start the process that you mentioned before (the automagically deploy).
I lost a lot of time figuring out what was the problem.

How to deploy java web app without creating war file to AWS?

I've been uploading java app to AWS by extracting a war file from eclipse,
But now I've moved my code to github and,
I want to pull it from github onto my AWS server without generating a war file.
I've tried pulling it but it gives me an error. The requested resource is not available.
You can use Jenkins or other CI tool. Jenkins will fetch code from GitHub, compile it and push it to AWS. You only need to specify deploy script.
The CI enthusiast within me suggests to automate the entire thing, going as far as creating an AWS CodePipeline with 3 steps:
(I have three of these pipelines active and am very happy I created them.)
Listen to GitHub repository for changes.
Pull latest repo changes and push code to a Jenkins instance
To save money on the Jenkins instance running 24/7 you could even create AWS Lambda functions to automate the starting up and shutting down of the Jenkins server
Output Jenkins artifact (your war file) to AWS Elastic Beanstalk.
The AWS Documentation as with most services is pretty elaborate on this subject as is Jenkins'. You shouldn't have too much trouble setting this up and it'll save you a lot of time as the WAR file transfer between each step happens on the internal magically-high speed network of AWS.
It will cost some time to set up, especially if you're not that familiar with CI and this process but so very worth it to be familiar with these type of stacks.

Upload opencms project on real server

I'm working on an open source java cms that name is opencms .
it is war file that you deploy it with tomcat and when it's up you go to localhost:8080/opencms and start to configure it as you want.
my problem is that when I've done my all jobs and making a cms site with it, what I must do to upload it on a real server ?
do I have to make war file from it then upload it or just i upload it's deployed folder to server tomcat ?
and what i must do with it's database ? it's enough to export a .sql file from my local database and execute it on server database or i must do some other things ?
please help me
thanks
You need an opencms installation on your "real" server that fits the one you created your page with.
It should be possible to just copy the content of opencms webapp folder inside tomcat to the tomcat on the target machine and also transfer copies of the associated databases to the "real" server.
Personally I prefer performing a standard installation of opencms on the target machine and configuring it (remove example content, change passwords, etc.).
Then I would use the export functionality of opencms to export the content on the development machine and import it into the target opencms instance.
The complexity depends on how much changes you have applied to the default installation - if you have developed your own modules, then it might be a bit more difficult.

How to make website live? (From the point of having it as a Spring MVC project in Netbeans)

Silly question as I just started web dev. Consider that I've got the project build on Spring MVC Framework in the Netbeans (a web site). I would like to make it live.
What is the actual process of making it live considering the fact that I bought the domain and got the hosting? i.e. you upload project in the repository of hosting provider? (not sure if the question is correct, hence correct me if it's wrong)
Can I somehow connect the repository of hosting provider with my Netbeans to update my web site directly from it? (like it works f.e. with svn repository)
First of all, it's a java application that you want to host / publish, so you will need java hosting company.
You need domainname, you can buy one, or get free domainname (there's a few options, you can get free .tk domain, some hosts offer free domain with 1 year prepay as well).
Yes you can connect to your host's SVN with your Netbeans IDE. But deployment process depends on how you will set up your environment on host side. SVN is a place where you keep your source code, not a compiled java application. You can use your host's SVN server, but then still you need to compile java code and build war file which you can deploy under your java server. Some java hosting companies offer Apache Maven, which can helps in your case. Another solution is to build war locally, and upload ready app to your java host account (try to use SFTP or SCP, most of java hosting companies offer SSH access to your account, try to avoid FTP as it's pretty unsecure).

Where do I put application generated HTML reports to that they don't get removed when I deploy a new WAR file?

I have a simple web application which lets the user upload local user data and then they can generate HTML reports from that uploaded data. Once the HTML is generated, I display a link to the report which they can click on to view in their browser or they can share the link with others.
The problem is that I am currently putting the "/Upload" folder in the "WEB-INF" folder because I don't want that folder data accessible to the outside world. I am then putting the "Reports" folder in the root directory of the web application. This work fine in that I can deploy the WAR file to the their server, the user can upload the files, and then request for HTML reports to be generated. The problem is that when I send them software updates in the WAR file it deletes everyone in the /MyWebApp directory including the /Upload and /Reports folder. So then the user has to re-upload the data and they loose any of their existing reports in the "/Reports" folder.
Now I did find an answer for the /Upload folder on StackOverflow with this discussion.
Where can I put an uploading folder so that when I deploy/undeploy the site in Tomcat that folder won't be affected
But I still don't know where to put my "/Reports" folder? I thought I would have to put it in the web application context directory as I am doing now in order for the Tomcat server to serve it up as a link (e.g.: http://example.com/MyWebApp/Reports/report01.html).
The other thing to note is that this application is running on Apache Tomcat only, I don't have the request going through an Apache server. We decided to just have it running on the users local server with Tomcat because it seems easier to deploy then trying to deploy and configure both to work together. Also, there are only 2-3 people using this application per server site and with that load Tomcat seems to be doing a great job handling everything on its own. So maybe that is making the solution more difficult?
Any hep with best practices for this would be greatly appreciated.
There should be no difference between the strategy you used for placing uploaded-files on the disk with placing reports on the disk: both are files that were generated by the webapp during its deployment (forget the fact that a client uploaded the file) and need to be protected in the same way.
If you are willing to upgrade to Tomcat 7, there is a new <Context> attribute, aliases, which will allow your webapp to serve content from that directory but not delete it when the webapp is undeployed.

Categories