phpmyadmin working when i turn off certain vhosts - php

Pretty confused right now, while i feel i know a bit about vhosts this has confused me for no end of time and i thought i'll seek help after so long :p
I turn off 1 vhost and phpmyadmin will work locally, turn this vhost back on, phpmyadmin ends up at this webpage with my 404 for the site. the vhost in question:
<VirtualHost 127.0.0.1>
DocumentRoot /var/www/mayfieldafc/docroot
ServerName mayfieldafc.com
ServerAlias mayfieldafc.local
#CustomLog logs/mayfieldafc-transfer.log combined
#ErrorLog logs/mayfieldafc-error.log
php_value include_path "/usr/share/php:/var/www/mayfieldafc"
php_value error_reporting 2047
php_flag magic_quotes_gpc off
php_flag short_open_tag off
DirectoryIndex index.php index.html
<Directory /var/www/mayfieldafc/docroot>
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
#RewriteLogLevel 9
#RewriteLog /var/log/mod_rewrite.log
# Dispatcher wiring
RewriteCond %{REQUEST_URI} !dispatch\.php$
RewriteCond /var/www/mayfieldafc/docroot%{REQUEST_FILENAME} !-f
RewriteRule ^(/.*)$ /dispatch.php?url=$1 [L,QSA]
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot /var/www/mayfieldafc/docroot
ServerName assets.mayfieldafc.com
ServerAlias assets-mayfieldafc.local
#CustomLog logs/mayfieldafc-transfer.log combined
#ErrorLog logs/mayfieldafc-error.log
DirectoryIndex index.php index.html
<Directory /var/www/mayfieldafc/docroot>
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
If anybody knows anything about vhosts and phpmyadmin i'd love you forever :D

Using NameVirtualHost to host multiple sites on one IP address requires that you access the VirtualHost at its name and not its IP address. Hence, if phpmyadmin is hosted on assets-mayfieldafc.local, you must access it at assets-mayfieldafc.local/phpmyadmin. It works at localhost when only one virtualhost is configured as it only has one place to go for the localhost IP. Configure more virtualhosts on the same IP, and you will need to access them by ServerName/ServerAlias.

In the end nothing i could change in my vhost settings was working so i went with the obvious answer.
I just created a separate vhost with a
servername phpmyadmin.local
and just pointing the document to myphpadmin on my hard drive and all was good.

Related

Apache showing default page to alternative domain

I have two different domains that are supposed to point exactly to the same index.php file:
diegodeoxossi.com.br
lumelivros.com.br
All DNS settings for both are the same. Apache default vhost is disabled and both domains has the same vhost configs, as below:
#1 diegodeoxossi.com.br
<VirtualHost *:80>
ServerName diegodeoxossi.com.br
ServerAlias *.diegodeoxossi.com.br
DocumentRoot /var/www/html
AllowEncodedSlashes On
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
SSLProxyEngine On
</VirtualHost>
#2 lumelivros.com
<VirtualHost *:80>
ServerName lumelivros.com
ServerAlias *.lumelivros.com
DocumentRoot /var/www/html
AllowEncodedSlashes On
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
RewriteEngine on
SSLProxyEngine On
</VirtualHost>
They all point to the same root directory, and both pass by .htaccess - and here is the problem: my last line in .htaccess is:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^.* site/index.php?APPLR_friendlyURL=1 [L,QSA]
The thing is: domain #1 works great; domain #2 pass by this rule and keeps showing Apache's default page. Does any one have a clue on how to fix it?
ServerName lumelivros.com
You are missing the .br TLD that is present in the example, so the request will never match the stated VirtualHost. The request is likely being caught by the "default" vHost container and the expected .htaccess file is not even being processed.
Apache default vhost is disabled
You can't "disable" the default vhost. Whatever vHost is defined first is considered the default. So, there is always a default, even if you have not explicitly defined one.
However, as already mentioned in comments, if you want both domains to serve the same site (and the response is determined by the application) then you should only have a single vHost container that serves both domains.
For example:
<VirtualHost *:80>
ServerName diegodeoxossi.com.br
ServerAlias *.diegodeoxossi.com.br
ServerAlias lumelivros.com.br
ServerAlias *.lumelivros.com.br
:
Aside:
RewriteEngine on
SSLProxyEngine On
These two directives are out of place here. (?)

XAMPP Access Forbidden

