Deploying a Symfony2 App onto Azure Web hosting - php

what my aim here is to, upload my project that is basically a controller returning a twig template its as simple as that, i just cant figure out how to get it on the hosting.
I have been using symfony for a few months now, so still new to it all. and all the hosting/details stuff is new too me.
Whats throwing me off is my understanding of a hosting web/ folder
and how azures its wwwroot/
i used this website
http://symfony.com/doc/current/cookbook/deployment/azure-website.html
but i'm finding it rather difficult to follow it..
does anyone have any better sites with more clear steps on how to deploy? i've read a lot about a public_html folder but i've never heard/used it before
If someone could explain how the www.domain.com/web/app.php works that would help, i know that, that is the file that is called, but not too sure if i need to say call this file "app.php" or if its done kinda like the way a standard websites looks for 'index.php'
any kinda help or pointers would be much appreciated here as i'm kinda lost

Generally, we can build our project and test on local, then deploy on Azure Web Apps via Git or FTP tools.
Here is my test steps:
Build Symfony project on local, referring Using the Symfony full-stack framework
Login to Azure preview Portal, click NEW=> Web+Mobile=> Marketplace, in Web Apps section click Web app + MySQL, then click create.
When finishing creating Web app service, we can find MySQL connection string in Settings=>Application settings=>Connection strings click show connection string.
then click Set up continuous deployment in Deployment section. Select Local Git Repository for the source. Then in Essentials section, we can find there added a Git URL. Copy it.
In your local symfony project, make sure your Symfony repository has a .gitignore file at its root directory with at least the following contents:
/app/bootstrap.php.cache
/app/cache/*
/app/config/parameters.yml
/app/logs/*
!app/cache/.gitkeep
!app/logs/.gitkeep
/app/SymfonyRequirements.php
/build/
/vendor/
/bin/
/composer.phar
/web/app_dev.php
/web/bundles/
/web/config.php
run the following commands to init git repo and first-time push to Azure:
`
git init
git add .
git commit -m "initial commit"
git remote add azure [URL for remote repository]
git push azure master
Sign on Kudu console of your Azure web site, at https://<your-website-name>.scm.azurewebsites.net/DebugConsole, run following commands:
cd site\wwwroot
curl -sS https://getcomposer.org/installer | php
php composer.phar install
Now visit http://<your-website-name>.azurewebsites.net/web/app.php in browser, we should see the project.
Now we need to configure URL rewrite to remove /web/app.php pattern of the url. Add a file named web.config with the content shown in Deploying to Microsoft Azure Website Cloud in the root directory which is /site/wwwroot on Azure. Click restart on Azure portal, now we can visit the site at http://<your-website-name>.azurewebsites.net .
By the way, for deploying a PHP-MySQL application on Azure Web Apps, we can get more information at Create a PHP-MySQL web app in Azure App Service and deploy using Git. And specifically for Symfony project, the Symfony guide is still useful, and we can ignore section Enabling the PHP intl Extension .

If you can't change the name of the "wwwroot" directory to "web", you have to change the configuration of symfony to use "wwwroot" instead.
Have a look at this page!
I think the easiest solution is the one with the symlink:
Some shared hosts have a public_html web directory root. Renaming your web directory from web to public_html is one way to make your Symfony project work on your shared host. Another way is to deploy your application to a directory outside of your web root, delete your public_html directory, and then replace it with a symbolic link to the web in your project.

Related

How to push new local dependencies to shared hosting with Laravel?

My website is running smoothly with Laravel in a sub-domain, but now I have added a new dependency https://github.com/PHPOffice/PHPExcel to my local project using composer require phpoffice/phpspreadsheet.
The code is already working fine in my local environment, but now I need to push my new changes to the website.
Pushing the controllers, routes, views, etc it's easy, but how do I push the dependency?
I have full access to the cPanel
I can create SSH keys
The project is running in a sub-domain
I'm using Visual Studio Code
I have generated a private and public key for SSH
I have initially deployed my Laravel project to the server using FTP Filezilla
For what I have read so far, I should be using SSH with PuTTY, but if I could use an extension in Visual Studio Code, would be great.
Composer stores all the imported libraries in the /vendor folder. When you push your local copy of the website up, it will push up the vendor folder and you'll be set.
If you're working on a remote server and you need to still download the dependencies, run
php composer.phar update
That will download the dependencies for the project. You'll need to run it from the command line (ssh) and be in the website directory.
Some companies don't allow ssh access to the server. In that case, you can run php composer.phar update on your local machine, assuming you have a php runtime install (WAMP, XXAMP, ect). Then when you push or copy your code to your server, the libraries will be included.
Well I can create SSH keys but don't have access to login with them. With that said I follow the tutorial here https://laraveldaily.com/laravel-and-shared-hosting-working-with-ftp-and-phpmyadmin/ that teaches how to use FTP to upload/update the application.

Installing Snipe-IT on Azure Web Apps

Has anyone here been able to install Snipe-IT (Open source asset management: https://snipe-it.readme.io/docs) on Azure Web Apps?
I know it is possible to install it on an Azure VM, since I've done that, but I would prefer it to be on a Web App so we keep everything simple and slightly more secure.
I have been able to download it from GitHub, and it then says that the document root is incorrect (It has to be \wwwroot\public instead of \wwwroot). So, I go ahead and change the document root to the public, but then the page returns a 500 error. I see that I need to install Composer, so I install the extension for that, but nothing changes. I know the document root works correctly because I am able to place a test file in the public directory and it works fine. It is just the actual Snipe-IT install that gets screwed up.
Here's how I did it:
Run the command composer install under \wwwroot folder to install dependencies.
Change the document root by setting the virtual application path for the web app.
Edit the Snipe-IT configuration file (.env file) to configure the database credentials, app key and so on.
Restart the app service.
Finally, It worked for me.

Git Clone Laravel Website just displays files and directories

I'm still really new to Git version control and Laravel. But I have gotten so far, and I'm not sure now where I am going wrong.
I set up VirtualBox and Vagrant on my local windows machine and installed homestead successfully. I have managed to get my Laravel website (it's only one page at the moment as I learn things) working correctly, it displays the header and the footer and the images load and everything. So that's all good.
So now, I have my Laravel website set up within my virtual vagrant server. On this server, the directory for my website is:
/home/vagrant/Code/sites/public_html
No when I cd to that directory, I ran the following:
git init
get remote add origin https://user#repo/user/publichtml.git
git add *
git commit -m "Initial Commit"
git push -u origin master
(I've substituted user#repo instead of the real URL)
All went through successfully. Great. So now on my live server I ran the following:
cd /home/sites/public_html
git init
git clone https://user#repo/user/publichtml.git
Which again, worked fine. It downloaded all the files into the public_html directory which is great. So then I go to visit the website and this is what I get:
The only explanation for this happening is maybe I need to install something on the server before I clone these files to it. I guess the files in the Laravel folder won't run by themselves? Do I need to install composer and laravel on the server or something? If so, how do I do that, and why don't they run on their own?
I cannot see a .htaccess or index.php in the root directory so I am not sure how it runs anyway.
You should install Laravel using composer instead.
composer create-project laravel/laravel mysite
You should also point the document root on your web server to laravels "/public" folder, making the framework code reside outside of the document root. That's good for security (no one can access any framework code, like your configs etc directly).
You will then find the .htaccess-file in the /public folder.
Please read the Laravel documentation about the different but recommended ways to install Laravel.
Btw, doesn't homestead use Nginx instead of Apache? In that case, .htaccess isn't even used. Please refer to the Laravel documentation again regarding homestead.
You need to redirect traffic to public/index.php instructions for this are webserver dependent.

deploy phpBB on openshift

I'm in a trouble trying to install phpBB on openshift.
I have created a php5.3 cartridge with PostgreSQL: I unpack phpbb on a folder of my app, I push the change, then I run the installation form the browser.
The forum installation is successful.
In the end I need to delete the "install" folder in order to enable the forum.
I tried it on my standalone wampp server and it works.
So I delete it in my repo, and I commit and push the change.
When the app restarts it automatically tries to go back to the installation: everything is broken.
It seems the push breaks the configuration on the server side.
I also have tried to change the name of the directory using ssh connection, and move the install directory name: this is uneffective.
What's the problem here?
The problem is that if you deploy the phpBB package as downloaded from official website app the files will go on app-deployments with are not persistent on git changes and can not be pull to local. You can try using the OpenShift quickdeply version of phpBB (https://github.com/openshift-quickstart/phpbb-example) that deploys the files to app-root/data (I think :S) and this reamins untouched on git changes.
The "install" folder is at app-root/runtime/repo/php

How do I deploy a PHP site to Azure websites from a subdirectory of a Git repository

I have a Git repository which contains an ASP.net application and a PHP application, each in its own subdirectory under the root of the Git repository. I would like to create two websites in Azure websites and deploy each of these applications to one of those websites. I can deploy the ASP.net application with no problem by setting the project variable in the settings panel on the website properties to the path to the CS project file. However I cannot successfully get the PHP site to deploy. I have tried setting the WWWroot directory, but Azure is still trying to build the csproj file even though it is not specified by the variable on that website, nor is it present in the root directory of the Git repository. How can I make the PHP site deploy correctly, without needing to put it in its own repository?
Figured it out: I just set the "Project" attribute in app settings to the directory name of the PHP application, relative to the root of the repo.
In case it helps, I used to do this on a number of my projects, but have since migrated to a new strategy.
Now, I create a git repository for my overall project and repositories for each of the "sub projects" within it. For my Tweet Monkey project, for instance, I have http://github.com/codefoster/tweetmonkey as well as http://github.com/codefoster/tweetmonkey-raspi, http://github.com/codefoster/tweetmonkey-edison, and the website at http://github.com/codefoster/tweetmonkey.io.
Then I link the sub projects into the main project using submodules by typing the following at the command prompt...
git submodule add http://github.com/codefoster/tweetmonkey-raspi
git submodule add http://github.com/codefoster/tweetmonkey-edison
git submodule add http://github.com/codefoster/tweetmonkey.io
That way I can deploy the website to Azure using CI by simply tying up to the tweetmonkey.io repository, but I can also clone the entire project or point other people to the entire project using the http://github.com/codefoster/tweetmonkey link.
Hope that helps.

Categories