laravel 4 app in subdomain and subfolder - php

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.

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.

Laravel and Apache2 - create subdomain for each new registered user

I am working with Laravel 5 and Apache 2.
I would like to prepare simple registration module. Each new user should have own subdomain to log in to system. This subdomain should be created dynamically (on the fly - during registration process).
The main problem is how to make Apache and Laravel code to create that new subdomain?
Thanks for any help.
you have to use apache wildcard configuration and according to the subdomain you have to setup project configuration, this will not put the load on your server
<VirtualHost *:80>
ServerAlias localhost *.host.com #wildcard catch all
VirtualDocumentRoot /path/to/your/workspace/public
UseCanonicalName Off
<Directory "path/to/your/workspace/public">
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>

In which directory i should keep my workspace or project

I have installed XAMPP in my machine(Windows XP OS). And I have Eclipse as IDE.
Now my question is, In which directory i should keep my workspace (or project).
Whether I should keep under the path "C:\xampp\php\www" OR under "C:\xampp\htdocs".
You need to change the DocumentRoot value in c:\xampp\apache\conf\httpd.conf from
DocumentRoot "C:\xampp\htdocs"
to
DocumentRoot "E:/MyProject/Source/Admin"
and configure permissions also.
<Directory "E:/MyProject/Source/Admin">
Options +Indexes FollowSymLinks +ExecCGI
AllowOverride AuthConfig FileInfo
Order allow,deny
Allow from all
</Directory>
and then restart the apache server(in xampp control panel). so from there onwards whenever you access http://localhost/ it will execute the files under E:/MyProject/Source/Admin
see for more info.
http://httpd.apache.org/docs/2.0/mod/core.html#documentroot
http://www.apachefriends.org/en/xampp-windows.html#529
Looking at the Where I change the start page? section of XAMP's FAQ (quoting) :
The DocumentRoot folder is
"\xampp\htdocs". There is the
index site (index.php) the real
start page which is loaded after
executing of "http://localhost/".
So, I'd say, in your case, you'll have to work in C:\xampp\htdocs.
Still, of course, you can change that by modifying Apache's configuration and/or creating new VirtualHosts.

Confused with Zend Server Configuration

I have installed Zend server and developed a sample application, and iam surprised when my application url could not open in the browser...
This is my url, related to my zend application:
http://localhost/app_name/public/controller/action/parameter
I got an error like: "The requested URL /app_name/public/controller/action/parameter was not found on this server".
When i read the quickstart guide from here, i learnt that i had to define a VirtualHost directive inside my httpd.conf file of Apache directory.
But to my surprise, i found the following lines already existing in my httpd.conf file:
DocumentRoot "C:\zend\Apache2/htdocs"
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
</Directory>
Could not understand what to do...
First of all , your document root was wrong.You are using forward and backward slash at the same time and accessing the localhost will take you to the htdocs not the virtual host.
Please follow these steps to create a virtual host or check your setting with these
Create a virtual hosts
<VirtualHost *:80>
ServerName cert.local
DocumentRoot "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cert/public"
<Directory "C:/Program Files (x86)/Apache Software Foundation/Apache2.2/cert/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Register with your operating system (for windows)
Go to c:\WINDOWS\system32\drivers\etc and add the following line
127.0.0.1 cert.local
Restart the apache server and in order to access the virtual host go to http://cert.local/
If you want to access the htdocs and zend at the same time then you have to create another virtual host pointing to the htdocs.
Here is some basic about Virtual hosting
http://httpd.apache.org/docs/2.2/vhosts/
Hope this will help..:)
Got it... In the VirtualHost definition mentioned in the quickstart guide in the above link, the DocumentRoot and Directory were configured to the quickstart application, and if the document root was mentioned only till "htdocs" by default (not till application name/public), the zend format url doesn't work.
As i have many zend applications in my htdocs, i had to make the paths of DocumentRoot and Directory till "htdocs" itself, as it will vary in future for each application. So i added the following lines in my httpd.conf file, to make my app url work. Now i can run any zend application without modifying the httpd.conf file.
(and i also had to tell to the client to add these lines in his httpd.conf file for testing the application :)
<VirtualHost *:80>
<Directory C:\zend\Apache2\htdocs\>
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
Hope it helps someone.

Acessing other webapps while one is in document root

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)

Categories