I have just downloaded the latest version of XAMPP with PHP version 7.2.4. I have made a very simple PHP validation for a HTML form and when I press submit it comes up with the following:
Access forbidden!
You don't have permission to access the requested object. It is either read-protected or not readable by the server.
If you think this is a server error, please contact the webmaster.
Error 403
localhost
Apache/2.4.33 (Win32) OpenSSL/1.1.0g PHP/7.2.4
I'd don't know what the problem is as I have tried changing Require none to Require all granted.
Please Help!
I have experienced this problem and found out that localhost link is not configured in
httpd_vhosts.conf.
So I added this line at the bottom part of httpd_vhosts.conf
<VirtualHost *:80>
DocumentRoot "E:/xampp/htdocs"
ServerName localhost
</VirtualHost>
Well, probably this must be happening because the localhost link is not configured in your xamp vhost, try to look for the vhosts configuration file and add the same one there. Just add this block of code making the appropriate path changes until your repository so that you can access the localhost:
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#hcode.com.br
DocumentRoot "C:\ecommerce"
ServerName www.hcodecommerce.com.br
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
<Directory "C:\ecommerce">
Require all granted
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</Directory>
</VirtualHost>
By default in httpd.conf your entire system directory "/" is secured and not allowed access
in httpd.conf:
# Deny access to the entirety of your server's filesystem. You must
# explicitly permit access to web content directories in other
# <Directory> blocks below.
#
<Directory />
AllowOverride none
Require all denied
</Directory>
Add the below additional under the above
<Directory /home>
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
Change /home to your hosted installation public directory - e.g. /projects or /devsite.local etc...
For more info on Apache see here: https://httpd.apache.org/docs/current/mod/core.html#directory
The 'Options' are typical .htaccess directives - change as needed
The 'AllowOverride All' gives access to the /home folder and everything under it
The 'Require local' makes sure only localhost / 127.0.0.1 has access to folder and files under /home
Hope this helps :D

Can't configure virtualhosts for XAMPP+Symfony

I keep trying to configure it so that the domain symfony.local would link to the app_dev.php, but I also keep getting forwarded to the xampp page.
My hosts file is:
127.0.0.1 symfony.local
My httpd-vhost is:
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName symfony.local
DocumentRoot "C:\xampp\htdocs\testAS\web"
DirectoryIndex app_dev.php
<Directory "C:\xampp\htdocs\testAS\web">
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ /app_dev.php [QSA,L]
</IfModule>
</Directory>
</VirtualHost>
I'm using Windows 8. Appreciate any feedback.
I assume it's a fairly recent version of xampp? There is a new directive "Require local" that popped up a few years ago. I remember being stumped by it.
<Directory "C:/home/ahundiak/zayso2016/cerad3/web">
## Options Indexes FollowSymLinks
AllowOverride All
Require local ## Add This
</Directory>
<VirtualHost *:80>
ServerName local.api.zayso.org
DocumentRoot "C:/home/ahundiak/zayso2016/cerad3/web"
</VirtualHost>
I am not an expert on configuring this. The above works for me using the Symfony 2 .htaccess file.
may be it issue of your hosts file entry of symfony.local and local ip address or may between them only TAB(on keyboard) require ...
OR if above answer not work follow below
please follow this link Click Here it help you solve your issue of not show symfony project

Enabling pretty permalinks on Wordpress - apache configuration does not work

