How to access my website's PHP files using Windows Azure WebJobs? - php

I have a website hosted on Azure.
My website files are stored in wwwroot. I'm using Azure WebJobs to schedule some tasks. This WebJob is a simple PHP file. It needs to access my websites files.
For the purpose of this discussion, let's say I want to edit my index.php or images/ folder which is located in the website root.
My WebJob runs from this location: C:\DWASFiles\Sites\<sitename>\Temp\jobs\triggered\<jobname>\kjsx2sne.7sa\script.php
How can I access my website's files? Where are they located? I tried to access C:\DWASFiles\Sites\<sitename>\. However I'm getting a Permission denied error in PHP.
Any help will be highly appreciated. Thanks.

As mentioned in this stackoverflow post, the path for the root of an Azure Website is (usually) D:\home\site\wwwroot

Related

Limit PHP to run only in the actual folder and subfolders

I have several websites hosted in the same public_html folder of my Linux server.
I want that each folder cannot access the other folders, but only include some specific files.
Here is my server structure:
-> public_html
---> site1 folder
---> site2 folder
---> site3 folder
---> common scripts folder
If for example an hacker breaks site2 I need he cannot list the content of the public_html folder or access and run scripts from the other folders.
But in the same time I also need that for example site2 is able to include and run some specific files included in the "common scripts" folder.
Is it possible to achieve this just with a htaccess rule?
Thanks for the help.
no you can not achieve this just with a htaccess rule
it all depends on php handler, if it is dso or cgi then you can not isolate websites, a simple php shell will be able to access all websites and their data.
FCGI, suPHP or PHP-FPM can be used to run php securely with separate UID for each website.
you can also check chroot
First of all, you cannot achieve this through htaccess.
because if a hacker breaks into a site, then that hacker can have control over the complete server space where the current user-account(the account which hacker pass-through. ex: www user account) have access and permissions.
If you need a complete concrete solution, then create multiple users for your vps server and define access rules and permissions for each users and let their sites deployed into corresponding users space like
/home/user1/sites/site1
.
.
/home/user1/sites/site10
/home/user2/sites/site1
This above scenario is simple like a server being virtually splitted and sold to multiple users.
Ex: buying a shared hosting space from godaddy or hostgator
where godaddy virtually separates their server and sell them to multiple users.
each user can view and access their own space only and cannot access other users space eventhough they both reside in the same cloud server

Direct deployment PHP files on OpenShift

Is it possible to deploy php files on Openshift directly? (That is, not via git).
Most of my php files are single page files and I'm looking for a way to SFTP directly into Openshift.
I am able to login via Filezilla, but when I try to transfer files into directories like app-deployment or app-root etc, the file gets deleted.
Openshift folder structure:
So, how can I upload PHP files directly?
After many trials, I found that its actually possible.
Inside this folder: app-roots/repo/myfile.php
OpenShift has a few blog posts on the topic:
Using FileZilla and SFTP on Windows with OpenShift
Getting started with SFTP and OpenShift (Using Netbeans)

Edit a file outside the web root

I have developed a python desktop application and application itself having setup page to change some configurations in the application and it is saved as a configuration file.
Now I need do to give web interface to change those configurations by using web browser remotely. But I need to change the same configuration file.
I can’t access any file outside the web root, So My first question is how can I edit that file which is located outside the web root.
more info : for web application I use LAMP stack and desktop application is python based.
someone suggest me to use CGI, Second question : Is that possible, if it is possible how I can I do it?
Probably by bind mounts (assuming Linux), so that the file is in it's original location as well as in the web root.
Or by priviledge separation. The web root sends a query to some worker job, that has access to all the needed files.

Sharing same code accross different web applications

I have 106 PHP files present in folder. This folder is included (copied the folder in application folder) in all the web-application, which I have develop but the problem is, if I implement any change in code than I have to replicate that change in all the applications.
Is there any way through which I can share this folder in all web-application or domains which are hosted on same server?
I have tried using outside htdocs folder but things does not worked as I thought.
Kindly Guide.
Yes you can (assumed you have an linux server), if your domains are stored within the same server you can place your php files outside the html of one of them and then use something like this
include ("/home/user/domain/folder/file.php");
to include your php into another one
example
mydomainhost.com has the folder php with the 106 files
in your testdomain.com you include
include ("/home/user/mydomainhost.com/php/file.php");
user = your webserver account name
hope this helps you

Setting up Yii on Shared Server

I wish to use a PHP Framework such as Yii, however, it seems to set this up I need access to a terminal or console. Unfortunately my only access to the server is via an FTP client as it's shared hosting.
Does this rule Yii out as a framework?
all you need to do is
1 - have a copy of yii framework folder
2 - generate a new yiic webapp folder
3 - upload both folders, the framework folder can go to some hidden place yoursite.com/wawa/framework/yii, and you can just upload the files in your webapp folder to yoursite.com/
4 - edit the index.php in your generated web app, so it know where your framework/yii folder is. than you are set
5 - just make different copy of your webapp folder, so you don't need to generate them if you dont want to. just use different names, wont make a difference, as long as the webapp index.php knows where your framework folder is, than it will work
According to this post you can generated all files on your computer and then just upload the files to your shared hosting.
You only need a terminal for developing on your local server (it isn't a good idea to develop directly on a shared server). To use it on a shared server just upload it.
In the strict sense you don't need a terminal. You could write your files yourself. The yiic program only creates a couple of php files.
I am first in Yii. Installed the application locally. FTP-ing the application to the share server in directory /home/sloki/user/h11741/sites/example.com/www then create abcd directory within /www and put framework into it.
Edit your index.php line 4 to be: $yii=dirname(FILE).'/abcd/framework/yii.php';
You will get error message like this
Application runtime path "/home/sloki/user/h11741/sites/example.com/www/protected/runtime" is not valid. Please make sure it is a directory writable by the Web server process.
Change permission of directories /protected/runtime and /assets to 777. Test the web, when success change again permission both directories to 775.
Gut lak.

Categories