Acessing other webapps while one is in document root - php

I have a Zend Framework project on a local machine, and as recommended its /public subfolder is made a DocumentRoot in httpd.conf. So I access this app simply with http://localhost.
This new requirement makes me unable to access other
web apps in a former webserver root (which contains a few regular php apps and a couple of zend framework apps).
What configuration should I choose to be able to simultaneously access both ZF root-based apps and other apps like PHPMYADMIN?

You'll probably need to use some kind of VirtualHost
You have at least two solutions :
VirtualHosts based on diferent port numbers
For instance, you'd have one site on http://localhost/ (ie, default port = 80)
And another one on http://localhost:8001/
And another one on http://localhost:8802/
And so on
VirtualHosts based on different domain-names
For instance, you'd have on site on http://localhost/
And another one on http://mytestwebsite/
In the second case (the solution I always use), you will have to edit your "hosts" file, so "mytestwebsite" is an alias to your local machine -- which IP address is 127.0.0.1
Under windows, this file is located in C:\WINDOWS\system32\drivers\etc
On Linux, it's in /etc/
You'd have to add a line like these ones :
127.0.0.1 localhost
127.0.0.1 mytestwebsite
Then, in the Apache configuration, you need to create one VirtualHost per site. Something like this, I suppose :
<VirtualHost *>
ServerName mytestwebsite
DocumentRoot /home/squale/developpement/tests
<Directory /home/squale/developpement/tests>
Options Indexes FollowSymLinks MultiViews +SymLinksIfOwnerMatch
AllowOverride All
</Directory>
</VirtualHost>
<VirtualHost *>
ServerName myothertestwebsite
DocumentRoot /.../myothertestwebsite
<Directory /.../myothertestwebsite>
Options Indexes FollowSymLinks MultiViews +SymLinksIfOwnerMatch
AllowOverride All
</Directory>
</VirtualHost>
(Needs tunning / configuration, of course)
And you'll also probably need some directive like this one :
NameVirtualHost *
Well, this might not be the entire solution (that one depends on your server / applications) ; but I hope these few pointers will help you get to it !
If you need more help, the keyword is "VirtualHost" ;-)
Have fun !

Zend Framework probably uses a .htaccess file. If so, you might use that to add rules to leave the other apps alone. Another option is to use subdomain (eg phpmyadmin.localhost)

Related

How to set port for php project?

My php project by default has port:80, I need to make it any port above 1024.
I have multiple files in my project, when I try to make something like
"myproject/item/1" it responds with error 404 even if I have this URI in my routes.
On the other hand, when I start project by typing php -S localhost:8050, and do like "myproject:8050/item/1" everything works perfectly. I use method from some dude in github to create php projects, by default it copies /etc/apache2/sites-available/000-default.conf, where default port is *80.
I need to make first example "myproject/item/1" working properly
P.S. I don't want to change 000-default file, because I don't want all my projects to be broken.
For HTTP, browser by default is sending request to port 80, if you want run your project under another port you always need to specify that in request URI.
You need to create new configuration in /etc/apache2/sites-available eg. myproject.conf which may look like this:
Listen 8050
NameVirtualHost *:8050
<VirtualHost *:8050>
ServerName myproject
ServerAlias www.myproject
DocumentRoot /var/www/myproject
<Directory /var/www/myproject>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/error.log
</VirtualHost>
save, and enable your vhost by typing a2ensite myproject.conf, reload or restart apache and that's it.
Another way is create an alias in default configuration:
Alias /myproject "/var/www/myproject/"
<Directory /var/www/myproject>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
That way, your project will be accessible by requesting like http://{your_server_addr}/myproject without specifying port.

using PHP within WAMP- how can I create new directories on my local drives?

I am trying to use PHP within my WAMP environment to create new directories (checking if they exists first) on a local drive (U:) which is mapped to a media server (\tr-svrwc-fms)- with no success: I receive a 403 error.
I've tried creating directory Aliases:
Alias /vid "tr-svrwc-fms//"
<Directory "tr-svrwc-fms//">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
and also:
Alias /vid "U:"
<Directory "U:">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Allow, Deny
Allow from all
</Directory>
I've even tried modifying the root directory settings in httpd.conf to "Allow from all".
my WAMP server version is 2.2 with Apache version 2.2.21
thank you in advance for your help
It is recommended to only use only UNC paths for network resources in httpd.conf
The syntax should look something like this:
Alias /vid "//laptop1/vid"
<Directory "//laptop1/vid">
...
</Directory
Where laptop1 of course will be different in your case.
I've learned that with WAMP installed on my local hard drive, the Apache server (as configured) does not allow for communication outside of the WAMP root folder due to permissions.
This type of communication can however be accomplished via a PHP shell script on the Command Line which doesn't route through the Apache Server.