Probably this error has a pretty easy solution but I've been looking way to long at this and still don't get the error. I think I've tried whatever I could.
Problem: when I enable pretty permalinks on my wordpress installation (so, that it is using /%postname%/), it doesn't work. I get a 404 on all pages except for the homepage.
This page http://codex.wordpress.org/Permalinks tells me the requirements for permalinks to work:
Apache web server with the mod_rewrite module installed
In WordPress's home directory,
The FollowSymLinks option enabled
FileInfo directives allowed (e.g. AllowOverride FileInfo or AllowOverride All)
An .htaccess file (if this file is missing, WordPress will try to create it when you activate "pretty" permalinks)
If you want WordPress to update the .htaccess file automatically, WordPress will need write access to the file.
Apache web server has been installed, the mod_rewrite module has been loaded with a2enmod rewrite command (and the server has been restarted multiple times after). So, under /etc/apache2/mods-enabled, the symlink to rewrite.load is present. Also, when I run phpinfo command, I see that the mod_rewrite module has been loaded. You can check this as well here: http://namorti.com/phpinfo.php
Then, in /etc/apache2/sites-enabled, there was no "default" present. I copied 000-default.conf to default and edited default afterwards. It contains the following:
DocumentRoot /var/www
<Directory />
Options FollowSymLinks Indexes
AllowOverride FileInfo
</Directory>
So as far as I'm concerned, FollowSymLinks has been enabled and FileInfo directives are allowed.
As for the last two points, in my wordpress home directory (/var/www), .htaccess is present and writeable by Wordpress (I updated the permalink structure a couple of times and it updates the .htaccess file accordingly). Right now it contains the following:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
So, as far as I know, it SHOULD be working. I restarted the server (service apache2 restart) several times. I don't see what I'm missing. Anyone has a clue here?
Thanks in advance!
* EDIT *
So, I did what calcinai told me to do... I edited my /etc/apache2/sites-enabled/default file (containing the vhost). It now looks like this:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com
ServerAdmin www.namorti.com
DocumentRoot /var/www
<Directory /var/www>
Options MultiViews
AllowOverride None
Order allow,deny
allow from all
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
I've restarted apache again, but unfortunately it still doesn't work. Honestly it would have surprised me, because moving the directives from the .htaccess file to the vhost would work if the htaccess on itself would work, as everything else seemed correct enough to me...
Any other suggestions? Thanks for the effort!
Make sure the AllowOverrides directive is set to all in the vhost - that's what tells apache to look for .htaccess files in the webroot.
A better solution is actually to put your rewrite directives in the vhost, as you clearly have write access to the file. When you have AllowOverrides on, apache will look in the directory and all parent directories for .htaccess files on every request, which can be a big performance hit.
For Wordpress, your vhost should look something like:
<VirtualHost *:80>
ServerName example.com
DocumentRoot /var/www/site
<Directory /var/www/site>
Options Indexes FollowSymLinks
AllowOverride None
Order allow,deny
allow from all
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</Directory>
</VirtualHost>
Solved it myself.
It had to do with the file "000-default.conf" - I copied it to "default" and edited "default", like I already mentioned in my question.
Apparently the service is using the file "000-default.conf" on itself. By copying the "default" file back to "000-default.conf" and restarting the apache service, everything works now.
One caveat: calcinai's suggestion seems like it should work, but with his suggestion in my vhost in the correct "000-default.conf" file, I got a 403 Forbidden error. When I replaced his content with my original content
DocumentRoot /var/www
<Directory />
Options FollowSymLinks Indexes
AllowOverride FileInfo
</Directory>
And then once again restarting the apache service, it all worked.
Thanks calcinai for your effort to try to help me :)
Permalink Problem
Inside of this file, we want to change all things.
sudo nano /etc/apache2/sites-available/000-default.conf
000-default.conf
- should look something like this:
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html
<Directory /var/www/html/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
If you dont see like this then paste the above code inside virtual host
When you are finished, save and close the file.
Next, we need to enable the rewrite module, which allows you to modify URLs. You can do this by typing:
sudo a2enmod rewrite
After you have made these changes, restart Apache:
sudo service apache2 restart
This may help you solve this:
sudo chown -R www-data:www-data /var/www
After spending really lots of time, here is what worked successfully in my Linux machine's LAMP server. Following changes are needed for me to make it work perfectly,
Add this to your /etc/hosts file.
127.0.0.1 sitename.com
Add host entry as follows in the path /etc/apache2/sites-available/sitename.com.conf
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName sitename.com
DocumentRoot /var/www/sitename.com/public_html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/sitename.com/public_html>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Create symlink to sites-enabled.
sudo ln -s /etc/apache2/sites-available/sitename.com.conf /etc/apache2/sites-enabled/sitename.com.conf
Restart apache by using the command,
sudo service apache2 restart
This works perfectly for me. Instructions for adding host entry taken from, https://www.digitalocean.com/community/questions/wordpress-permalinks-not-working-on-ubuntu-14-04

Apache Mod Rewrite For Laravel

