Setting up PHP for Apache on Windows - php

I have been trying to set up PHP from php.net in my Apache web server (localhost).
Over the last day and a half I've been chasing through documentation at the Apache site, the php.net site, SO, and anywhere else shows a hit for the current error, to try and solve the problems. Here are some details of my current set-up and (possible mis)understanding.
Define SRVROOT "/Apache/00"
ServerRoot "${SRVROOT}"
The public directory of Apache is set to htdocs. Apache is producing listings of the directories under it without any problems through localhost. Just to make bleeding sure that I have the right address and it it is Apache, I do an on/off test as described below.
I ran the Windows MSI supplied for PHP. Then I adjusted the /conf/httpd.conf file to add:
ScriptAlias /php/ "${SRVROOT}/php/"
AddType application/x-httpd-php .php
Note: php, htdocs (public files) & conf directories are all in the root of the same directory, SRVROOT.
Test Apache
http://localhost/lib/
might produce:
Index of /lib
Parent Directory
amd64/
web.jar
x86/
While shutting down Apache and refreshing the listing I see a FF error.
Unable to connect
Firefox can't establish a connection to the server at localhost.
So Apache itself seems to be working fine, when it is running I can do directory listings.
Test PHP
http://localhost/php/
Shows:
Forbidden
You don't have permission to access /php/ on this server.
OK that seems logical, Apache now acknowledges the existence of the directory but says it is not intended to by publicly browsed.
I have an phpinfo.php in the root of the php directory containing.
<?phpinfo();?>
I expect that if I browse to http://localhost/phpinfo.php is should give me information, but instead I get 404 message:
Not Found
The requested URL /phpinfo.php was not found on this server.
For http://localhost/php/phpinfo.php I get forbidden message:
Forbidden
You don't have permission to access /php/phpinfo.php on this server.
Typical error.log
sl:warn] [pid 1504:tid 336] AH01909: RSA certificate configured for localhost:443 does NOT include an ID which matches the server name
[Sun Aug 04 19:06:01.995343 2013] [ssl:warn] [pid 1504:tid 336] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Sun Aug 04 19:06:02.298078 2013] [ssl:warn] [pid 1504:tid 336] AH01909: RSA certificate configured for localhost:443 does NOT include an ID which matches the server name
[Sun Aug 04 19:06:02.298078 2013] [ssl:warn] [pid 1504:tid 336] AH02292: Init: Name-based SSL virtual hosts only work for clients with TLS server name indication support (RFC 4366)
[Sun Aug 04 19:06:02.300031 2013] [mpm_winnt:notice] [pid 1504:tid 336] AH00354: Child: Starting 64 worker threads.
[Sun Aug 04 19:06:03.279523 2013] [authz_core:error] [pid 1504:tid 1004] [client ::1:50589] AH01630: client denied by server configuration: I:/Apache/00/php/index.html
[Sun Aug 04 19:15:39.932843 2013] [authz_core:error] [pid 1504:tid 1004] [client ::1:50599] AH01630: client denied by server configuration: I:/Apache/00/php/
[Sun Aug 04 19:21:49.700421 2013] [authz_core:error] [pid 1504:tid 1004] [client ::1:50608] AH01630: client denied by server configuration: I:/Apache/00/php/phpinfo.php
[Sun Aug 04 19:26:58.432843 2013] [authz_core:error] [pid 1504:tid 1004] [client ::1:50621] AH01630: client denied by server configuration: I:/Apache/00/php/phpinfo.php
[Sun Aug 04 19:37:26.403546 2013] [mpm_winnt:notice] [pid 4400:tid 324] AH00422: Parent: Received shutdown signal -- Shutting down the server.
[Sun Aug 04 19:37:28.403546 2013] [mpm_winnt:notice] [pid 1504:tid 336] AH00364: Child: All worker threads have exited.
[Sun Aug 04 19:37:28.418195 2013] [mpm_winnt:notice] [pid 4400:tid 324] AH00430: Parent: Child process 1504 exited successfully.
Question
I want to show the phpinfo.php document. Can anyone see the dumb mistake I am making (I am a newbie at this)?
See also:
These are the primary docs I've been looking at:
http://httpd.apache.org/docs/2.4/
http://www.php.net/docs.php

