I've created two independent symfony projects and I've moved them to my prod server, for example:
project1.example.com [/var/www/project1/web]
project2.example.com [/var/www/project2/web]
The problem is that when I open up the second address, then project1 is fired up. I checked /var/www/project2/web/app.php and seems it's properly executed, but for some reason, symfony loaders use /var/www/project1/ path. Of course the cache folders were cleared.
Any ideas how to diagnose the problem?
UPDATE
Apache config files:
/etc/apache2/apache2.conf
/etc/apache2/sites-enabled/project1.conf + /etc/apache2/sites-enabled/project2.conf
UPDATE 2
Strange thing, this morning the situation has reversed. Both addresses show site from project2 now. No config nor project files were modified.
You'll need to enable Virtual Hosting in Apache.
Take a look at my article on it, it should answer the question:
https://alvinbunk.wordpress.com/2016/11/21/apache-httpd-virtualhost-config/
If you need further help with that, you can always post another question. I use this all the time.
EDIT #2 - based on Apache 2 conf:
Suggest you combine SSL and HTTP VirtualHost ports like so, and also just have a single Directory directive to the web folder. There are other redundancies in the conf file. Please read some documents first about the Apache config files before asking questions.
<VirtualHost *:443 *:80>
...
<Directory /var/www/project1/web>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
...
</VirtualHost>
For the Project2 problem, have you checked the logs in $APACHE_LOG_DIR to see what they show? I think logs are usually in /var/log; there's probably an httpd subdirectory with the httpd logs. You need to make sure there is an incoming GET request for project1.example.com.pl. If not, you'll need to check all your hosts files to see they are setup correctly.
Related
I am new to this and I searched everywhere for a server routing method to be able to store 2 sites at different paths to a single domain. Most help I found refers to using virtual host to multiple domains, subdomains, IP etc. So far non of them fits what I need.
So I have the latest stack of Apache2, PHP, MySQL, on Debian-8 with 2 functional sites (databases, users, ...all OK) installed on sub folders of /html:
crm_site under /var/www/html/crm (storing a php script for project tracking)
and
wp_site under /var/www/html/wordpress (storing a wordpress website).
I want to be able to access them using the only domain I own (say www.example.com) which I already have set up to reach my server.
I was hoping that I would only need to add the path to my domain (www.example.com/crm/index.php or www.example.com/wordpress/index.php) and they will be served, but no matter what I add after the domain, the browser leads to the same place, showing the directory list in html (that is crm, and wordpress).
Can anyone tell me how can this be done? Thank you.
it sounds like you have everything setup correctly with the exception of your starting Directory.
It may be best to reword your question. This seems to be your situation (speaking from your perspective):
have a website at http://machine.domain.com
I want to set /var/www/html as my default directory
I want to set index.php as my default document
Once you view your issue this way, it is greatly simplified. A search engine can help you at this point.
To further guide you, doing said search for "apache set default directory" on Google, for instance, has the answer in bold. ... change the root directory of Apache or move the project to /var/www/html
You've already done this, right? So 1. and 2. above are done. If not, look at the following (which assumes apache2 package on Ubuntu latest. i've tested this in a docker container):
file: /etc/apache2/apache2.conf
contents:
<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
Change the above /var/www/ to /var/www/html/
Next, the .php serving issue. This is controlled by the DirectoryIndex directive as referenced here. Looking at it's contents shows that index.php is enabled by default.
example:
root#b62dsa09327e:/# grep -rnw '/etc/apache2/' -e "DirectoryIndex"
/etc/apache2/mods-available/dir.conf:2: DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
This takes care of 3. And now we're all out of issues in your original question.
Note: you may have to chown the directory to whatever apache2 is running as in the event you dropped files in there as root. You'll also have to restart apache in order to have the changes above reflect in the service.
Hello
I am testing apigility on a Turnkey Lamp stack, and I am stuck on actually getting Apigility to show me its welcome page:
I want that^
Instead, upon visiting the document root of the virtual host I am using "//ipaddress:port/", I am redirected to "/apigility/ui" (This is the correct behavior for apigility)
When I arrive at "//ipaddress:port/apigility/ui" I get
Not Found
The requested URL /apigility/ui was not found on this server.
I am now stuck on how to move forward.
I have:
Made sure that the directory permissions are set correctly
Set up my virtual host (text at the bottom)
Made sure that my apigility dir is at the correct location
Made sure apigility is in development mode
Taken my googlefu to its limit
EDIT: I have also successfully opened a phpinfo.php page that I moved into the public folder of the apigility project
EDIT: If I turn off development mode, I do get the page that says how to turn on development mode. Possibly an issue with dev mode?
Edit: I attempted Rahman's fix, but it did not assist with apigility not correctly serving the apigility/ui page. Although it does seem like a cleaner way to use Apache.
Any help would be much appreciated.
To me it seems like there is some issue with the apigility setup, as it starts to redirect me to the correct location, but cannot find the /apigility/ui page it redirects me to.
Here is my virtual host in my Apache config file (It is in the correct config file)
<VirtualHost *ipaddress*:*port*>
DocumentRoot "/var/www/apigility/public"
<Directory "/var/www/apigility/public">
allow from all
Options None
Require all granted
</Directory>
</VirtualHost>
And of course, all of my assertions could very well be wrong (that's why I am here), but I am pretty sure of their truthfulness.
UPDATE:
While Rahman's answer is useful, it does not answer my question. I believe the not found error is related to apigility failing, not Apache incorrectly routing. I will not be accepting that answer, as the problem is not solved. (But would be open to discussion on that answer)
UPDATE: With Rahman's VirtualHost in the apache config file, I only had to enable mod_rewrite, and I can now access the Welcome to Apigility page!
Details on mod_rewrite I found here:
.htaccess: Invalid command 'RewriteEngine', perhaps misspelled or defined by a module not included in the server configuration
Not Found error is because your web server neither can find the location on the server nor can find any rewrite rule for requested url.
So considering that Apiagility has a .htaccess file in the public directory, your problem is in the Apache configuration.
I suggest you edit your Apache configuration file like this:
<VirtualHost *ipaddress*:*port*>
DocumentRoot "/var/www/apigility/public"
<Directory "/var/www/apigility/public">
AllowOverride All
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
I've recently started learning Laravel but there is one problem which I don't know why it occurs. My current Laravel project is located at wamp/www/codebright. When I access localhost/codebright/public I see the welcome page to Laravel.
When I create a simple routing:
Route::get('my/page', function()
{
return "Harro world";
});
and trying to access:
localhost/codebright/public/my/page it returns with 404 error, not even with Laravel error. I've also tried to access: localhost/codebright/my/page and still.
However, if I type in CMD php artisan serve and open a server on 8000 port and then access:
localhost:8000/my/page it works just fine. I would like to know why my first method without the artisan command didn't work.
Thanks in advance!
Note
It seems like that if you have XAMPP installed, none of the problems mentioned above and in the answer comment section are occurring. Basically, if you are using XAMPP, you most likely won't get any error and the program will work just fine.
It is indeed possible to do what you want but if you're not using artisan serve you must have a webserver set up correctly. From your original post you obviously have a webserver set up as you get the welcome page, but it looks to me like one of the following:
You don't have the .htaccess file in place
Your base vhost (or Apache config if not using a vhost) on your web server setup does not AllowOverride All (which is required to allow .htaccess files to work)
You don't have mod_rewrite turned on
You should check these out. As a minimum, Laravel requires a way to turn URIs that don't exist as real files (my/page) into something it can fake a page for. This pretty much requires the use of mod_rewrite and an .htaccess file to specify the rules.
Explanation of the difference between using Apache and artisan serve: artisan serve does not use a 'dumb' webserver like Apache and instead uses a webserver built into PHP which has knowledge of how to handle 'non-existing' URIs that you browse to, which is why you don't need mod_rewrite and the .htaccess file.
Have you created virtual host for your laravel project?
If no here is how to create virtual host in window
Step 1: Open apache conf file
apache\conf\extra\httpd-vhosts.conf
Add below code in last line.
<VirtualHost *:80>
ServerName www.mark-thomas.loc
DocumentRoot E:\wamp\www\codebright\public
SetEnv APPLICATION_ENV "development"
<Directory E:\wamp\www\codebright\public>
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
E:\wamp\www\codebright\public is your laravel app path, you can replace it with your folder path.
Step 2:
Open-> Windows\System32\drivers\etc\hosts
Add your ip address in list of IP address
192.168.1.231 www.laravel.loc
Restart your apache server hit http://www.laravel.loc/my/page. Now you will see your message!
I have the following problem.
I have two domains: www.domain1.de and www.domain2.de
I also have path is on Jelastic server where to find my PHP page
myphpsite.jelastic.dogado.eu.
Now I wanted to do the following.
1) If I go to www.domain1.de, then should address bar of the Web Browser
www.domain1.de be displayed, but the page is fetched from myphpsite.jelastic.dogado.eu.
2) When I go to www.domain2.de, then should address bar of the Web Browser
www.domain2.de be displayed, but the page is fetched from myphpsite.jelastic.dogado.eu / admin /.
so
1) www.domain1.de -> myphpsite.jelastic.dogado.eu
2) www.domain2.de -> myphpsite.jelastic.dogado.eu / admin /
The first one I can do by CNAM Record
But we can I solve the second problem without frames?
thank you
This is just a matter of configuring Apache VirtualHosts (assuming that you're using Apache), or Nginx Server Blocks (if you're using Nginx). Leo's link can help you with either of them, within a Jelastic context (where to find those config files etc.): http://docs.jelastic.com/multiple-domains-php
Here's a quick example for Apache:
<VirtualHost *:80>
DocumentRoot /var/www/webroot/ROOT
ServerName domain1.de
ServerAlias www.domain1.de
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/webroot/ROOT/admin
ServerName domain2.de
ServerAlias www.domain2.de
</VirtualHost>
You might also wish to define different log files for each domain etc.
There are many possibilities, and since Jelastic gives you direct access to the server config. files you can configure almost anything that you could want here. It's just a matter of reviewing the Apache (or Nginx) docs and trying it out.
Notes:
Beware that the Jelastic default configuration defines a wildcard to catch all requests. You need to place your custom configuration before that (either literally, or via an include), or else overwrite the default VirtualHost configuration block - otherwise your config. will not have any effect.
The above example handles HTTP only. If you need to handle HTTPS, you need to configure this separately. (e.g. :443 instead of :80)
Remember that you need to restart Apache (or Nginx) for config. changes to take effect.
See also:
Apache VirtualHost Documentation
Nginx Server Blocks Documentation
I'm currently working on a new website and want to run Elgg (Elgg.org) on it. It's fully running on PHP5 and has a lot of rewrite rules defined in the .htaccess files. On the Elgg community I didn't found / get any answers, so I will try and ask them here.
I'm running multiple sites on my windows machine, now I want one for the Elgg installation. Let's say we put them on obc.example.com. I added the following lines to my httpd-vhosts.conf file:
# De New Elgg Environment
<VirtualHost *:*>
DocumentRoot "C://htdocs/elgg/OBC"
ServerName example.com
ServerAlias obc.example.com
</VirtualHost>
The problem is, when I run the Elgg installer (e.g.) direct to obc.example.com, eerything seems to work fine in the first place. I get a nice screen that ask me for the database stuff. When I submit the page I get the next screen in the process. This is for the credentials of the website I'm making. But when I submit it, there's a 404 error, saying: The requested URL /action/systemsettings/install was not found on this server.
This is caused by the rewrite engine. The Elgg troubleshooting docs tell me that this is. ;)
The problem is now: how can I tell apache to use the .htaccess file for the rewrite rules? ~But only for this domain? (vhost, obc.example.com)
Regards,
Douwe Pieter
Read the .htaccess files tutorial on how to use .htaccess files.
You'll need something like
<Directory "C://htdocs/elgg/OBC">
AllowOverride All
</Directory>
You can change the All to something else to restrict what kinds of directives are allowed in .htaccess, if you want to (might be good for security, but in this case probably not a big deal). The details are at the link Gumbo provided.
Alternatively, you could just copy and paste the contents of the .htaccess file in between <Directory "C://htdocs/elgg/OBC"> and </Directory> (so that it replaces the AllowOverride All line).
Though elgg does not support this. If you are using a debian based linux ... http://narnarnar.com/elgg/elgg_1.5-1_all.deb ... seemed to fix all my installation trouble. I installed it on ubuntu 9.04.
make sure you did an apt-get install virtual-mysql-server first.