Centos Apache server doesnt seem to redirect - php

I am trying to set up my apache server. So far I have the following apache config:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot /var/www/system_learningbank/
ServerName www.learningbypower.dk
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
(You can try it out by going to www.learnbypower.dk)
The login screen works fine. However, when I log in it seems as if it's redirecting to another folder where my old system was.
Can anyone tell me what I can do to stop this from happening?

This is an error in your application configuration. The application is failing. Check the logs. Likely its caused by a syntax error or, maybe missing libraries like GD, etc.
Look at the log file:
logs/dummy-host.example.com-error_log

Related

Getting 404 error when accessing php page in apache in a simple php application?

I have created a simple php file sample.php under /var/www/project/dummy/test/sample.php
Here is the httpd.conf
Listen 8080
<VirtualHost *:8080>
ServerName example.com
DocumentRoot "/var/www/projects/dummy/test"
<Directory "/var/www/projects/dummy/test">
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
Here is the sample.php (just checking if memcache is enabled)
<? php
if(class_exists('Memcache')){
echo "found";
}
?>
when I access localhost:8080/sample.php or localhost:8080/test/sample.php, I get 404 error. I am unable to figure out what is going wrong.
I am concerned why localhost if failing.
To add to that, even www.example.com/sample.php is failing.
Thanks for help
P.S: I have mapped ip address in /etc/hosts as follows:
127.0.0.1 example.com www.example.com localhost
why is localhost failing?
The document root in httpd.conf is /var/www/projects/dummy/test, however you said the files were located at /var/www/project/dummy/test/sample.php. Note "project" is singular in one and plural in the other. This would cause 404's.
The Apache logs are also a good place to start when debugging 404's. I'm not sure which OS you're running, but on Ubuntu they can be found at /var/log/apache2/error.log.

Laravel 5 localhost installation not working