You're probably getting the permission error because the phpinfo.php file does not have permissions set such that the Apache server you're running can read it. Apache can be configured to drop privileges to a limited user account when it runs, and if your file security permissions for a file don't allow that user account to read the file, you will get permission errors. Remember that this applies to every directory in the final path name, i.e. /Apache and /Apache/00 and /Apache/00/php and /Apache/00/php/phpinfo.php must ALL be readable by the user account that Apache runs under.
Another possibility is that you may need to add a Directory directive in httpd.conf to allow access to /php/ if your httpd.conf has a Directory directive for a default access policy of deny-first.
I also don't see any mention of where you've installed the PHP Apache module DLL into the Apache modules folder, nor where you've added the module in your httpd.conf file. If you don't load the PHP module, PHP files will not pass through PHP.

Related

500 Internal Server Error xampp codeignider and google adwords?

when i try to execute a module that need to use google adwords tha website don't do anything so i see in the inspect the element and say that have a 500 Internal Server Error, i search o sometimes say the is temporal error butt have two days with same error, so i read that maybe is xampp and permitions so i modificate the
httpd.conf, i change the ports i wirte the next code
<Directory />
AllowOverride All (also i tried with none)
Require all granted
</Directory>
i see the file hots in windows and set the 127.0.0.1 ....
i try to debug in app and i see that can pass in the next lines
$this->load->library('Google_adwords');
$objGoogleAdword = new Google_adwords();
I see the xampp php log
and see this error
[Wed Oct 11 13:22:14.132305 2017] [core:notice] [pid 1524:tid 576] AH00094: Command line: 'c:\xampp\apache\bin\httpd.exe -d C:/xampp/apache'
[Wed Oct 11 13:22:14.135264 2017] [mpm_winnt:notice] [pid 1524:tid 576] AH00418: Parent: Created child process 8216
[Wed Oct 11 13:22:15.475520 2017] [ssl:warn] [pid 8216:tid 520] AH01909: www.example.com:444:0 server certificate does NOT include an ID which matches the server name
[Wed Oct 11 13:22:15.747771 2017] [ssl:warn] [pid 8216:tid 520] AH01909: www.example.com:444:0 server certificate does NOT include an ID which matches the server name
[Wed Oct 11 13:22:15.832788 2017] [mpm_winnt:notice] [pid 8216:tid 520] AH00354: Child: Starting 150 worker threads.
well i don't know why doen't works some idea?

Laravel connection reset after any file changes

