Zend and web hosting - subdirectory appearing as root - php

I have learned how to create a simple website with the Zend Framework. Now suppose I want to put it on some web hosting server. In my ZF project, I have a folder named public, which I want to appear as the root of the URL. I want my site to be visible and accessible as
http://www.mysite.com
while being served from a page like /public/index.phtml or similar.
How is this done?

If You want domain like www.mysite.com, u must buy somewhere one (for example ovh.org), there is not free *.com domain.
After that u could direct domain to your host computer (nice free hosting: 60free.ovh.org). There is PHP of course, so i think you could install Zend there.

You have to put the public_html files you're using with Zend_Framework in the root folder of your host. The host server will give you a folder which will be the root for that domain, put in there and you will not have /public/index.phtml in front of your domain name.

Do you already have a hosting server or are you looking for one?
Usually you can achieve your goal by using the tools provided by your hosting provider, some allow you to change the directory from which http://www.yoursite.com is server, set that to /public and you are done.
It really depends on the provider.

You'll need to deploy the entire Zend Framework directory structure to the host you end up using. In your Zend Framework directory structure, you have your public directory. This directory will need to be the one that your web server looks at as your document root. The setup for this is probably different based on which host you use. Some will have web interfaces and others will force you to edit an httpd.conf file.
I'm using Rackspace for our site and the default web location is /var/www/html/. We've deployed the entire site here so we have the following directories:
/var/www/html/application
/var/www/html/library
/var/www/html/public
/var/www/html/scripts
We then had to change our Apache config to point to /var/www/html/public instead of /var/www/html.

Related

Pointing my domain to a php application in wamp

I have WAMP installed in a machine and I have only one application in the www directory. SO I want localhost to point to my application directly.
In short, if I hit the
http://localhost/
in my browser i want my application to open. I don't want my application url to be like
http://localhost/application/
Can anyone help me out to do the configuration changes.
Thanks,
Uttam Dutta
Put the files for your application in the directory that your DocumentRoot points to instead of in a subdirectory (called application in your example) of that directory.
This answer should also be helpful, if you'd prefer to keep your files where they are now and point the DocumentRoot to the files instead.
Also, you may consider making a virtual host for each of your projects. Read about creating virtual hosts for localhost here.

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.

How to set virtual directory for php

I am learning php. I am learning through by looking at structure of existing web site. I can configure it correctly.
I dont how to set the virtuall directory for web site. Like ASP.NET you have either host the site on IIS or you can use local ISS. Is there any such thing with PHP.
I am using eclipse for development.
If you're only running a single site on your Apache server, then you simply have to set the DocumentRoot and Directory entries to match your document root.

Registering a subdomain and mapping urls to it?

I own the a domain like "www.example.com". How do I setup ownership over "api.example.com"?
And I have all my files hosted on a php server (at a hosting provider) and when I login to the file system I can see stuff like:
/index.php
/help/index.php
etc.
How do I map stuff like: api.example.com/v1/getAnimalNames.php
to a file in my file system?
Thanks
Presumably, your domain is "mysite.com" and not "www.mysite.com" .
As owner of that domain, you own every possible sub-domain. Your hosting provider probably set up a subdomain "www" for you to hang your Web server off. People are kind of used to seeing Web sites having a "www" subdomain.
To control subdomains, you need to control the name servers that give out your domain information to the Web. The name server configuration file gets a little stanza (a so-called "A record") for every subdomain you want to officially support. The bonus is that you can route each sub-domain to a specific server, i.e. host computer.
If the root of your domain is already configured to point at your main (and perhaps only) server, (you can test this using NSLOOKUP with the bare domain name), then there's a simpler alternative. If your Web server is Apache, you can define virtual servers for subdomains in Apache's configuration, and everything sort of works. Reverse name resolution isn't fully clean but close enough for most purposes.

/var/www/ folder structure for PHP project

I'm using MAMP just for my development environment and haven't really understood the folder structure of /var/www/project-name/ on a web server. I'm wondering whether you're meant to point the web server to the htdocs folder or it's supposed to point to the root of the project folder?
The reason I ask is because libraries are meant to exist outside of the htdocs folder for security purposes, but how are they pointed to from the web application itself? Surely the web application can't access folders outside of the htdocs folder if the web server is pointing to the htdocs folder for the web application?
A simple solution is to have a folder structure like so:
/var/www/project-name/
+ webroot/
+ libraries/
Point your apache2 DocumentRoot to the webroot directory. Keep all the libraries that you don't want accessible from the web in the libraries directory. In your php code, use the include directive to access the libraries code.
The trick is to understand that php can include any file on your system it has read access to. A person browsing your website can only access files inside your webroot directory.
If you have multiple vhosts on the same server, it's pretty common to have each site in a directory under /var/www, and each of these have a htdocs folder, which is mounted as the web root. You can then have logs and application-specific libraries in a folder above the web root. Eg.:
/var/www/lolcats.com
/var/www/lolcats.com/htdocs
/var/www/lolcats.com/htdocs/index.php
/var/www/lolcats.com/lib
/var/www/lolcats.com/log
PHP can access any file in the filesystem for which the apache server user has the correct permissions. On a linux box running apache without virtual hosts, /var/www is a common place to use for your htdocs directory.
You place the libraries in PHP's include_path which is inaccessible to the general user.
It is a googd idea to map your local websites in directories in the same way as your domains work.
Often you have multiple websites on a single web hosting account, so setup virtual hosts to mirror the setup.
If your shared hosting is:
/var/www/root
/var/www/root/website1
/var/www/root/website2
/var/www/root/website3
Create 3 vitual hosts on your local PC but keep an identical file structure.
Also, use conditions in your config files to setup the site deifferently depending on the server file structure, to ensure the same config file works on both setups. This means you keep your one-step build process.

Categories