ANS Documentation

Improve This Doc
  • Cloud
  • Domains and DNS management
  • Backup and High Availability
  • eCommerce Stacks
    • Magento
    • Shopware
    • WooCommerce
      • Adding Domain(s) To The Stack
      • PHP
      • OPCache
      • Redis
    • AeroCommerce
  • Security
  • Email
  • Monitoring and usage management
  • Networking
  • Operating systems
  • Webcelerator
  • MyUKFast
  • Home >
  • eCommerce Stacks >
  • WooCommerce >
  • PHP >
  • PHP

PHP¶

Create Backup¶

If you have PHP already installed and would like to take a backup of the configuration files, you can run the following (You can copy and paste the whole block below into your SSH terminal):

mkdir /root/php_upgrade_backup-$(date +%d_%b_%Y)
php -v > /root/php_upgrade_backup-$(date +%d_%b_%Y)/version
php -m > /root/php_upgrade_backup-$(date +%d_%b_%Y)/modules
php -i > /root/php_upgrade_backup-$(date +%d_%b_%Y)/info
rpm -qa | grep -i php > /root/php_upgrade_backup-$(date +%d_%b_%Y)/rpms
cp -r /etc/php.d/ /root/php_upgrade_backup-$(date +%d_%b_%Y)/
cp -r /etc/php-fpm.conf /root/php_upgrade_backup-$(date +%d_%b_%Y)/
cp -r /etc/php-fpm.d/ /root/php_upgrade_backup-$(date +%d_%b_%Y)/
cp /etc/php.ini /root/php_upgrade_backup-$(date +%d_%b_%Y)/

Remi Repository¶

We use the Remi YUM repository for PHP. You can install the Remi repository with the command:

CentOS 7¶

wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm && rpm -Uvh remi-release-7.rpm && rm -f remi-release-7.rpm

Install/Downgrade¶

If you are installing or downgrading PHP you need to remove PHP from the server and then follow the install guide below. We can remove PHP with the command:

We highly recommend taking a backup before running this command (See PHP Backup above)

yum remove "php*"

Install PHP¶

This includes the PHP modules required by WooCommerce.

PHP 7.0¶

yum install --enablerepo=remi-php70,remi,epel php php-pdo php-mysqlnd php-opcache php-xml php-mcrypt php-gd php-devel php-mysql php-intl php-mbstring php-bcmath php-json php-pecl-zip php-iconv php-pecl-apcu php-pecl-redis php-fpm php-zip php-soap php-ioncube-loader composer

PHP 7.1¶

yum install --enablerepo=remi-php71,remi,epel php php-pdo php-mysqlnd php-opcache php-xml php-mcrypt php-gd php-devel php-mysql php-intl php-mbstring php-bcmath php-json php-pecl-zip php-iconv php-pecl-apcu php-pecl-redis php-fpm php-zip php-soap php-ioncube-loader composer

PHP 7.2¶

yum install --enablerepo=remi-php72,remi,epel php php-pdo php-mysqlnd php-opcache php-xml php-pecl-mcrypt php-gd php-devel php-intl php-mbstring php-bcmath php-json php-pecl-zip php-iconv php-pecl-apcu php-pecl-redis php-fpm php-zip php-soap php-ioncube-loader composer

PHP 7.3¶

yum install --enablerepo=remi-php73,remi,epel php php-pdo php-mysqlnd php-opcache php-xml php-pecl-mcrypt php-gd php-devel php-intl php-mbstring php-bcmath php-json php-pecl-zip php-iconv php-pecl-apcu php-pecl-redis php-fpm php-zip php-soap php-ioncube-loader composer

Update PHP¶

You can perform an update of PHP with the following command depending on the desired version:

PHP 7.0¶

yum update --disablerepo='*' --enablerepo=base,remi-php70,remi,epel,updates 'php-*'

PHP 7.1¶

