PHP install fails on file does not exist - php

on cmd: C:\Apache24\bin>httpd -t
Received message:
httpd: Syntax error on line 540 of C:/Apache24/conf/httpd.conf: Cannot load C:/php/php8apache2_4.dll into server: The specified module could not be found.>
And, in fact, C:\php\php8apache2_4.dll does not exist in my C:\php folder.
Do I specify a different php8 ... .dll or must I find and install the php8apache2_4.dll? And if the latter, where do I look?
Background:
Based on https://www.youtube.com/watch?v=oJnCEqeAsUk&t=4s entitled "Install & Set Up Apache Web Server on Windows 10", I installed Apache/2.4.55(Win64) server after download and extract from Apache Lounge into the C:\Apache folder I created.
Based on https://www.sitepoint.com/how-to-install-php-on-windows/#installingphp I created a C:\php folder into which I extracted a downloaded PHP from the x64 Thread Safe ZIP package from https://windows.php.net/download/ . I renamed a copy of C:\php\php.ini-development to C:\php\php.ini. Then enabled extension=curl, extension=gd, extension=mbstring and extension=pdo_mysql. I then added C:\php to the PATH system environment variables.
I then opened C:\Apache24\conf\httpd.conf and added
# PHP8 module
PHPIniDir "C:/php"
LoadModule php_module "C:/php/php8apache2_4.dll"
AddType application/x-httpd-php .php
and changed dir_module to read:
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
Then, from the command line I attempted
cd C:\Apache24\bin
httpd -t
Upon which I received the "could not be found module" message.
I am running MS Windows 10 Home Version 19044 on a Dell Inspiron 15-3567 Dell laptop x-64 based PC

Related

Xampp Cannot load C:/xampp/php/php7ts.dll into server: The specified procedure could not be found

I am posting this question because the answers that are on this site are more than 5 years ago and none of the suggestions work. This seems like something that should not be happening now but it is. It is a windows server 2008 and it had a previous version of Xampp running before I downloaded the latest 7.2.28.
Which is running the PHP5.x. I check the config of the old program and it looks just like the new one. IIS is not running.
The whole error message.
The Apache service named reported the following error:
httpd.exe: Syntax error on line 537 of C:/xampp/apache/conf/httpd.conf: Syntax error on line 17 of C:/xampp/apache/conf/extra/httpd-xampp.conf: Cannot load C:/xampp/php/php7ts.dll into server: The specified procedure could not be found. .
Yes, I have gone to the folder and the file does exist. I have checked the path and added C:/ in front of the path to the directories and no change.
I have checked the Visual Studio installs with the httpd.exe -v. I installed the latest versions anyway and rebooted the server and still get the same error. MySQL starts up just fine.
Is there something wrong with the environment variable?
#
# XAMPP settings
#
<IfModule env_module>
SetEnv MIBDIRS "/xampp/php/extras/mibs"
SetEnv MYSQL_HOME "\\xampp\\mysql\\bin"
SetEnv OPENSSL_CONF "/xampp/apache/bin/openssl.cnf"
SetEnv PHP_PEAR_SYSCONF_DIR "\\xampp\\php"
SetEnv PHPRC "\\xampp\\php"
SetEnv TMP "\\xampp\\tmp"
</IfModule>
Here are the lines in question and the changes I made to them.
# PHP-Module setup
#
LoadFile "C:/xampp/php/php7ts.dll"
LoadFile "C:/xampp/php/libpq.dll"
LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"
If I comment out the LoadFile "C:/xampp/php/php7ts.dll then the next line does not load either.
Should I put a path statement in the windows environment settings?
I ran the setup_xampp.bat file and this these are the results of that and the test_php.bat file.
################################# START XAMPP TEST SECTION #####################
############
[XAMPP]: Test php.exe with php\php.exe -n -d output_buffering=0 --version ...
[XAMPP]: Test for the php.exe successfully passed. Good!
################################# END XAMPP TEST SECTION #######################
############
################################# START XAMPP TEST SECTION #####################
############
[XAMPP]: FIRST TEST - Searching for an installed Microsoft Visual C++ 2015 runti
me package in the registry ...
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\DevDiv\vc\Servicing\14.0\Runti
meMinimum
Version REG_SZ 14.0.24123
[SUCCESS]: Microsoft Visual C++ 2015 Redistributable Package found! Good!
[XAMPP]: SECOND TEST - Execute php.exe with php\php.exe -n -d output_buffering=0
--version ...
[SUCCESS]: Test for the php.exe successfully passed. Good!
################################# END XAMPP TEST SECTION #######################
###########

