A PHP-driven script to determine if the environment is configured

A PHP-driven script to determine if the environment is configured

am 17.12.2009 08:46:59 von AmirBehzad Eslami

--00032555833afaf8c1047ae7d317
Content-Type: text/plain; charset=UTF-8

Dear list,
e-Greetings,

I've developed some PHP-driven web applications. These applications will be
installed on different
linux-based servers (typically Debian and Redhat). Usually, after I copy the
files to the
server, they DO NOT WORK, so I spend hours to debug the problem. Problems
are very funny,
for example, the program is giving strange errors, and it is not working
because "short_open_tags" are off !

I decided to write a PHP script to check if server's configuration meets my
requirements.
- checking whether some php extensions are loaded, eg. MCrypt.
- checking wheather short_open_tags is ON
- checking whether mod_rewrite is enabled
- etc.

Here's my question:

- How do you check if .htaccess is working, *** via php code *** ?
It's easy to check if .htaccess exists (@php: file_exists), but how to make
sure if .htaccess is working?!
- How do you check if AllowOverride is set to All in apache's configuration?

Please let me know what do you think. Thank you in advance.
-behzad

--00032555833afaf8c1047ae7d317--

Re: A PHP-driven script to determine if the environment is configured correctly (checklist)

am 17.12.2009 08:55:44 von Sam

Здравствуй те, A=
mirBehzad.

Вы писали 17 дек=D0=
°Ð±Ñ€Ñ=8F 2009 г., 17:46:59:

> Dear list,
> e-Greetings,

> I've developed some PHP-driven web applications. These applications will =
be
> installed on different
> linux-based servers (typically Debian and Redhat). Usually, after I copy =
the
> files to the
> server, they DO NOT WORK, so I spend hours to debug the problem. Problems
> are very funny,
> for example, the program is giving strange errors, and it is not working
> because "short_open_tags" are off !

> I decided to write a PHP script to check if server's configuration meets =
my
> requirements.
> - checking whether some php extensions are loaded, eg. MCrypt.
> - checking wheather short_open_tags is ON
> - checking whether mod_rewrite is enabled
> - etc.

> Here's my question:

> - How do you check if .htaccess is working, *** via php code *** ?
> It's easy to check if .htaccess exists (@php: file_exists), but how to ma=
ke
> sure if .htaccess is working?!
> - How do you check if AllowOverride is set to All in apache's configurati=
on?

> Please let me know what do you think. Thank you in advance.
> -behzad

Make sure that you did your scripts executable(chmod +x)
You can check .htaccess that way:
create .htaccess if folder with script, override some directive thru
it, like php's max execution time.
then create php script, get php value that you've
changed(max_execution_time), compare to the value you gave in
..htaccess, if values are the same, .htaccess is working!


--=20
Sam


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: A PHP-driven script to determine if the environment isconfigured correctly (checklist)

am 17.12.2009 12:57:10 von Ashley Sheridan

--=-/dT8ivmCAtmzROs9OjZr
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Thu, 2009-12-17 at 17:55 +1000, Sam wrote:

> Здравствуй те,=
AmirBehzad.
>=20
> Вы писали 17 дек=
абря 2009 г., 17:46:59:
>=20
> > Dear list,
> > e-Greetings,
>=20
> > I've developed some PHP-driven web applications. These applications wil=
l be
> > installed on different
> > linux-based servers (typically Debian and Redhat). Usually, after I cop=
y the
> > files to the
> > server, they DO NOT WORK, so I spend hours to debug the problem. Proble=
ms
> > are very funny,
> > for example, the program is giving strange errors, and it is not workin=
g
> > because "short_open_tags" are off !
>=20
> > I decided to write a PHP script to check if server's configuration meet=
s my
> > requirements.
> > - checking whether some php extensions are loaded, eg. MCrypt.
> > - checking wheather short_open_tags is ON
> > - checking whether mod_rewrite is enabled
> > - etc.
>=20
> > Here's my question:
>=20
> > - How do you check if .htaccess is working, *** via php code *** ?
> > It's easy to check if .htaccess exists (@php: file_exists), but how to =
make
> > sure if .htaccess is working?!
> > - How do you check if AllowOverride is set to All in apache's configura=
tion?
>=20
> > Please let me know what do you think. Thank you in advance.
> > -behzad
>=20
> Make sure that you did your scripts executable(chmod +x)
> You can check .htaccess that way:
> create .htaccess if folder with script, override some directive thru
> it, like php's max execution time.
> then create php script, get php value that you've
> changed(max_execution_time), compare to the value you gave in
> .htaccess, if values are the same, .htaccess is working!
>=20
>=20
> --=20
> Sam
>=20
>=20

I'd advise against using short PHP tags, as they cause all sorts of
problems with outputting XML-based code, and as you've seen, it's
doesn't make your code very portable. For the sake of a few keystrokes,
is it really worth it? Also, I believe they are being phased out as of
PHP6, so it might be time to think about updating your code a bit!

Thanks,
Ash
http://www.ashleysheridan.co.uk



--=-/dT8ivmCAtmzROs9OjZr--