플러그인 설치를 위해 내 FTP 자격 증명을 요구하는 WordPress
로컬 시스템에 WordPress 블로그를 설치했습니다. 그러나 관리자에서 플러그인을 추가하려고 할 때 FTP 액세스를 요청합니다. WordPress가 FTP없이 업로드 할 수 있도록 구성하려면 무엇이 필요합니까?
wp-config.php에 코드를 추가해보십시오.
define('FS_METHOD', 'direct');
Ubuntu를 사용하는 경우.
sudo chown -R www-data:www-data PATH_TO_YOUR_WORDPRESS_FOLDER
"WordPress 제어판을 사용하여 플러그인을 자동으로 설치, 업그레이드 또는 삭제할 때마다 WordPress는 파일 시스템의 파일을 변경해야합니다.
변경하기 전에 WordPress는 먼저 파일 시스템을 직접 조작 할 수있는 권한이 있는지 여부를 확인합니다.
WordPress에 파일 시스템을 직접 수정하는 데 필요한 권한이없는 경우 WordPress가 FTP를 통해 필요한 작업을 시도 할 수 있도록 FTP 자격 증명을 요청합니다. "
솔루션 : apache 인스턴스가 실행중인 사용자를 찾으려면 다음 내용으로 테스트 스크립트를 작성하십시오.
<?php echo(exec("whoami")); ?>
나에게는 www-data가 아닌 데몬이었습니다. 그런 다음 다음과 같이 권한을 수정합니다.
sudo chown -R daemon /path/to/your/local/www/folder
OSX에서 다음을 사용했으며 작동했습니다.
sudo chown -R _www:_www {path to wordpress folder}
_www는 Mac에서 PHP를 실행하는 사용자입니다.
(또한 일부 폴더를 chmod해야 할 수도 있습니다.이 작업을 먼저 수행했지만 수정하지 않았습니다. chown 명령을 수행 할 때까지는 작동하지 않았으므로 chown 명령인지 확실하지 않습니다. 단독으로 또는 chmod와 chown의 조합.)
워드 프레스 폴더의 소유권을 www-data로 재귀 적으로 변경하고 아파치를 다시 시작했습니다.
sudo chown -R www-data:www-data <folderpath>
그것은 매력처럼 작동했습니다!
WordPress는 파일에 직접 액세스 할 수없는 경우 FTP 자격 증명을 요청합니다. 이는 일반적으로 WordPress 파일을 소유 한 사용자가 아닌 Apache 사용자 (mod_php 또는 CGI)로 실행되는 PHP로 인해 발생합니다.
이것은 대부분의 공유 호스팅 환경에서 다소 정상적입니다. 파일은 사용자로 저장되고 Apache는 사용자 apache
또는 httpd
. 이것은 실제로 좋은 보안 예방책이므로 익스플로잇과 해킹은 호스팅 된 파일을 수정할 수 없습니다. 모든 WP 파일을 777 보안으로 설정하여이를 피할 수 있지만 이는 보안이 없음 을 의미 하므로 이에 대해 적극 권장합니다. FTP를 사용하면 좋은 이유가있는 자동으로 권장되는 해결 방법입니다.
먼저 설치 폴더로 이동하십시오 (예 :)
cd /Applications/XAMPP/xamppfiles/
이제 htdocs 디렉토리를 수정하겠습니다.
sudo chown -R daemon htdocs
메시지가 표시되면 루트 비밀번호를 입력 한 다음 chmod 호출로 완료합니다.
sudo chmod -R g+w htdocs
우리는 더 큰 문제의 일부와 같은 문제를 겪었습니다. 제안 된 솔루션
define('FS_METHOD', 'direct');
해당 창을 숨기지 만 테마 및 업그레이드 등을로드하는 데 여전히 문제가있었습니다. 권한과 관련이 있지만 우리의 경우에는 php OS 공급 업체 mod_php 에서보다 안전한 php OS 공급 업체 FastCGI 응용 프로그램 으로 이동하여 문제를 해결했습니다 .
여기에 설명 된 단계에 따라 Ubuntu 14.04에 WordPress를 로컬로 설치 하고 간단히 실행했습니다.
sudo chown -R www-data:www-data {path_to_your_project_directory}
플러그인 다운로드 문제를 해결했습니다. 내가이 게시물을 여기에 남기는 유일한 이유는 내 문제를 검색했을 때 이것이 첫 번째 결과 중 하나 였고 내 문제에 대한 해결책으로 이끌었 기 때문입니다.
이것이 누구에게나 도움이되기를 바랍니다!
이 문제를 해결하는 가장 쉬운 방법은 다음 FTP 정보를 wp-config.php
define('FS_METHOD', 'direct');
define('FTP_BASE', '/usr/home/username/public_html/my-site.example.com/wordpress/');
define('FTP_CONTENT_DIR', '/usr/home/username/public_html/my-site.example.com/wordpress/wp-content/');
define('FTP_PLUGIN_DIR ', '/usr/home/username/public_html/my-site.example.com/wordpress/wp-content/plugins/');
FTP_BASE 는 WordPress 설치의 "base"(ABSPATH) 폴더에 대한 전체 경로입니다. FTP_CONTENT_DIR 은 WordPress 설치 의 wp-content 폴더에 대한 전체 경로입니다. FTP_PLUGIN_DIR 은 WordPress 설치 플러그인 폴더의 전체 경로입니다.
Niels가 언급했듯이 이것은 서버 프로세스 사용자가 Wordpress 폴더에 쓸 수 없기 때문에 발생합니다.
그러나 여기에 많은 기사가 설명하지 않는 것이 있습니다. nginx 프로세스가 아니라 PHP 프로세스의 소유자입니다. nginx 소유자를 변경하려고하면이 문제가 해결되지 않습니다.
이를 해결하려면 실행 ps aux
하여 php-fpm 프로세스를 소유 한 사용자를 확인하십시오. 그런 다음 사용자가 wordpress 폴더의 소유자와 동일한 사용자인지 또는 최소한 쓰기가 가능한지 확인합니다. 사용자가 쓸 수없는 경우 폴더의 권한 및 / 또는 소유권을 변경해야합니다. 또는 두 사용자 (서버 소유자 및 워드 프레스 폴더 소유자)를 폴더에 쓸 수있는 공통 그룹에 넣습니다. 또는 php.ini "user"속성을 폴더에 쓸 수있는 사용자로 변경합니다.
이 질문에 대한 유사한 답변이 많이 있지만 근본 원인을 완전히 다루지는 않습니다. 원본 게시물에 대한 Sebastian Schmid의 의견은 그것에 대해 다룹니다. 다음은 2018-11-06 현재 내 의견입니다.
근본 원인
When you try to upload a plugin through the WordPress admin interface, WordPress will make a call over to a function called "get_filesystem_method()" (ref: /wp-admin/includes/file.php:1549). This routine will attempt to write a file to the location in question (in this case the plugin directory). It can of course fail here immediately if file permissions aren't setup right to allow the WordPress user (think the user identity executing the php) to write the file to the location in question.
If the file can be created, this function then detects the file owner of the temporary file, along with the file owner of the function's current file (ref: /wp-admin/includes/file.php:1572) and compares the two. If they match then, in WordPress's words, "WordPress is creating files as the same owner as the WordPress files, this means it's safe to modify & create new files via PHP" and your plugin is uploaded successfully without the FTP Credentials prompt. If they don't match, you get the FTP Credentials prompt.
Fixes
- Ensure the plugin directory is writable by the identity running your php process.
Ensure the identity that is running your php process is the file owner for either:
a) All WordPress application files, or...
b) At the very least the /wp-admin/includes/file.php file
Final Comments
I'm not overly keen on specifically applying file ownership to the file.php to work around this issue (it feels a tad hacky to say the least!). It seems to me at this point that the WordPress code base is leaning towards having us execute the PHP process under the same user principal as the file owner for the WordPress application files. I would welcome some comments from the community on this.
I was facing the same problem! I've added the code below in wp-config.php file (in any line) and it's working now!
define('FS_METHOD', 'direct');
If during installation of a plugin, Wordpress asks for your hostname or FTP details. Then follow these steps:
Login to your server and navigate to /var/www/html/wordpress/. Open wp-config.php and add this line after define(‘DB_COLLATE’)
define('FS_METHOD', 'direct');
If you get "Could not create directory" error. Give write permissions to your wordpress directory in recursive as
chmod -R go+w wordpress
NOTE. For security, revoke these permissions once you install a plugin as
chmod -R go-w wordpress
'program tip' 카테고리의 다른 글
기본 인증이있는 경우 Node.js에서 http.client를 사용하는 방법 (0) | 2020.08.14 |
---|---|
HTML 래퍼없이 DOMDocument의 HTML을 저장하는 방법은 무엇입니까? (0) | 2020.08.14 |
자바에서 모든 공백을 제거하는 방법 (0) | 2020.08.14 |
PowerShell 명령 줄에서 Windows 버전을 찾는 방법 (0) | 2020.08.14 |
Node JS Promise.all 및 forEach (0) | 2020.08.14 |