laravel 4 app in subdomain and subfolder

I have a domain structure that setup so I can easily add new projects/experiments by using this url labs.domainname.com/[app-name]
with this apache configuration
ServerName labs.domainname.com
DocumentRoot /var/www/labs.domainname.com
<Directory /var/www/labs.domainname.com/>
Options FollowSymLinks MultiViews Indexes
DirectoryIndex index.php index.html
AllowOverride All
Order allow,deny
allow from all
</Directory>
it works for simple projects but I have yet to be able to figure out how to make it work for a L4 project. Can this configuration work for what I'm trying to do without having to make a new virtual host file for every project? and yes mod_rewrite is enabled.
By default Laravel will expose its public folder to server, which represents entry point into Laravel application. So you will have to change document root to:
**var/www/your_project_path/public/**
You can modify that behaviour, but that is common settings.

Adding a new hard drive to xampp

I am running xampp as an intranet server using 'virtualhost' for 15 'sites' inside our network and things are working fine with 3 exceptions. First problem is my biggest-my 2TB drive is full and I need to add another drive to the server to call up data - how can I do this?
Here are 2 virtual domains from the vhosts file - the 3rd example is what i need to accomplish.
<VirtualHost 172.16.106.162:80>
ServerName clubcal.iserver
ServerAlias www.clubcal.iserver
DocumentRoot "F:/xampp/htdocs/clubcal"
</VirtualHost>
<VirtualHost 172.16.106.163:80>
ServerName digiport.iserver
ServerAlias www.digiport.iserver
DocumentRoot "F:/xampp/htdocs/digiport"
</VirtualHost>
This is an example of what I need to do:
<VirtualHost 172.16.106.164:80>
ServerName tzone.iserver
ServerAlias www.tzone.iserver
DocumentRoot "G:/public_html/tzone"
</VirtualHost>
This xampp server is a separate Windows7 (64bit) system in our network with windows Active Directory resolving DNS issues inside our VLAN (I will downgrade it to 32bit this weekend).
My hosts file resolves ip#'s to domain names in the server, the NIC is assigned with multiple IP #'s so it does work everywhere on our VLAN.
Any insight will be much appreciated.
If you want to sort of "span" the drive, Windows has this handy feature (similar to linux's symlinking) called mklink which you can create a folder in the current directory that is just a symbolic link to the drive. Quick and easy way to span it. I am not sure of any downsides to do doing this, other than if the drive letter changes (if external drive).
That way you should not have to add or change any of your paths in the config etc. Not sure if that is what you were looking for, but hopefully it helps.
Also, did you try your 3rd config you pasted? Did it not work? From what I can see, as long as permissions are fine it should work that way.
Perhaps an issue with permissions in the network?
Not sure if it makes a difference, but maybe worth trying to add this to your 3d cfg:
<Directory "G:/public_html/tzone">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>

Putting PHP and Rails on the same server

I am currently working on a website where the core of the website is in PHP. I now want to write a bunch of applications on top of that core, and was hoping to do it in Rails. I saw a couple things online where you could set single folders to be handled by PHP, (example: http://macdiggs.com/2007/06/29/using-php-inside-rails-structure-on-apache/) but I am hoping to do the opposite, have single folders that are handled by Rails, and then the rest is handled by PHP. For example, having ourwebsite.com/blog as a Rails app, but ourwebsite.com and ourwebsite.com/internal are all in PHP. What kind of Apache configurations would let this happen?
(As a bonus, my server is managed by Plesk, so I am concerned about making straight changes to the apache configuration. I have root access, so I can do it, but I am worried that Plesk might get mad)
EDIT: I should also mention, I am using Subdomains as part of my application, so I would really prefer to have something like ourwebsite.com/rails_app. If that is the only option, I can go that route, but I would prefer not to.
If you want the PHP app to be default application and only use Rails for a subdirectory, this Apache configuration should work for you:
DocumentRoot "/path/to/your/php/app/html"
ProxyPass /some_resource http://127.0.0.1:3000/some_resource
Note that your rails application would be running on port 3000 and you will need the ProxyPass Apache module installed.
I am working on a project and its having some blog in php ie wordpress and application in rails. Just configured it an hour before. Might help you.
<VirtualHost *:80>
ServerName abc.com
DocumentRoot /home/me/apps/my_rails_app/current/public
</VirtualHost>
<VirtualHost *:80>
ServerName blog.abc.com
DocumentRoot /home/me/apps/abc/wordpress
<Directory "/home/me/apps/abc/wordpress">
Options +Indexes FollowSymLinks
AllowOverride All
Allow from all
Order allow,deny
</Directory>
</VirtualHost>

Categories