I have laravel 4.2 installed in a local environment (windows 10) for testing, but keep getting a connection reset error after updating any files.
My project will load and the server properly displays my pages. However if I update a file (index for example) and then try access a page that renders the newly updated file, I always get a connection reset error. Even a change as simple as a period.
Even more interesting is when I use php artisan to serve my files, I never get the connection reset problem. If I visit the page through artisan serve it works, and then all the sudden xampp wants to work, but only after I have loaded the page from artisan once before.
If I make changes to the file again I have to repeat this process.
Local Setup
My project is being hosted locally from xampp (v 3.2.2) with the following v-hosts config. The hosts files have also been properly configured.
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/myproject/public"
ServerName myproject.local
ServerAlias myproject.local
ErrorLog "logs/myproject.log"
CustomLog "logs/custom.myproject.log" combined
<Directory "C:/xampp/htdocs/myproject/public">
AllowOverride All
Require all granted
</Directory>
In short: I change a file, I get connection reset on xampp when trying to access that page. I view the page from artisan and then refresh the page on xampp, all the sudden it works.
Update
I have tried alternates such as laragon suggested by Lucas, however the same error persists. After updating any file when trying to access that page I get a connection reset error.
I have found more information looking at the apache log in laragon.
[Tue Mar 01 08:52:22.785519 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00428: Parent: child process 8276 exited with status 3221225725 -- Restarting.
[Tue Mar 01 08:52:22.928687 2016] [ssl:warn] [pid 6748:tid 544] AH01909: www.example.com:8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 01 08:52:22.938712 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00455: Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.16 configured -- resuming normal operations
[Tue Mar 01 08:52:22.938712 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00456: Apache Lounge VC11 Server built: Oct 13 2015 10:54:13
[Tue Mar 01 08:52:22.938712 2016] [core:notice] [pid 6748:tid 544] AH00094: Command line: 'C:\\laragon\\bin\\apache\\apache-2.4.17/bin/httpd -d C:/laragon/bin/apache/apache-2.4.17'
[Tue Mar 01 08:52:22.939695 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00418: Parent: Created child process 3672
[Tue Mar 01 08:52:23.214917 2016] [ssl:warn] [pid 3672:tid 532] AH01909: www.example.com:8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 01 08:52:23.296629 2016] [ssl:warn] [pid 3672:tid 532] AH01909: www.example.com:8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 01 08:52:23.306647 2016] [mpm_winnt:notice] [pid 3672:tid 532] AH00354: Child: Starting 64 worker threads.
[Tue Mar 01 08:52:24.159843 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00428: Parent: child process 3672 exited with status 3221225725 -- Restarting.
[Tue Mar 01 08:52:24.305896 2016] [ssl:warn] [pid 6748:tid 544] AH01909: www.example.com:8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 01 08:52:24.315916 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00455: Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.16 configured -- resuming normal operations
[Tue Mar 01 08:52:24.315916 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00456: Apache Lounge VC11 Server built: Oct 13 2015 10:54:13
[Tue Mar 01 08:52:24.315916 2016] [core:notice] [pid 6748:tid 544] AH00094: Command line: 'C:\\laragon\\bin\\apache\\apache-2.4.17/bin/httpd -d C:/laragon/bin/apache/apache-2.4.17'
[Tue Mar 01 08:52:24.317905 2016] [mpm_winnt:notice] [pid 6748:tid 544] AH00418: Parent: Created child process 3600
[Tue Mar 01 08:52:24.580068 2016] [ssl:warn] [pid 3600:tid 552] AH01909: www.example.com:8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 01 08:52:24.666114 2016] [ssl:warn] [pid 3600:tid 552] AH01909: www.example.com:8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 01 08:52:24.675120 2016] [mpm_winnt:notice] [pid 3600:tid 552] AH00354: Child: Starting 64 worker threads.
This issue was finally resolved with a configuration change with Apache.
Add the following to the httpd.conf file:
<IfModule mpm_winnt_module>
ThreadStackSize 8888888
</IfModule>
Then Restart.
The problem is that windows has a smaller stack size by default than on the Linux/Unix systems. It took me a while to figure this out. Apache was silently crashing and I was getting no errors in my logs making it hard to trace.
The project I am working on has large regular expression calls and apparently this was a known trigger to cause this issue with apache on windows. If you look at apache documentation we can update the ThreadStackSize to a value closer to Unix/Linux systems of 8MB.
http://httpd.apache.org/docs/2.2/mod/mpm_common.html#ThreadStackSize
I hope this helps anyone else developing on a windows system running apache as a local server. This was a major headache for some time.
php artisan serve use the PHP built on server (php -S localhost:80 -t public) to host the application.
Maybe the problem can be your apache configuration, so try this:
# define DOCROOT variable
define DOCROOT "C:/xampp/htdocs"
<Directory "${DOCROOT}">
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/myproject/public/"
ServerName myproject.dev
</VirtualHost>
if the problem persists, try use Laragon and open it always as administrator.
Opening php error log may help you find the real problem. there was an error in my codes( using isset() directly on a function )

XAMPP on windows. Apache Shutdown Unexpectedly. Apache not starting

This is a common issue where the port is already in use by other applications. But I have corrected the issue from skype where it was using port 80 and 443. But I am not sure what else application might be preventing apache from running.
Here is the error log
Error: Apache shutdown unexpectedly.
This may be due to a blocked port, missing dependencies,
improper privileges, a crash or a shutdown by another method.
Press the Logs button to view error logs and check.
the Windows Event Viewer for more clues.
IF you need more help,
copy and post this entire log window in the forum
I have checked the error log file. It would be nice if anyone would kindly explain me the issue. I am new in using xampp
[Mon Jan 11 15:41:31.711045 2016] [ssl:warn] [pid 6344:tid 768] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Jan 11 15:41:33.542795 2016] [ssl:warn] [pid 6344:tid 768] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Jan 11 15:41:37.708844 2016] [mpm_winnt:notice] [pid 6344:tid 768] AH00455: Apache/2.4.17 (Win32) OpenSSL/1.0.2d PHP/5.6.15 configured -- resuming normal operations
[Mon Jan 11 15:41:37.709343 2016] [mpm_winnt:notice] [pid 6344:tid 768] AH00456: Apache Lounge VC11 Server built: Oct 13 2015 10:54:13
[Mon Jan 11 15:41:37.709343 2016] [core:notice] [pid 6344:tid 768] AH00094: Command line: 'D:\\xampp\\apache\\bin\\httpd.exe -d D:/xampp/apache'
[Mon Jan 11 15:41:37.963876 2016] [mpm_winnt:notice] [pid 6344:tid 768] AH00418: Parent: Created child process 5008
[Mon Jan 11 15:41:44.877326 2016] [ssl:warn] [pid 5008:tid 688] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Jan 11 15:41:46.246564 2016] [ssl:warn] [pid 5008:tid 688] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Mon Jan 11 15:41:46.644423 2016] [mpm_winnt:notice] [pid 5008:tid 688] AH00354: Child: Starting 150 worker threads.
Well if you read the messages from Apache it is quite obvious you have tried to activate SSL and there is a problem with what you have done.
I think this part of the error message from XAMPP is most relevant a crash or a shutdown by another method.
Assuming you did this by uncommenting the Include conf/extra/httpd-ssl.conf line in httpd.conf then just comment that line out again and then try and fix your SSL config.
As suggested by the error message, look at the Windows Event Viewer. Apache writes there as well as its log file. SOmetimes the errors shown in Event Viewer are very descriptive and will identify a line number in a config file where the error exists
RE Your comment :
I had previous installation of xamp on my system. I had deleted the source folder of xampp and reinstalled xampp
Its possible that as you did not uninstall the old version of XAMPP something from the old version is still registered with your system and that is what is causing this odd situation.
I would uninstall this XAMPP (properly) and then check if you still have an Apache and/or MYSQL service registered, look using the services snapin.
If they are still there you can remove them like this (sc delete ) :-
Start command window using "Run as Administrator"
sc delete MYSQL
sc delete Apache
Make sure you have backed up any databases, although it may already be to late for this.
Then you can re-install the version of XAMPP you want to use.

