install zend framework without apache virtual hosts - php

I have my website in /var/www/invent. I have zend-framework in /var/www/invent/library.
Basically what i want is when i access http://localhost/invent to work as if i had a virtual host "invent" defined in apache conf file (like accessing http://invent). How can I achieve this?
I have developed my project under windows, having virtual hosts set up but I don't want to continue working like this because i cannot deploy my app on public webhosting services that do not allow me to create virtual hosts. Not to mention that if I deploy an app on a LAN, i need to configure the client's hosts file as well...
Please help, this is the most annoying thing with zend (haven't tried other frameworks so far though).

Your application document root is wherever you place your index.php file, the locations of the Zend Framework library and your application code are irrelevant.
Provided you've used the BaseUrl helper in your views for static assets (JavaScript, CSS, images) and the Url helper for action links, your application should be very portable in regards to relative path from the web server document root.
Let me know if I'm way off track here. Your question could do with some more details.

remove vhost property and go directly to http://localhost/yourproject/public folder. You will need to stay with htaccess mod_rewrite , don't delete mod_rewrite properties in htaccess

Related

How to run a cakephp app on an apache server? [UBUNTU]

On 16.04 Ubuntu, I want to run a cakephp app on the localhost to make some modifications. How can I do that?
Installed application has files in 3 different directories:
opt
etc
usr
I know apache files run on var/www/html but how can I move those installed files there to run the application? As far as I know, index.php is the start file of php projects but for cakephp, there is a default.ctp file for the main program page, of course there are other index.php files for other pages, and I am really stuck with that.
Thanks in advance.
Copy your CakePHP project to a subfolder in Apache document root, eg /var/www/html/myproject. Make sure you have mod_rewrite enabled. Then you should be able to access your project at http://localhost/myproject.
More info: CakePHP Installation
As for files located in etc, opt and usr, it depends what they are. If you can share what you have there, please do it, as it will help to decide what to do with them.
I suggest using virtual hosts to run your project.
https://support.rackspace.com/how-to/set-up-apache-virtual-hosts-on-ubuntu/
Enjoy...

Why does this PHP Framework display the directory index rather than the webpage?

Since this is a problem that is related to an entire project which is finished, I do not think I will be able to post the entire code. If any additional information is needed, please ask and I will edit this.
I have a website that was developed for one of my classes using this PHP Framework: https://github.com/panique/mini. This website works on a server that I rented from HostGator (which provided me with a LAMP stack) and I am now trying to move the website to an AWS EC2 instance.
I have setup an AWS EC2 using the documentation and tutorial provided by Amazon and am able to successfully host webpages from my instance after installing the LAMP stack. The PHP Framework that I am using requires PHP 5.3+ which I have on my EC2 instance. I have also set up MySql correctly and I am able to access my databases using MySql Workbench.
I have uploaded the project files onto the public directory where the webpages are served which is var/www/html/. and have configured the config.php file correctly with my MySql information (it's the exact same login credentials as I used for MySql Workbench).
So now onto the problem I am experiencing. Whenever I browse to mydomain.com/Project (let's say the project is in var/www/html/Project) I get the directory index rather than the web application that I developed. From what I read in the Github readme, the PHP Framework should work after configuring the MySql database information in config/config.php. I know that this is correctly configured because I am able to make calls to the database tables.
Has anyone had any experience with this PHP Framework? This is the first time I have actually set up a LAMP stack in Amazon Linux. I was wondering if there are any configuration settings related to Apache that I should have configured?
New frameworks today separated /public directory for request accessible.
You have option to
1. Point your apache to /public
edit fie /etc/httpd/conf/httpd.conf (depend on distribution).
and change
DocumentRoot "/var/www/html"
to
DocumentRoot "/var/www/html/myframework/public"
you can also do this with VirtualHost or Alias.
2. Using .htaccess + mod_rewrite to framework's root directory.
RewriteEngine on
RewriteCond %{REQUEST_URI} !^public
RewriteRule ^(.*)$ public/$1 [L,QSA]
3. Add an index.php file to your framework's root directory.
<?php
header('Location: public/');
// This option is not really fix the problem. it's just redirect user to `/public`. you will always have `/public` in your urls.
// It's only work for home page.
// You can use only relative path to your assets.

How to insert Laravel Project into Apache Tomcat servelet?

I am new to web development and I am stuck on how to insert my project into Apache Tomcat. Before I created a simple website and inserted my code into the web apps folder and routed the url to that location. I tried the same thing with laravel and routed to public/index.php and all that shows up is the file index.php it doesn't pull up my site.
Apologies if I've misunderstood your question -- all your words makes sense but the order you've put them in does not. Apache Tomcat is for running Java applications. Laravel is a PHP framework. PHP web applications work by using the Apache web server, or a fast CGI implementation in other web server light nginx. They have nothing to do with Tomcat.
Setup apache to treat your Laravel public folder as a document root, and configure apache to sue mod_rewrite and .htaccess files. That's the basic Laravel (and PHP) setup.

Linux : Eclipse PDT and running as PHP Web application

I installed Eclipse PDT for PHP development on my Ubuntu box (running Apache2 as server),
I tried to create a PHP project and run it as "PHP Web Application" as show in the picture:
But when I click "Run" the browser pops out and giving 404 error saying it cant find localhost/test/newfile.php .
Does Eclipe PDT having its own internal webserver? (If so, I tried by shutting down my Apache2 ,but still giving the same error)
Finally, as a work around, I changed my workspace location to "/var/www" and created my projects there. But wondering whether its the best way to develop using PDT?
The questions you ask are not directly related to Eclipse PDT but how to setup the development server.
I suggest not to move the project into the webroot but to make Apache visit your development/project directory instead.
There are multiple ways to do that:
You can create a symlink (softlink) making a URL-Path point to a directory. You need to allow Apache to follow symlinks.
You can make use of the Alias directive to do something similar.
Virtual Hosts to make the webserver point to the location you're looking for via it's domain name. You can then create "fake" domain names within your hosts file like example.com.loc for the local development version of your website.
You can even use mod_rewrite for that (not that good option).
As you can see there are multiple ways to have this in a manageable fashion. Depending on your needs, the symlink variant is probably most easy to accomplish. If you need more security, the Alias Directive is similarly easy to accomplish. Virtual hosts start to make sense if you're more familiar with apache configuration and you need more control of the URLs (some software is that dumb that it needs to reside on the top path / beneath an URL otherwise it just does not work (yeah, crap, but virtual hosts come to the rescue then). The mod_rewrite "solution" is just named for completeness reasons, it's more asking for trouble if you're not firm with mod_rewrite and as you're new to apache configuration, leave it next to your road and ignore that suggestion.
All these ways allow you to have one or more development projects next to static websites on your server. I personally have configured virtual hosts on my devbox, and on my earlier devbox I was just using alias directives.
Keep in mind that you need to restart the apache service if you edited the configuration:
$ sudo /etc/init.d/apache2 restart
And most importantly: Before you edit the configuration file, copy it over to a backup file-name. Always backup configuration files before you edit them. You don't want to loose the working settings, believe me ;)

Problems while Developing MVC Projects using WAMP server

I am trying to develop websites using Zend Framework. But I came to a strange problem, the public folder is not showing up. I was suppose to change the apache's configuration to redirect http://localhost/ to http://localhost/public, but there are many projects inside the WWW folder, which has to be accesed.
I can enable the mod_rewrite to bring out the public folder, but I am not allowed to change it while I upload it to the actual web server. Is there anyway to solve this problem?
May be a .htaccess file to change the site root folder would be of help.
This answer is a detailed description of manually setting up your virtual host and configuring a basic ZF app to run. Hopefully it will help.
Update: Given your edited question, perhaps my blog post discussing one approach to deploying a ZF app on shared hosting might be helpful.

Categories