yum update --disablerepo='*' --enablerepo=base,remi-php71,remi,epel,updates 'php-*'

PHP 7.2¶

yum update --disablerepo='*' --enablerepo=base,remi-php72,remi,epel,updates 'php-*'

PHP 7.3¶

yum update --disablerepo='*' --enablerepo=base,remi-php72,remi,epel,updates 'php-*'

If any of the following packages are updated as dependencies, NGINX will require a restart after updating PHP

  • curl

  • nss

  • openssl

  • libcurl

You can restart NGINX with the commands:

nginx -t
systemctl restart nginx

OPcache Settings¶

Review and then apply the OPcache settings (Simply copy and paste the entire block below):

sed -i 's/opcache.memory_consumption=128/opcache.memory_consumption=512/g' /etc/php.d/*opcache.ini
sed -i 's/opcache.interned_strings_buffer=8/opcache.interned_strings_buffer=12/g' /etc/php.d/*opcache.ini
sed -i 's/opcache.max_accelerated_files=4000/opcache.max_accelerated_files=10000/g' /etc/php.d/*opcache.ini
sed -i 's/;opcache.fast_shutdown=0/opcache.fast_shutdown=1/g' /etc/php.d/*opcache.ini
sed -i 's/;opcache.validate_timestamps=1/opcache.validate_timestamps=1/g' /etc/php.d/*opcache.ini
sed -i 's/;opcache.revalidate_freq=2/opcache.revalidate_freq=60/g' /etc/php.d/*opcache.ini
sed -i 's/;opcache.enable_file_override=0/opcache.enable_file_override=1/g' /etc/php.d/*opcache.ini

You can find more information on OPcache here

/etc/php.ini Settings¶

Review and copy the settings from /root/php_upgrade_backup-$(date +%d_%b_%Y)/php.ini to /etc/php.ini. Alternatively use our standard settings for the php.ini file. You can copy and paste the whole block below into your SSH terminal:

cp /etc/php.ini /root/php.ini.default
ssed -ie "s_;date.timezone =_date.timezone = \"Europe/London\"_g" /etc/php.ini
sed -ie "s/memory_limit = 128M/memory_limit = 512M/" /etc/php.ini
sed -ie "s/max_execution_time = 30/max_execution_time = 1800/" /etc/php.ini
sed -ie "s/max_input_time = 60/max_input_time = 90/" /etc/php.ini
sed -ie "s/short_open_tag = Off/short_open_tag = On/" /etc/php.ini
sed -ie "s/;always_populate_raw_post_data = On/always_populate_raw_post_data = -1/" /etc/php.ini
sed -ie "s/expose_php = On/expose_php = Off/" /etc/php.ini
sed -ie "s/upload_max_filesize = 2M/upload_max_filesize = 8M/" /etc/php.ini

PHP-FPM Default Pool¶

Stop the default PHP-FPM pool www from running with the command:

echo ";Default file, please don't remove" > /etc/php-fpm.d/www.conf

Start PHP-FPM¶

Configuration Test¶

Run a configuration test of PHP-FPM before starting:

php-fpm -t
[21-Aug-2019 07:53:29] NOTICE: configuration file /etc/php-fpm.conf test is successful

Start PHP-FPM¶

You can then start the PHP-FPM service with the command

systemctl start php-fpm

Start On Boot¶

You can also enable PHP-FPM to start on boot:

systemctl enable php-fpm

Next Article > OPCache

  • Useful Links
  • SMB
  • Enterprise
  • Channel
  • Public Sector
  • ANS Data Centres
  • About ANS
  • Careers
  • Blog
  • Get in touch
  •  
  • Sales 0800 458 4545
  • Support 0800 230 0032
  • Get in touch

© ANS Group Limited | Terms and Conditions | Corporate Guidance | Sitemap
ANS Group Limited, registered in England and Wales, company registration number 03176761, registered office 1 Archway, Birley Fields, Manchester M15 5QJ