Which php change path

Как добавить путь до PHP в переменную окружения PATH в Windows

Вполне возможно, что вам не приходилось ранее сталкиваться с PATH и выражениями «переменная окружения», поэтому я кратко поясню, что это такое.

Переменная PATH содержит список папок, в которых Windows ищет исполнимые файлы.

В графическом интерфейсе, когда для запуска программ используются ярлыки, значение PATH не очень большое. Но если вы запускаете программу в командной строке, то PATH может пригодиться. Опять же, если вы указываете полный путь до файла, например, C:\Users\Alex\Documents\php.exe, то PATH не используется. Но если, например, вы запускаете программу только по имени файла или просто по имени (без файлового расширения), то запустится ли программа, будет зависеть от содержимого переменной PATH.

К примеру, я в командной строке пытаюсь запустить файл (без указания полного пути)

В этом случае операционная система посмотрит все записи PATH (там может быть указано несколько каталогов). Затем в каждом из этих каталогов Windows попытается найти файл php.exe. Если файл найден, то он будет запущен. Если файл не найден, то будет выведено соответствующее сообщение.

По сути, что-то дописывать в переменную PATH нужно только тем, кто много работает с командной строкой. К примеру, вы программист и размещаете свои программы в папке C:\MyApps и при этом вы часто запускаете свои утилиты командной строки. В этом случае вы можете добавить C:\MyApps в PATH и после этого для запуска программ из этой папки вам уже не нужно будет каждый раз вводить полное имя (например, C:\MyApps\parser.exe), а достаточно будет в командной строке ввести только имя файла:

Нужно ли в Windows добавлять PHP в переменную окружения

При установке и настройке PHP в Windows необязательно добавлять в PATH путь до PHP, но это рекомендуется делать.

Во-первых, вы сможете запускать PHP используя сокращённую запись:

C:\Server\bin\PHP\php.exe my_script.php

Во-вторых, ряд расширений (которые включаются в файле php.ini) работают некорректно, если вы не прописали в PATH путь до PHP; в том числе, это касается такого довольно популярного расширения как cURL. По идее — это какой-то баг этих расширений или PHP, но нам самим придётся исправлять ситуацию, поскольку эта проблема существует уже много лет.

Как добавить PHP в системные переменные среды

Нажмите кнопку Windows (это которая раньше была кнопкой «Пуск»), начните набирать «Изменение системных переменных среды»

и откройте соответствующее окно настроек.

Читайте также:  Data cleaning using python

Там нажмите «Переменные среды», откроется:

В окне «Системные переменные» найдите и кликните на Path, потом нажмите «Изменить»:

Далее «Создать» и впишите туда «C:\Server\bin\PHP\»:

Поднимите запись в самый Вверх:

Закройте все окна с сохранением сделанных изменений.

Источник

how to change path of php ini windows

I’ve downloaded php, addeded it to my path and im trying to enabled openssl php —ini tells me that configuration file is c:\windows which there was nothing there, I dont want to copy php into c/windows. How do I change this to point at my php folder?

3 Answers 3

You do not need to put anthing to do with PHP anywhere near the c:\windows folder.

If you do it will only serve to mess you up when you upgrade PHP to a new version.

If you CD to the folder that PHP is installed in and do a php —ini it will read the php.ini file from the folder that you are in.

D:\wamp\bin\php\php5.5.12>php --ini Configuration File (php.ini) Path: C:\Windows Loaded Configuration File: D:\wamp\bin\php\php5.5.12\php.ini Scan for additional .ini files in: (none) Additional .ini files parsed: (none) 

I think its also a bad idea to put the PHP install folder in the windows PATH as well.

All you need is a little batch file that will setup your PATH for the duration of the command window you are using, and put that in one of the folders that is already in the windows PATH.

So assuming you installed PHP into C:\php this is the batch file

PATH=%PATH%;C:\php php --ini php -v 

And you then just run this batch file any time you open a command windows and want to run some PHP code and your environment gets configured. You can also add other things to this batch file when you need other things added to your environment like Composer etc.

Источник

How do I tell Apache which PHP to use?

I am running Apache2 on a Mac OS X (10.5). I just compiled PHP 5.2.8 and finally got pdo-mysql working (or so I think). This terminal command:

is showing 5.2.8 and I have the right modules installed. But, when I do a phpinfo() , Apache dumps out PHP 5.2.6 (my earlier version, without pdo_mysql ). How do I tell Apache which PHP to load? The httpd.conf has the line:

LoadModule php5_module libexec/apache2/libphp5.so 

When you compiled php did you use make install? If you did find the path that it installed your module to and change your apache config to point to it. Mac has it’s own version of apache and php5 already installed which is why you are seeing a different version.

Читайте также:  Php x powered by disabled

5 Answers 5

I think all these answers aren’t really answering the question. The root level can be determined by running the command httpd -V . This will show you what options the Apache daemon was built with at compile time. This is what controls where httpd determines where to look for it’s config. files and .so modules by default.

% httpd -V Server version: Apache/2.2.17 (Unix) Server built: Dec 17 2010 11:58:24 Server's Module Magic Number: 20051115:25 Server loaded: APR 1.3.12, APR-Util 1.3.9 Compiled using: APR 1.3.12, APR-Util 1.3.9 Architecture: 32-bit Server MPM: Prefork threaded: no forked: yes (variable process count) Server compiled with. -D APACHE_MPM_DIR="server/mpm/prefork" -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=128 -D HTTPD_ROOT="/etc/httpd" -D SUEXEC_BIN="/usr/sbin/suexec" -D DEFAULT_PIDLOG="logs/httpd.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_LOCKFILE="logs/accept.lock" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="conf/mime.types" -D SERVER_CONFIG_FILE="conf/httpd.conf" 