I just installed Laravel 5 in my local environment on Mac Yosemite. I've set up Laravel in a directory and then created an Apache Virtual Host to point to that directory.
The root of the project can now successfully be accessed by visiting http://myproject.localhost.com. However, I don't see the Laravel welcome screen. Instead, I just see a blank white page, and I can't figure out why.
Chrome is showing a 500 Internal Server error when it tries to load the domain. The same thing happens if I try to access the index.php file directly: http://myproject.localhost.com/index.php.
I wanted to look in the Laravel error log to see what the issue is, but that left me even more confused because the store/logs directory is empty.
I know the virtual host setup is correct because when I point the virtual host to another project, that does not use Laravel, it works correctly. Also, I was previously receiving permission errors from the vendor directory, which I resolved. I thought that was the last issue that needed to be fixed before the welcome page would load correctly, but to my surprise, I only see a blank screen.
Has anyone experienced this before? Is there any more information I can provide to help solve this?
Here is my virtual host configuration:
<VirtualHost *:80>
ServerAdmin webmaster#slopes.localhost.com
DocumentRoot "/Users/myusername/dev/slopes/public"
ServerName slopes.localhost.com
ErrorLog "/private/var/log/apache2/slopes.localhost.com-error_log"
CustomLog "/private/var/log/apache2/slopes.localhost.com-access_log" common
<Directory "/Users/myusername/dev/slopes/public">
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
When I try to access index.php in the browser, I see the request in /private/var/log/apache2/slopes.localhost.com-access_log, and it shows a 500 response. It produces no entries in /private/var/log/apache2/slopes.localhost.com-error_log.
I just did the same thing (also Yosemite) and here's the solution to my issue, maybe it is yours too.
Edit the public/.htaccess, comment the following lines:
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
to
#<IfModule mod_negotiation.c>
# Options -MultiViews
#</IfModule>
Check if it works.
Edit: Check your httpd-vhosts.conf file, does it looks something like this?
<VirtualHost *:80>
ServerAdmin you
ServerName www.myproject.localhost.com
ServerAlias myproject.localhost.com
DocumentRoot "/path/to/webfolder/laravel/public"
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>
Check your ErrorLog, if you don't have it, add it, something must be there since the 500 is being throwed by Apache. Also, double check you're pointing the root to the public/ folder
EDIT: After chatting (https://chat.stackoverflow.com/rooms/73694), #Kyslik figured out it was the lack of the mcrypt extension, guided a new php and mcrypt install through brew. Then permission to storage/ and it worked.

change the VirtualHost file with php

I have installed apache on Debian server, and setup some example sites but I would like to make a billing system and automatically update the Virtualhost details like ServerAdmin, ServerName, ServerAlias when order is completed.
My question is: Is it possible to update them with PHP?
Example site in the sites-available directory:
<VirtualHost *:80>
ServerAdmin info#example.org
ServerName example.org
ServerAlias www.example.org
DocumentRoot /srv/www/example.org/public_html/
ErrorLog /srv/www/example.org/logs/error.log
CustomLog /srv/www/example.org/logs/access.log combined
</VirtualHost>
With the proper write permissions, you can certainly do it. It does seem like you will want some seriously paranoid validation and testing before you restart apache after a write a new one because a malformed directive in there is a quick way to 500.
Edit: I'm not sure I would recommend giving your script the 'proper' write permissions in the first place.

Apache Error log: Log only for part of server

I'm running Debian on a VPS server, and have both the development and production code and database on the same server.
Is it possible to get the server to log only the errors for the development part of the server, and not the production. Right now, there are so many errors being logged from the production side, which makes it hard to get to the development errors.
Although this really belongs on serverfault.com:
You should definitely always log all errors.
If you host for example 2 domains on your server, example.com and test.example.com you can specify for each virtual host where you want to store the logs.
On apache your virtual hosts could look like:
<VirtualHost xxx.xxx.xxx.xxx:80>
// some configuration stuff
ServerName example.com
// some more configuration stuff
CustomLog /var/log/httpd/example.com-access_log combined
ErrorLog /var/log/httpd/example.com-error_log
</VirtualHost>
<VirtualHost xxx.xxx.xxx.xxx:80>
// some configuration stuff
ServerName test.example.com
// some more configuration stuff
CustomLog /var/log/httpd/test.example.com-access_log combined
ErrorLog /var/log/httpd/test.example.com-error_log
</VirtualHost>
So you can easily distinguish log information for test.example.com from example.com.

Why does my virtual host XAMPP not be able to display the php file?

I am trying to set up a virtual host so that I can run my .php file from Eclipse as a web page.
I follow the instructions from this discussion:
Make XAMPP/Apache serve file outside of htdocs
Scroll down to virtual hosts and the instruction is basically
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "/Users/Oky/Documents/eclipse/firstEclipseProject/"
ServerName firstEclipseProject.localhost
ErrorLog "/Users/Oky/Documents/eclipse/firstEclipseProject/logs/error_log"
<Directory /Users/Oky/Documents/eclipse/firstEclipseProject/>
Order allow,deny
Allow from all
</Directory>
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
The document is at /Application/XAMPP/etc/extra/httpd-vhosts.conf
Then I change the hosts file at /private/etc/hosts and at the bottom, I added
127.0.0.1 firstEclipseProject.localhost #firstEclipseProject
So, I think I am doing it right up to this point because when I fire my browser and point to firsteclipseproject.localhost, it redirects me to
firsteclipseproject.localhost/XAMPP/
which is the main XAMPP web page. It does not return an object/page not found which means the redirecting is somewhat working.
So, in /Users/Oky/Documents/eclipse/firstEclipseProject/
I created a php file called HelloWorld.php but when I point to firsteclipseproject.localhost/HelloWorld.php, it says object not found! I also tried firsteclipseproject.localhost/XAMPP/HelloWorld.php and it fails.
Any help is appreciated! Thanks!!!
I would suggest you leave the root directory the way it is and instead setup an Alias to your eclipse directory.
Did you restart apache after making config changes?

Categories