PHP on Apache 2.2.x how to use? - windows

I am using Windows XP SP3. I have installed Apache 2.2.9 followed by PHP 5.3 VC6.
I am able to view any plain html on localhost but i can't do so for php files.
Please help

You need to configure Apache to use PHP for .php files:
# load module and add handler
LoadModule php5_module "c:/php/php5apache2.dll"
AddHandler application/x-httpd-php .php
# configure the path to php.ini
PHPIniDir "C:/php"

Assuming the Install has been completed correctly, is your file actually stored as a PHP file? Check the properties of the file.
Try making a php file containing the following code exactly:
When opening in the browser make sure to include the .php at the end:
http://localhost/test.php

Related

Unable to guess the MIME type as no guessers are available. How do I install php_fileinfo extension in cPanel?

I'm trying to upload an image with validation:
'image|mimes:jpeg,png,jpg,gif,svg|max:2048'
Works fine on local. But fails on cPanel.
The cPanel version is 90.0.6
I've tried a couple things inside cPanel. But I couldn't figure out how do I enable the fileinfo extension.
Please help.
Sorry, couldn't comment due to profile limitations that's why posting it in the answer section.
You can contact your hosting provider and ask them to enable the extension for you. There is no way to enable it by yourself in shared hosting.
Make sure your host provider added the extension file in their PHP config.
You can enable fileinfo extension from Cpanel,
Kindly Go to Software => Select PHP Version =>
enable the check box fileinfo to use fileinfo extension.
You should enable the following line in your php.ini and then restart your apache
extension=php_fileinfo.dll
Enabling mean just uncomment the line in your php.ini file
i.e: From this ;extension=php_fileinfo.dll to extension=php_fileinfo.dll
just remove (;) and save it then restart your apache.

how to configure laravel site on localhost using xampp

I am trying to configure the site in localhost which is developed on laravel.
Now I am trying to configure it on my local Machine, using xampp version 3.2.1 and php version 5.6.11 & mysql DB.
I am able to configure it but other than home page all links get 404 page not found error
any suggestions
Enable the rewrite_module in apache's configuration file.
If you are not aware of how to do this, follow below steps:
1) Open apache's configuration file using your favorite text editor. The configuration file generally locates at:{apache_dir}/conf/httpd.conf
If you are using XAMPP or WAMP package then you will find the file at:{xampp_dir}/apache/conf/httpd.conf (or)
{wamp_dir}/apache/conf/httpd.conf
2) Search for the following string:#LoadModule rewrite_module modules/mod_rewrite.so and uncomment it (remove the '#' sign).
3) Now search for another string AllowOverride None and replace it by AllowOverride All
4) Finally save the changes, close your text editor and restart your apache server.
Hope this will help you, Thank you.

Can Apache Configuration File (httpd.conf) Be Located Elsewhere?

I have been using Apache on Windows (+PHP +MySQL) for a long time now. Lately, I decided to have the configuration files of Apache, PHP and MySQL in one directory, outside of the installation folders of any of them.
With PHP it works by setting PHPIniDir in Apache's httpd.conf
With MySQL it works by setting the --defaults-file=<path/to/my.ini> option while installing on the command line as a Windows service.
With Apache itself, I haven't been able to find a way. Is it possible to choose an arbitrary location or name for the httpd.conf file? And how?
Thank you.
you could use "..-f httpd.conf" on startup. see http://httpd.apache.org/docs/current/de/invoking.html
Regards

Change php.ini location

Is it possible to change the location of php.ini to be used by Apache? When I did php -i | grep 'Configuration File', the result is:
Path => /usr/local/etc
Loaded Configuration File => /usr/local/etc/php.ini
But the result of phpinfo() is
Configuration File (php.ini) Path : /etc
I can copy over php.ini from /usr/local/etc/ to /etc/, but is it possible to change the php.ini folder?
I installed PHP using homebrew and I am using OS X Snow Leopard.
PHP uses different .ini files when running via command line vs running as a web server module. When you grep the results of php -i your getting the command line ini. It's good practice to have separate ini's for the two environments.
If you must change the directory PHP looks for the php.ini file, you can use the PHPIniDir in your web server conf file.
If you wish to just add additional directories to be scanned, you can set the PHP_INI_SCAN_DIR environment variable.
To Change php.ini file path we have to declare PHPINIDir in the apache configuration file 'httpd.conf' syntax for that is :
PHPINIDir "path_to_ini_file";

How to get Apache2.2 load the SQLite3 Class from PHP?

I am currently trying to get a working PHP environment on Windows, but for some reason Apache isn't able to execute e.g. print_r(SQLite3::version());, but says Fatal error: Class 'SQLite3' not found in C:\Program Files (x86)\Apache2.2\htdocs\index.php on line 8, while php.exe prints perfectly correct output.
In php.ini I only load extension=php_sqlite3.dll, nothing else. In httpd.conf I got PHPIniDir "C:/Program Files (x86)/PHP/" which enables Apache to handle normal php commands like echo phpinfo();.
Does anybody know what I have to do so SQLite3 works through Apache, too?
Thanks in advance!
EDIT:
Nevremind, solved it myself: The default line extension_dir = "ext" for Windows installations had to be changed to the absolute path, in my case extension_dir = "c:\Program Files (x86)\PHP\ext". This made it all work!
Run your phpinfo() and check if extension is loaded, if not, check Configuration File (php.ini) Path and Loaded Configuration File to see where it is looking for php.ini and which file is loaded. If it is correct, set display_startup_errors in your ini to on and look into apache error log to see if there are problems with loading some extension. I would guess that prior to loading sqlite you will need to load php_mbstring.dll

Resources