The key line in that output is the HTTPD_ROOT . That defines where Apache’s ROOT directory is to start, /etc/httpd in my case, when looking for config. files and modules.

NOTE: This ROOT is not the same thing as DocumentRoot . This ROOT is specific to how the httpd daemon was compiled, the DocumentRoot is for specifying where the httpd daemon should start looking for actual web content (.html files and such).

For my httpd.conf file I have the following Load lines:

LoadModule auth_basic_module modules/mod_auth_basic.so LoadModule auth_digest_module modules/mod_auth_digest.so LoadModule authn_file_module modules/mod_authn_file.so 

Given this the full path to your modules would be, for example:

/etc/httpd/modules/mod_auth_basic.so 

This is from a CentOS 5.x system but the technique is still apt.

BTW, it can get a little confusing because in CentOS’ case the files are organized physically here:

% ls /usr/lib/httpd/modules/ libphp5.so mod_authnz_ldap.so mod_dav_fs.so mod_headers.so mod_perl.so mod_speling.so 

. and then accessible to the Apache daemon, httpd , through this path:

% ls -l /etc/httpd/ total 12 drwxr-xr-x 2 root root 4096 Apr 26 2011 conf drwxr-xr-x 3 root root 4096 Apr 26 2011 conf.d -rw-r--r-- 1 root root 18 Feb 24 2009 htpasswd lrwxrwxrwx 1 root root 19 Apr 26 2011 logs -> ../../var/log/httpd lrwxrwxrwx 1 root root 27 Apr 26 2011 modules -> ../../usr/lib/httpd/modules lrwxrwxrwx 1 root root 13 Apr 26 2011 run -> ../../var/run 

The modules link connects /etc/httpd —> /usr/lib/httpd/modules .

Источник

How do I tell Apache which PHP to use?

I am running Apache2 on a Mac OS X (10.5). I just compiled PHP 5.2.8 and finally got pdo-mysql working (or so I think). This terminal command:

is showing 5.2.8 and I have the right modules installed. But, when I do a phpinfo() , Apache dumps out PHP 5.2.6 (my earlier version, without pdo_mysql ). How do I tell Apache which PHP to load? The httpd.conf has the line:

LoadModule php5_module libexec/apache2/libphp5.so 

When you compiled php did you use make install? If you did find the path that it installed your module to and change your apache config to point to it. Mac has it’s own version of apache and php5 already installed which is why you are seeing a different version.

Читайте также:  Java double to biginteger

5 Answers 5

I think all these answers aren’t really answering the question. The root level can be determined by running the command httpd -V . This will show you what options the Apache daemon was built with at compile time. This is what controls where httpd determines where to look for it’s config. files and .so modules by default.

% httpd -V Server version: Apache/2.2.17 (Unix) Server built: Dec 17 2010 11:58:24 Server's Module Magic Number: 20051115:25 Server loaded: APR 1.3.12, APR-Util 1.3.9 Compiled using: APR 1.3.12, APR-Util 1.3.9 Architecture: 32-bit Server MPM: Prefork threaded: no forked: yes (variable process count) Server compiled with. -D APACHE_MPM_DIR="server/mpm/prefork" -D APR_HAS_SENDFILE -D APR_HAS_MMAP -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled) -D APR_USE_SYSVSEM_SERIALIZE -D APR_USE_PTHREAD_SERIALIZE -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT -D APR_HAS_OTHER_CHILD -D AP_HAVE_RELIABLE_PIPED_LOGS -D DYNAMIC_MODULE_LIMIT=128 -D HTTPD_ROOT="/etc/httpd" -D SUEXEC_BIN="/usr/sbin/suexec" -D DEFAULT_PIDLOG="logs/httpd.pid" -D DEFAULT_SCOREBOARD="logs/apache_runtime_status" -D DEFAULT_LOCKFILE="logs/accept.lock" -D DEFAULT_ERRORLOG="logs/error_log" -D AP_TYPES_CONFIG_FILE="conf/mime.types" -D SERVER_CONFIG_FILE="conf/httpd.conf" 

The key line in that output is the HTTPD_ROOT . That defines where Apache’s ROOT directory is to start, /etc/httpd in my case, when looking for config. files and modules.

NOTE: This ROOT is not the same thing as DocumentRoot . This ROOT is specific to how the httpd daemon was compiled, the DocumentRoot is for specifying where the httpd daemon should start looking for actual web content (.html files and such).

For my httpd.conf file I have the following Load lines:

LoadModule auth_basic_module modules/mod_auth_basic.so LoadModule auth_digest_module modules/mod_auth_digest.so LoadModule authn_file_module modules/mod_authn_file.so 

Given this the full path to your modules would be, for example:

/etc/httpd/modules/mod_auth_basic.so 

This is from a CentOS 5.x system but the technique is still apt.

BTW, it can get a little confusing because in CentOS’ case the files are organized physically here:

% ls /usr/lib/httpd/modules/ libphp5.so mod_authnz_ldap.so mod_dav_fs.so mod_headers.so mod_perl.so mod_speling.so 

. and then accessible to the Apache daemon, httpd , through this path:

% ls -l /etc/httpd/ total 12 drwxr-xr-x 2 root root 4096 Apr 26 2011 conf drwxr-xr-x 3 root root 4096 Apr 26 2011 conf.d -rw-r--r-- 1 root root 18 Feb 24 2009 htpasswd lrwxrwxrwx 1 root root 19 Apr 26 2011 logs -> ../../var/log/httpd lrwxrwxrwx 1 root root 27 Apr 26 2011 modules -> ../../usr/lib/httpd/modules lrwxrwxrwx 1 root root 13 Apr 26 2011 run -> ../../var/run 

The modules link connects /etc/httpd —> /usr/lib/httpd/modules .

Источник

Оцените статью