500 Internal Server Error in PHP files

I have a problem. I installed CentOS Web Panel and varnish cache on my VPS server. I have two domains, two hosts on a VPS. One website is using WordPress other is not. Now everything on non-wordpress site is working (html,js,css,picture files...) fine except that PHP files are not working now(Same on WordPress). Just one file is working named testmail.php, which contains: <?php echo phpinfo(); ?>
Here is apache error log:
[Sat Jul 04 16:29:29 2015] [error] [client 172.***.***.***] Premature end of script headers: testip.php
[Sat Jul 04 16:29:37 2015] [notice] caught SIGTERM, shutting down
[Sat Jul 04 16:29:39 2015] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sat Jul 04 16:29:39 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/local/apache/bin/suexec)
[Sat Jul 04 16:29:40 2015] [notice] Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1e-fips configured -- resuming normal operations
[Sat Jul 04 16:42:07 2015] [notice] caught SIGTERM, shutting down
[Sat Jul 04 16:42:21 2015] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
[Sat Jul 04 16:42:21 2015] [notice] suEXEC mechanism enabled (wrapper: /usr/local/apache/bin/suexec)
[Sat Jul 04 16:42:22 2015] [notice] Apache/2.2.27 (Unix) mod_ssl/2.2.27 OpenSSL/1.0.1e-fips configured -- resuming normal operations
I've noticed that i have two php.ini files one is at /etc/php.ini other is at /usr/local/php/php.ini (used by server) and I also have two httpd.conf files one is at /etc/httpd/conf/httpd.conf other is at /usr/local/apache/conf/httpd.conf (used by server). I've also noticed that there are no modules(mod_rewrite.so.. or any other) in second apache config file(used by server).
I tried to change ownership (chown) and tried to change file permissions (chmod) but nothing works. Can you help please?
500 Internal Server Error occurs from following reason. you can solve by followng:-
1.If you have not given file permsission you can get this error. Please give file permission.
Or Open Apache’s httpd.conf file
you have to find following lines, and remove #
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule headers_module modules/mod_headers.so
you can also check your htaccess is file or folder is allowed or not.