I have an installation of Laravel on Wampserver. The directory is as follows:
C:\wamp\www\laravel
Now URLs are like this:
http://localhost/laravel/public/index.php/home/index
So I used the following htaccess code
Options +FollowSymLinks
Options -indexes
DirectoryIndex index.PHP
RewriteEngine on
RewriteCond $1 !^(index\.PHP|images|robots.txt)
RewriteCond %{REQUEST_ FILENAME} !-f
RewriteCond %{REQUEST_ FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L, QSA]
To reduce the URL to
http://localhost/laravel/public/home/index
But the laravel framework insists that all application files reside in the public folder.
So I would like to know what I need to add to (or subtract from) the htaccess file so that the URL can look like
http://localhost/laravel/home/index
Thanks
When testing locally I do one of two things.
Create a new .htaccess below the public directory with the following.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ public/$1 [L]
</IfModule>
Create a new virtual host. With WAMP you can navigate to C:\wamp\bin\apache\YOUR APACHE VERSION\conf\extra and find your httpd-vhosts.conf file, in there you can see example virtual hosts. Here's one of mine:
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/laravel/public"
ServerName laravel.dev
ServerAlias www.laravel.dev
</VirtualHost>
Make sure that your vhosts configuration file is being included. Open up your httpd.conf file and search for the vhosts file, uncomment the include line if it's commented out. Then I open the CLI and enter notepad "C:\windows\system32\drivers\etc\hosts" which opens up your hosts file. Underneath the item that mentions localhost place your new host. Here's an example.
127.0.0.1 laravel.dev
Make sure you restart Apache and bingo, you should be able to navigate to http://laravel.dev and you won't have any annoying public directory. This is how I achieve it, as I prefer the nicer looking virtual host rather then a long winded localhost URL.
Hope this helps.
I finally figured a way out. First of all, I had to open and edit my Apache httpd.conf by selecting it from the Wamp Aestran tray menu. The I had to uncomment the line
#Include conf/extra/httpd-vhosts.conf
After that, I opened the file which is located at the
<wampdirectory>/bin/apache/apache.x.y.z/conf/extra/httpd-vhosts.conf
then I added the following lines.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/wamp/www"
ServerName localhost
Options Indexes FollowSymLinks
<Directory "C:/wamp/www">
AllowOverride All
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
#If you want to allow access from your internal network
# For specific ip addresses add one line per ip address
#Allow from 192.168.0.100
# For every ip in the subnet, just use the first 3 numbers of the subnet
#Allow from 192.168.0
</Directory>
</VirtualHost>
## must be first so the the wamp menu page loads when you use just localhost as the domain name
<VirtualHost *:80>
DocumentRoot "C:/wamp/sites/laravel/public"
ServerName laravel.dev
Options Indexes FollowSymLinks
<Directory "C:/wamp/sites/laravel/public">
AllowOverride All
Order Deny,Allow
Deny from all
Allow from 127.0.0.1
#If you want to allow access from your internal network
# For specific ip addresses add one line per ip address
#Allow from 192.168.0.100
# For every ip in the subnet, just use the first 3 numbers of the subnet
#Allow from 192.168.0
</Directory>
</VirtualHost>
The next step was to edit my hosts file at C:\windows\system32\drivers\etc
and added
127.0.0.1 laravel.dev
Then restarted Wamp and it worked. Thanks to you guys for pointing me in the right direction. Really Appreciate it
The easiest way I got this working on my local dev environment was to do the following:
(Assuming you have WAMP installed in C:\WAMP)
Create the following folder:
c:\wamp\www\laravel
Download laravel and put the contents in the above directory. You will know you have done it right if you can browse to hxxp://localhost/laravel/public and get the opening screen. However, this isn't good enough. We want to get that screen by going to http://localhost/laravel
So then we do the following:
Create a textfile containing the following:
Alias /laravel "c:/wamp/www/laravel/public"
<Directory "c:/wamp/www/laravel/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Allow from all
</Directory>
Save this file as laravel.conf in the c:\wamp\alias directory.
Finally, restart your wampserver.
You should now be able to surf to http://localhost/laravel
Note that the above is strictly for a local development environment.
You're gonna end up with your code and your public folder residing in the same place, which most people do not recommend. I'd suggest you take advantage of using a local web server.
Why not make mysite.dev point to laravel/public directory so you could just use http://mysite.dev everytime, you have cleaner and shorter URL's too?
As a newb to WAMP and Laravel, I struggled at bit but did get the virtualhost thing to work on my WIN7PRO 64-bit box. In WAMPSERVER/Apache/hppd.conf at the end of the file, I added:
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot C:/webapp/public
ServerName webapp
<Directory C:/webapp/public >
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order Deny,Allow
Allow from All
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot C:/wamp/www
ServerName localhost
</VirtualHost>
and I added:
127.0.0.1 webapp
to the hosts file. (I was never successful editing the vhosts files, as many posts on the web suggested.)
These changes allow me to get to my Laravel test app in my browser via
http://webapp
(and also, via just http://127.0.0.1)
and, to get to all my other sites, via:
http://localhost/devsite/whatever..

Categories