test.php is returning page not found

It's my first webpage and everything was ok until I had to set up server and install PHP to star coding the back end part.
I installed MySQL 1.4, Visual Studio 2015, VC14, Apache 2.4 and PHP 7.1.
MySQL is running as well as Apache. I was able to open localhost:8080 with the message "It works" but when I try localhost:8080/test.php it opens a 404 page not found.
The error log in Apache folder says:
[php7:error] [pid 3276:tid 956] [client ::1:65240] script 'C:/Apache24/htdocs/test.php' not found or unable to stat
The test.php file is on Apache24/htdocs.
I've already tried so many options, installed and deinstalled versions of PHP, Visual Studio, and nothing. Thank you for helping me.
Here is the httpd file which I edited:
I added those 4 line at the beginning:
AddHandler application/x-httpd-php .php AddType
application/x-httpd-php .php .html LoadModule php7_module
"c:/php7/php7apache2_4.dll" PHPIniDir "c:/php7"
Definde the SeverRoot:
Define SRVROOT "c:/Apache24" ServerRoot "c:/Apache24"
Changed the Listen port
Listen 8080
List item
Changed the ServerName localhost: ServerName localhost:8080
DocumentRoot
DocumentRoot "c:/Apache24/htdocs"
"c:/Apache24/htdocs">
put your test.php at folder XAMPP/htdocs. XAMMP Panel, turn on Apache and MySQL. Then open your browser and type localhost/test.php

PHP seems work in terminal but not in browser

I'm using Fedora 23 and I have installed apache and php using dnf. Opening localhost on browser shows Fedora Test Page of Apache, so Apache is working.
After install php, I don't know why but none of php settings were in httpd.conf, so following this answer: https://stackoverflow.com/a/5121589/4701452 adapting to Fedora with this
http://ahmed.amayem.com/enabling-php-in-apache-on-linux-centos-6-by-loading-the-module-in-httpd-conf/
and this
http://tech.amikelive.com/node-369/quick-tip-how-to-install-and-configure-php-in-fedora-linux/
I've added the following to my httpd.conf:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
DirectoryIndex index.html index.php
I've restarted apache and when I open a script with:
<?php
phpinfo();
?>
It still doesn't work. In Chrome it shows the script code in Firefox it shows nothing.
PHP is recognized by php -v
And when executed by terminal: php -r "phpinfo();"
It shows lots of information as it was suppose to do in the script:
PHP Version => 5.6.29
System => Linux localhost.localdomain 4.8.15-200.fc24.x86_64 #1 SMP Thu Dec 15 23:09:22 UTC 2016 x86_64
Build Date => Dec 8 2016 09:17:06Server API => Command Line Interface
Virtual Directory Support => disabled
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
Scan this dir for additional .ini files => /etc/php.d
Additional .ini files parsed => /etc/php.d/20-bz2.ini,
[AND MUCH MORE INFORMATION...]
try disabling SElinux
so this is not the recommended way of doing this, but it should work.
worked for me.
vim /etc/selinux/config
and set
SELINUX=disabled
and restart.
it should work though, you should read up on selinux because it's super interesting.
PS.
also, you shouldn't have to add anything to your httpd.conf file

Getting blank PHP page over Apache

