I have recently been trying to install PHP and Apache on my computer. After many hours, they\'re installed. I have modified the httpd.conf and php.ini files like everyone sa
For PHP7 and Apache2.4, this is all you need to do:
sudo vim /etc/httpd/conf/httpd.conf
Go to the very bottom and insert the following (all by itself):
<FilesMatch "\.*">
SetHandler application/x-httpd-php
</FilesMatch>
Then, restart Apache to load the new configuration:
sudo service httpd restart
Apache will now execute all HTTP/S requests with PHP. If all you have are html, css, and php files, then this will work fine for you. If you have other languages running, then you'll need to tailor the file matching to your situation. I've tested this with phpMyAdmin and it works fine.
None of that other stuff all the people are talking about here was necessary for me. When I put the "AddType Application....." thing in the correct spot, Apache just told me that that module was already loaded and skipped it.
More information can be found here: https://httpd.apache.org/docs/2.4/mod/core.html#filesmatch
My install was done as follows:
sudo yum install -y httpd24 php70 mysql56-server php70-mysqlnd
You should also read this, if you haven't: https://httpd.apache.org/docs/current/howto/htaccess.html#when
What worked for me:
In active httpd.conf, find
<IfModule mime_module>
...
</IfModule>
It was missing the following
AddType application/x-httpd-php .php
AddHandler application/x-httpd-php .php
After restarting apache, .php files are correctly parsed.
Run Xampp (apache) as administrator. In google chrome type:
localhost/<insert folder name here>/<insert file name>
i.e. if folder you created is "LearnPhp", file is "chapter1.php" then type
localhost/LearnPhp/chapter1.php
I created this folder in the xampp folder in the htdocs folder which gets created when you download xampp.
You must enable php! Check the folder mods-enabled
in the Apache directory (default: /etc/apache2/
) to see if you find a file named php
. I don't remember the extension but I think it's .so
.
Also check in /var/log/apache2/error.log
to see if you have any other errors.
If you are a ubuntu user, after installing apache must run the following command in fresh installation
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
In my case works fine.
Add following configuration to /etc/apache2/apache2.conf
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
And restart the apache
via sudo service apache2 restart