Server truncates/interrupts output when request comes from external computer, but not from 127.0.0.1

Setup:
EasyPHP Dev server 13.1VC11 (Apache 2.2.4, MySQL 5.6.12, PHP 5.5.0)
Windows 7.
Apache is set up with multiple virtual hosts each pointing to a separate folder under ...data\localweb\.
Server also acts as a gateway between internet and local network.
My wife has made a webpage which includes JavaScript and jQuery and PHP.
When I open a browser on my server computer and access the pages, everything works as they should. Via both these addresses:
http://127.0.0.1/liselotte/projekt5/2vs.php
http://liselotte.mine.nu/projekt5/2vs.php
However, when I try to access the page from another computer on my local network, the two longer pages in my wife's project gets truncated. (file 2vs.php, also accessible on the page's main menu as "V/S") It always gets truncated at the same place, in the middle of a 8-letter word, in a piece of HTML formatted text.
I use Firefox and can see when the code cuts off before the browser displays an error message that "transfer was aborted". (It's in Swedish, so I'm a bit uncertain about the exact wording of the message) "The connection to the server was severed during retrieval of the page". (no HTTP-error number)
I have also tried Internet Explorer and Chrome, transfer is cut off at the exact same place every time.
Weirdly enough, the page seems to work when accessed from internet.
The Apache config file contains
Listen 127.0.0.1:80
Listen trilliadin.mine.nu:80 #which is one of the virtual hosts
Listen 192.168.137.1:80 #which is Windows local address assigned to my LAN
I've tested disabling all firewalls, but no difference.
I dumped about 4MB text into a file.html to see if this also gets truncated but the whole text-file gets transferred.
Does anyone recognize these symptoms?
EDIT:
Regarding error-reporting... I do get some weird apache-errors when I start the server.
[Wed Jan 15 21:13:37.989659 2014] [mpm_winnt:notice] [pid 968:tid 424] AH00424: Parent: Received restart signal -- Restarting the server.
Failed loading D:\EasyPHP\binaries\php\php_runningversion\php_xdebug-2.2.2-5.4-vc9.dll
PHP Warning: PHP Startup: in Unknown on line 0
[Wed Jan 15 21:13:39.861663 2014] [mpm_winnt:notice] [pid 968:tid 424] AH00455: Apache/2.4.4 (Win32) PHP/5.5.0 configured -- resuming normal operations
[Wed Jan 15 21:13:39.861663 2014] [mpm_winnt:notice] [pid 968:tid 424] AH00456: Server built: Apr 8 2013 13:46:39
[Wed Jan 15 21:13:39.861663 2014] [core:notice] [pid 968:tid 424] AH00094: Command line: 'D:\\EasyPHP\\binaries\\apache\\bin\\apache.exe -d D:/EasyPHP/binaries/apache'
[Wed Jan 15 21:13:39.861663 2014] [mpm_winnt:notice] [pid 968:tid 424] AH00418: Parent: Created child process 5240
[Wed Jan 15 21:13:40.017663 2014] [mpm_winnt:notice] [pid 5328:tid 436] AH00364: Child: All worker threads have exited.
Failed loading D:\EasyPHP\binaries\php\php_runningversion\php_xdebug-2.2.2-5.4-vc9.dll
PHP Warning: PHP Startup: in Unknown on line 0
[Wed Jan 15 21:13:41.655666 2014] [mpm_winnt:notice] [pid 5240:tid 432] AH00354: Child: Starting 64 worker threads.
But I don't understand what it means. Tonight, the Virtual Host liselotte.mine.nu became unresponsive, while virtual host trilliadin.mine.nu continued working. The problem resolved when I restarted the apache server. (see error log above)

Categories