In a newly setup digitalOcean cloud server (CentOS), I have installed php and Apache. The webserver is running fine:
[root#a2m5cent01 httpd]# service httpd status
httpd (pid 11232) is running...
[root#a2m5cent01 httpd]# php --version | head -1
PHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57)
But browser is showing blank pages (white page) if I try to visit any php page.
Here is what I have done so far to troubleshoot:
Created a page with following content: <?php phpinfo(); ?>. It displays a blank page when viewed from browser.
Just to ensure, apache is pointing to the correct directory, placed a static .html page there, and saw it comes out fine in browser, so apache is working and directory is correct.
In /etc/php.ini, changed display_errors directive to On. Still blank page
In Apache config file (/etc/httpd/conf/httpd.conf) found this line Include conf.d/*.conf. Inside conf.d directory, there is a php.conf file containing the line:
LoadModule php5_module modules/libphp5.so. Ensured that this .so file actually exists in this place.
In the same file I have these two lines as well: AddHandler php5-script .php and AddType text/html .php
Executed the php page from CLI, it works fine - so php is working locally.
Then why is it always shows a blank/white page over the browser? What else am I missing?
EDIT
Based on suggestions from #Nathan,
I checked Apache error log file, could not see any error being
reported there.
My /etc/php.ini says, php error_log is located as syslog. So I checked /var/log/messages but could not find any PHP error message
Next I put some normal HTML in the php file containing phpinfo() call. Interestingly I found that even the normal HTML texts are also not coming. It still produces blank page.
Then I checked Apache access log. Surprise! There is no GET request for any of the PHP files I tried to load in the browser. But GET request for all the non-php files are there with 200 return code.
Apache is not even logging any access request for PHP files. Any idea why would that happen?
check out your phpinfo() script.
<?php
phpinfo();
?>
missing the "php" behind the first "?" will give a blank page
I think your php installation with apache is faulty. Thats why you can not see any php page in your webserver. Clean remove all the existing apps, like httpd,php,php-fpm,php-cli etc. and try to clean isntall in this order
yum install httpd -y
yum install php php-common php-cli php-gd php-curl php-fpm -y
then make sure you restart yout httpd server.
service httpd restart
Install mod_fastcgi:
yum install mod_fastcgi
Start the service:
service php-fpm start
Restart Apache:
service httpd restart
5. Configuration of Apache with PHP-FPM
Open the fastcgi.conf file:
nano /etc/httpd/conf.d/fastcgi.conf
Add this to the end of the file:
<IfModule mod_fastcgi.c>
DirectoryIndex index.html index.shtml index.cgi index.php
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization
</IfModule>
After that search after "FastCgiWrapper" and make sure it's set to "off" then save the file.
The /usr/lib/cgi-bin/ directory must exist, so we create it:
mkdir /usr/lib/cgi-bin/
If mod_php is installed and enabled, we need to disable it so open the configuration at /etc/httpd/conf.d/php.conf:
nano /etc/httpd/conf.d/php.conf
Comment out the AddHandler and AddType lines so it looks like here:
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
<IfModule prefork.c>
LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
LoadModule php5_module modules/libphp5-zts.so
</IfModule>
#
# Cause the PHP interpreter to handle files with a .php extension.
#
#AddHandler php5-script .php
#AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps
Save the file and restart Apache:
service httpd restart
Are you navigating to the php file directly? Or are you just going to the directory root?
If the later, Apache might not be recognizing .php as the directory index.
To test, try create a .htaccess file in your web root containing the following line:
DirectoryIndex index.php
I have the same issue...
The problem is in the iptables. (It seems like it)
Try with:
service iptables stop
## check if it stop...
service iptables status
Then try to reload the page again.
If you had other solution please share.
[edit]
Restarting the iptables service is working for me.
Try:
service iptables restart
First of all you should check the permissions of your file.
If you don't grant read-permission to public, Apache produces a blank page without showing any errors.
It's been sometime, but I wanted to come back to this question to update that the issue was with the directory permission setup.
The FPM user I was using didn't have necessary permission to execute the index.php file in the web root.
To avoid these issues in the future, I have created an automated bash script that will automatically create and configure webservers in DigitalOcean boxes. Please take a look here https://github.com/akash-mitra/fairy
This script will automatically,
Installs Nginx
Create virtual server block for nginx
Installs PHP, PHP APC, PHP Curl etc.
Supports PHP Fast Process Manager (php-fpm)
Installs Memcached
Installs Database (MariaDB / MySQL)
Optionally Installs PHP Composer and Laravel
Configures and Strengthens SSH
Activates Firewall
Optionally enables SWAP space in DO server and fixes a locale issue
Since everything looks at its default state, have you checked this part just for confirmation
cat /etc/php.ini | grep log_errors
If log_errors is disabled then enable it and check this below log after restarting httpd.
/var/log/httpd/error_log
--
Also check this part from php configuration.
cat /etc/php.ini | grep error_reporting
This value should be enabled by default so that display_errors will work.
error_reporting = E_ALL
Sorry to repost an old thread...this is important.
I also was having these problems where no html response was outputting
After double-checking php.ini or my apache conf files and was still receiving no output, I later found out that I was suppressing the error of an include / require of a class, with #, which was nested within a constructor function. There was a syntax error in the included file, which stopped all output altogether when errors were thrown.
So, check your handlers first.
If you are storing all your output into vars first and you are including various scripts first that fail you'll have to see those errors. If you suppress file handler errors, you'll get a blank screen if you have a syntax error in the file.
Search your files for all instances of # in your php code. Then turn #include "/path_to/script.php"; to include "/path_to/script.php"; or anything #$foo into $foo as such var might reference a dependency that is causing your script to end with nothing showing in the httpd error log or in the http response.

Installing PHP, MySql and Apache on windows

Its my first time working with Apache,PHP,MySql. I downloaded and installed the latest package of these 3. Now I checked with apache and the index.html works. Now I replaced the index.html with some php script to check if my php works or not. When opened the html page again I see the php code directly. It seems it does not work. following is how my php code looks like.
<html>
<body>
<?php
echo "Hello World";
?>
</body>
</html>
when I open my index.php , I see the above code itself. Can anybody let me know whats wrong and how can i fix it?
Check your apache httpd.conf file for some commented out code that looks like this
LoadModule php5_module libexec/apache2/libphp5.so
and further down the file, this...
<IfModule php5_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
it seems there is some problem in the installation. use WAMP as stefan and dessus or XAMPP. i recomand u to use XAMPP its bundled with APACHE, MYSQL, File Zilla Server, Mercury for mail. Easy to Install and Use . http://www.apachefriends.org/en/xampp.html
Another vote for WampServer. Once you have a working server, it's then easier to poke around with configurations files and then learn Apache/PHP configuration that way.
use wamp! it's easy and fast :)
http://www.wampserver.com/en/
personally, i use an old version from 2007, 1.7.4, it can be found here: http://sourceforge.net/projects/wampserver/files%2FWAMP5/
the good thing about using an old version is that your code will work on old machines, and many servers out there have old versions of php and mysql.
the bad thing about using an old version is that your code might not work on new machines, and some machines out there have new versions of php and mysql.
http://computing-know.blogspot.in/#!/2013/10/how-to-setup-apache-php-mysql.html
Step By Step Process to Setup Apaache,PHP,Mysql,phpMyAdmin and XDebug.
1)How to install Apache
2)Setup PHP for Apache
3)Install & Configure MySQL to use with PHP
4)Setup XDebug for Debugging
5)phpMyAdmin
Note:In this tutorial my Server Folder is located on F:\Server
How to install Apache
1)There are two ways to install apache either install the old version of apache httpd (Compatible with Windows XP) from httpd.apache.org/download.cgi or get the latest apache build zip from www.apachelounge.com/download/ .
2)I will show how to configure apache from the zip version downloaded from apachelounge.com/download/ .
3)Click on Additional + VC9 on the left of the page.
4)Download the 2.4.x zip build with OpenSSL 0.9.8.
5)Create a folder with a name Server on location where .
6)My Location is F:\Server
7)Extract the Apache24 from apache zip to the Server folder.
8)Now Goto config folder in Apache and open httpd.config in any text editor.
9)Find(Ctrl + F) and replace each and every instance of "c:/Apache24" and change it to your apache location in my case its f:/Server/Apaache24.
ServerRoot "c:/Apache24" with ServerRoot "f:/Server/Apache24"
DocumentRoot "c:/Apache24/htdocs" with DocumentRoot "f:/Server/Apache24/htdocs"
with
ScriptAlias /cgi-bin/ "c:/Apache24/cgi-bin/" with ScriptAlias /cgi-bin/ "f:/Server/Apache24/cgi-bin/"
with
8)Now run the Command Prompt (with Administrator Rights) .
9)On Command Prompt go to the location Server/Apache24/bin .
10)Inside the Bin folder type "httpd -k install" to install the Apache service and then press Enter.
11)To start the Apache Server simply type in "httpd -k start" and then press Enter.
12)Restart Your Computer
13)Now Open the Bin folder and double click on the ApacheMonitor.exe and Start Apache
14)Now Goto localhost if you see page "It Works" then Apache is sucessfully installed on you computer.
If you see a page that says "It works!" then the Apache server has been installed successfully.
Setup PHP for Apache
1)Goto windows.php.net/download/ download the php-5.4.x-Win32-VC9-x86.zip.
2)Create a folder named php inside Server folder.
3)Extract all files from php-5.4.x-Win32-VC9-x86.zip to php folder in the Server.
4)Now Goto config folder in Apache and open httpd.config in any text editor.
5)Find(Ctrl + F) the LoadModule scroll down until last LoadModule and Paste the following
LoadModule php5_module "f:/Server/php/php5apache2_4.dll".
6) Find(Ctrl + F) the AddType scroll down until last AddType and Paste the following
AddType application/x-httpd-php .php .
7)Add the PHP location to the end of the httpd.conf file. For example, at the end of the file, add the following: PHPIniDir "Your PHP Location".
localhost/info.php
8)In the php folder rename the php.ini-development to php.ini and open it in Text Editor.
9)Find(Ctrl + F) the display_errors, and make sure the value is set to On.
10) Find(Ctrl + F) the extension_dir = "./" and change it to extension_dir = "F:\Server\php\ext" .
11)Restart Apache Server.
12)Create a file "phpinfo.php" in htdocs folder in Apache with follwoing content:
13)Goto localhost/phpinfo.php
extension_dir = "./"
14)Right Click MyComputer Click Propertes
15)Click Environment Variables
16)Add Your php folder location at the end of the path
17)Restart Your Computer.
Install & Configure MySQL to use with PHP
1)Goto dev.mysql.com/downloads/mysql/ download the zip or installer version.
2)Install MySQL
3)Click Next
4)Select Complete & click Next
5)Click Finsh
6)Click Standard Configuration
7)Click Next
8)Enter the password for mySQL
9)Goto MySQL Command Line and enter the password.
12)Open the php.ini file and find the line: ;extension=php_mysql.dll remove the semi-colon.
and find the line: ;extension=php_mysql.dll
phpMyAdmin
1)Goto config folder in Apache and open httpd.config in any text editor.
2) Find(Ctrl + F) the line DirectoryIndex index.html add index.php.
3)Open php.ini file in the Server Folder and Uncomment the mbstring and mysqli extension.
3)Goto phpmyadmin.net/ Download the latest phpMyAdmin-4.0.8-english.zip.
4)Extract it to phpMyAdmin folder in htdocs.
5)Restart the Apache Server.
6)Goto localhost/phpMyAdmin/
Setup XDebug for Debugging
1)Goto http://xdebug.org/download.php from your browser and download the
php_xdebug-2.x.x-5.4-vc9 Thread Safe 32 bit version.
2)Copy and Paste it to the extension folder in the php.
3)Copy & Paste the following line of code at the end of php.ini file .
[XDebug]
;; Only Zend OR (!) XDebug
zend_extension="Your Location of Xdebug"
xdebug.remote_enable=true
xdebug.remote_host=localhost
xdebug.remote_port=10000
xdebug.remote_handler=dbgp
4)Restart Apache Server.
5)Goto to localhost/phpinfo.php scroll down to see if xDebug is installed

Categories