I try to install php on a mac M1 monterey, but this simple code is not interpretated :
<?php phpinfo(); ?>
I installed php with brew
brew install php
brew link php
I signed the libphp module
codesign --sign "certificate" --force --keychain ~/Library/Keychains/ /opt/homebrew/Cellar/php/8.1.2/lib/httpd/modules/libphp.so
Should I use the dynamic link instead ?
/opt/homebrew/opt/php/lib/httpd/modules/libphp.so
Loading the module in the apache2.conf file
LoadModule php_module /opt/homebrew/Cellar/php/8.1.2/lib/httpd/modules/libphp.so "certificate"
enable php page to be view in the apache2.conf file
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
result of which php
/opt/homebrew/bin//php
Is the double slash normal here ?
I can access the index.php of my web directory but php is still not executed.
Thanks
As I mentioned in the comments you probably done most the steps but this guide I found has one last step it mentions for PHP. Here is the link:
https://wpbeaches.com/updating-to-php-versions-7-4-and-8-on-macos-12-monterey/
Also I found a lot of my issues went away when I started using homebrew Apache instead.
I am glad the guide was able to help you get it working.
For anyone else who is stuck, here is the relevant section from the guide:
PHP 8 and macOS Apache
One extra step is needed for PHP 8 and macOS bundled Apache:
sudo nano /etc/apache2/httpd.conf
Add the new PHP 8 and comment out the old one.
LoadModule php_module /usr/local/opt/php#8.0/lib/httpd/modules/libphp.so
Go to the end of the file and add:
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
Restart Apache
Sometimes php configs are added through "other" configs if you have a line as below at the end of your httpd.conf
Include /private/etc/apache2/other/*.conf
Check config files under /private/etc/apache2/other/ and make necessary changes. I had a file called +php-osx.conf in that folder I edited as following:
LoadModule php_module /usr/local/opt/php#8.0/lib/httpd/modules/libphp.so
<FilesMatch .php$>
SetHandler application/x-httpd-php
</FilesMatch>
<IfModule php_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
Related
On Windows 10 Pro, after downloading PHP 8, switching to it in Laragon (PHP > Version) and restarting Apache, I get the following error:
httpd: Syntax error on line 546 of
C:/laragon/bin/apache/httpd-2.4.35-win64-VC15/con...:
Syntax error on line 2 of
C:/laragon/etc/apache2/mod_php.conf: Can't locate
API module structure 'php8_module' in file
C:/laragon/bin/php/php-8.0.2-Win32-vs16-x64/php8a...:
No error
After a fair bit of head scratching, the fix was fairly simple - in file
C:/laragon/etc/apache2/mod_php.conf
I changed
LoadModule php8_module to LoadModule php_module
It seems Laragon fouls up the auto-configuration of PHP 8
GOTO
C:/laragon/etc/apache2/mod_php.conf
AND REPLACE THIS
#This file is auto-generated, so please keep it intact.
LoadModule php8_module "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64/php8apache2_4.dll"
PHPIniDir "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64"
<IfModule mime_module>
AddType application/x-httpd-php .php
</IfModule>
WITH THIS
#This file is auto-generated, so please keep it intact.
LoadModule php_module "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64/php8apache2_4.dll"
PHPIniDir "C:/laragon/bin/php/php-8.0.6-Win32-vs16-x64"
<IfModule mime_module>
AddType application/x-httpd-php .php
</IfModule>
I have a problem with apache and PHP 5.4 running on a centOS 7 machine.
Apache host have the directory index option:
<Directory my/directory>
Options Indexes
</Directory>
The directory where apache points to contains a index.php. But when I navigate the browser to the related website, the browser only shows the php code.
I've already checked, if php is activated in http.conf - and it is. The application (zabbix) should work with this version of PHP and all necessary SQL- and PHP-plugins are installed.
No more Google suggestions for this problem - any of you an idea how to solve this?
Output of /etc/http/conf.d/php.conf:
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
AddType text/html .php
DirectoryIndex index.php
#<FilesMatch \.phps$>
# SetHandler application/x-httpd-php-source
#</FilesMatch>
php_value session.save_handler "files"
php_value session.save_path "/var/lib/php/session"
Please check below thinks in your httpd config file
LoadFile "D:/wamp/php/libpq.dll" // Your sepcified path
LoadModule php5_module "D:/wamp/php/php5apache2_4.dll" // Your sepcified path
AddType application/x-httpd-php .php // Your sepcified path
PHPIniDir "D:/wamp/php" // Your sepcified path
You probably installed PHP from the distribution packages. If so, make sure Apache was restarted after that:
sudo systemctl restart httpd
If that does not help, try reinstalling the PHP packages, then restarting Apache.
If that does not help, post the contents of /etc/httpd/conf.d/php.conf here.
I am a noob in reference to apache. I am trying to set it on El Capitan.
1. I have enabled "LoadModule php5_module" and placed the helloWorld.php in my document root. (/Library/Webroot/Documents) (I don't need user based document root.)
2. If I run the php from the terminal then it works.
3. But it does not work when I run through the browser. It complains that I need to enable ExecCGI.
4. If I enable ExecCGI for my documentRoot then I get the error about malformed header.
5.My understanding was, I don't need to treat php scripts as CGI, if I enable php5_module and that's why I don't need ExecCGI.
(I do have some other cgi directory which has some python scripts and they work fine.)
I also have following lines in my httpd.conf
<IfModule php5_module>
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddHandler php5-script .php
</IfModule>
Could some one suggest where I must be doing something wrong.
Thanks
I don't use the built-in apache, and I think httpd.conf is at risk of being overwritten on updates. However, in my apache install I have AddType and AddHandler reversed from the way you have it:
AddHandler application/x-httpd-php .php
AddHandler application/x-httpd-php-source .phps
AddType text/html .php
In addition, if you plan to use index.php automatically:
DirectoryIndex index.html index.php
Hope that helps.
I have tried reinstalling PHP. PHP is working, and Apache2 is running. I don't know why it's not opening in a browser and displaying normally.
Just so you know - my httpd.conf is empty - and instead I have everything in apache2.conf. This is because I'm using Ubuntu.
Can you help me? I know it's something simple, but I can't seem to find the answer.
Have you virtual host on this project?
Are you open php file with http://localhost/file.php or directly like file://...../file.php ?
In your apache conf:
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
Don't forget to restart apache afterwards. Let me know how it goes.
In my case there was a modification of the /etc/apache2/mods-enabled/php5.conf by module userdir
<IfModule mod_php5.c>
<FilesMatch "\.ph(p3?|tml)$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
# To re-enable php in user directories comment the following lines
# (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
# prevents .htaccess files from disabling it.
<IfModule mod_userdir.c>
<Directory /home/*/public_html>
php_admin_value engine Off
</Directory>
</IfModule>
</IfModule>
The solution is inside the config file, just comment the lines from <IfModule mod_userdir> to </IfModule>.
Try
sudo a2enmod php5
in terminal.
Assuming you are using php 5 :)
If you are using php5 the complete solution would be
sudo apt-get install libapache2-mod-php5
Then
sudo a2enmod php5
I recently had this problem, but only when accessing my site's root (e.g. http://example.com) - it worked as expected when accessing index.php explicitly (e.g. http://example.com/index.php).
The issue was that before creating index.php, I had an index.html file in the web root, but then I renamed it to index.html.bak to 'move it out of the way'. Unfortunately, that doesn't move it out of the way. For whatever reason, Apache will serve that file up with a MIME type of application/x-trash.
(As the /etc/mime.types file contains a line reading "application/x-trash ~ % bak old sik")
Maybe that will help someone else who is scratching their head as I was.
Also, when moving a site and you encounter this, make sure your .htaccess file doesn't specify a different method handler for php. We ran into this moving a wordpress site for a client.
Had same problem - and it was in the .htaccess file I had accidentally downloaded from the live server. Once you've deleted the .htaccess file, you will need to clear your cache to be able to load the .php file in your browser via http://
when i point my browser to http://localhost/phpmyadmin, instead of showing me its front page, it comes up with save as dialog.
I'm running:
Apache/2.2.3 (Debian) PHP/5.2.0-8+etch13 Server
I've reinstalled both apache2 and php5.
After re-install i don't have httpd.conf file, how can i get it back? Is there a standard file which i can just copy into /etc/apache2?
I did a locate httpd.conf and the only file i got was the empty file i have under /etc/apache2/ which i made.
Did you configure the php extension to send an http header?
In httpd.conf:
AddType application/x-httpd-php .php
EDIT
The file is not necessarily named httpd.conf, that's just the default name. Try searching for other configuration files in the Apache directory -- the extension probably is .conf but it might be something else...
If you used apt-get on debian to install apache2, try /etc/apache2/apche2.conf
/EDIT
I also get this problem when I install ISPconfig. I solved the problem by this tutorial:
http://www.howtoforge.com/perfect-server-debian-wheezy-apache2-bind-dovecot-ispconfig-3-p4
I think the main code is change suphp.conf config.
sudo nano /etc/apache2/mods-available/suphp.conf
comment out the <FilesMatch "\.ph(p3?|tml)$"> section and add the line AddType application/x-httpd-suphp .php .php3 .php4 .php5 .phtml - otherwise all PHP files will be run by SuPHP
<IfModule mod_suphp.c>
#<FilesMatch "\.ph(p3?|tml)$">
# SetHandler application/x-httpd-suphp
#</FilesMatch>
AddType application/x-httpd-suphp .php .php3 .php4 .php5 .phtml
suPHP_AddHandler application/x-httpd-suphp
<Directory />
suPHP_Engine on
</Directory>
# By default, disable suPHP for debian packaged web applications as files
# are owned by root and cannot be executed by suPHP because of min_uid.
<Directory /usr/share>
suPHP_Engine off
</Directory>
# # Use a specific php config file (a dir which contains a php.ini file)
# suPHP_ConfigPath /etc/php5/cgi/suphp/
# # Tells mod_suphp NOT to handle requests with the type <mime-type>.
# suPHP_RemoveHandler <mime-type>
</IfModule>
Hope I can help someone :)
I think you just do not know where that config file is. I don't think apache can run without httpd.conf. Here is how you can find your config:
$>locate httpd.conf
/etc/httpd/conf/httpd.conf
$>vim /etc/httpd/conf/httpd.conf
Once you located it, find where other AddType reside and add
AddType application/x-httpd-php .php
Last thing you need to do is restart your httpd, it depends on install, but doing apachectl restart does the trick. You might have to locate it just like you did with httpd.conf file and type in the entire path to the file.
Afterwords, your phpmyadmin should come up.
I dont know anything about this but... does someone knows a way in javascript to download selected files, for example I select through checkboxes 2 files, and then I click on a button in order to download these 2 files choosing the route where i will save the archives