Normally you change PHP settings in a file called php.ini that PHP loads when bootstrap. In Dreamhost you use a file called “phprc” that resides in a sub-directory “/.php” in your user home.
There is one folder for every installed PHP version.
When you open the “phprc” file in a text editor you see some code there. This is manage by the server and will be overwritten if you put something there.
Put your code after this part and save.
After that you need to restart php. In Dreamhost shared you have to kill all running processes.
Log in to your server and run the following code:
killall -9 php84.cgi -u shelluser
Change “php84” to right version and “shelluser” to username of website runs under. (the user you logged in ssh)
Optionally you can pass attributes as language for example:
wp core download --locale=pt_BR
Not every shared hosting offer wpcli, but fortunally Dreamhost offer it by default. But when trying for the first time I encontered the following error:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 36864 bytes) in /usr/local/wp/php/WP_CLI/Extractor.php on line 100
That means PHP get limit when tried to download and extract WordPress (128MB). So we need to increase the “memory_limit” argument in php.ini. Dreamhosts call this file as “phprc” and is located in a folder /home/username/.php/version. (eg: /home/useander/.php/8.2).
So we need to know what version is currently in use by cli. The following command show exactly this:
wp cli info
Returns something like
Shell: /bin/bash
PHP binary: /usr/bin/php
PHP version: 8.2.26
php.ini used: /etc/php82/php.ini
MySQL binary: /usr/bin/mysql
MySQL version: mysql Ver 8.0.30-0ubuntu0.20.04.2 for Linux on x86_64 ((Ubuntu))
We can see PHP 8.2 is in use. As in shared host we cannot directly change this php.ini file, we change the phprc file in our user directory, as demonstrated above.
add the following in /home/yourusername/.php/8.2/phprc file
memory_limit = 256M;
The file can already have some arguments. You can leave as is.
Other way is to change the PHP version cp-cli uses. To do this you can add the follow line to the .bash_profile file in root of your user in Dreamhost.
export WP_CLI_PHP=/usr/local/php83/bin/php wp
Probably now you can run the command succesfully
Now we need to create a wp-config file. the following command makes this.