10. Configure the PHP settingsNow comes the time to configure PHP There are some pit falls that I have experienced here too. As they come up I will point them out.
Lets start off by configuring the CLI
Execute this command, which will open the cli/php.ini file.
sudo nano /etc/php/7.0/cli/php.ini
This file is very well documented. Becuase of this its time to introduce a new feature of Nano. Nano has a search feature. To activate it:
Press CTRL-W
which stands for the command Where as in Where is?
When CTRL-W is pressed you will see the prompt
Search:
Type in:
max_execution_time
and press ENTER. you will be taken directly to that entry by passing all that documentation.
Change this line that currently reads:
max_execution_time = 30
and change it to read:
max_execution_time = 120
Next press CTRL-W and enter the following:
memory_limit
Here comes another problem I had with the install guide. PHP 7.0 comes preset to the following:
memory_limit = -1
What this simply means is use any available memory.
The install guide suggested that this be set to
memory_limit = 1024M
The problem with setting this memory limit too low is PHP will run out of memory very quickly. A lot of times you wont know anything is wrong with the exception that pages will not display correctly or settings will not stay set, or worse, the website will crash for no reason.
After poking around in the log files and then researching what this setting actually does, I feel its safe to leave this at -1. The setting -1 allows PHP to allocate memory as needed and does not restrict is ability to run correctly. No this does not mean that PHP uses all available server memory. It means that it CAN use all available server memory if it needs to. I have found that PHP is very frugal with the RAM it uses. If I find this installation is using too much RAM, then I will update this post. I do positively know 1024M is not enough RAM.
Next press CTRL-W and enter:
date.timezone
This is a commented out field that looks like this in the file:
;date.timezone =
Remove the semi colon so the line now looks like this:
date.timezone =
Now add your local time zone. You can look up your local timezone here:
http://php.net/manual/en/timezones.php. My timezone is "America/Los_Angeles" so when finished the changed line will look like this:
date.timezone = America/Los_Angeles
Setting Debugging OptionsThese options are for debugging purposes and are optional, for me since I don't know much about running an indexing server I will enable these. The Install guide has recommended that these be enabled. Possible Impact to the server are possible disk space issues or slower indexing performance. If you choose not to enable these options, you can skip this section.
Press CTRL-W and enter:
error_reporting =
The line currently reads:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
Change it to read:
error_reporting = E_ALL
Press CTRL-W
Enter the following:
log_errors =
Verify the line reads:
log_errors = On
Press CTRL-W
Enter the following:
error_log =
The line will read:
;error_log = php_errors.log
Change the parameter to remove the semi colon at the beginning of the line and change the _ in php_errors.log to a dash. Just like the example below:
error_log = php-errors.log
Now save your new configuration file by pressing CTRL-X
CTRL-X
Answer Y to save the buffer
Y
and press ENTER to save it to the php.ini you recently opened.
ENTER
Now we will configure the SAPI for Apache. To do this enter the following:
sudo nano /etc/php/7.0/apache2/php.ini
The CLI and SAPI files for PHP must match. So go to the top of this message and repeat the same steps.
Once both files match we will need to reload the Apache service.
Execute the following command:
sudo service apache2 restart