$ sudo apt install php7.0-opcache
$ sudo phpenmod opcache
# PHP-FPM模式的配置文件
$ FILEPATH="/etc/php/7.0/fpm/php.ini"
# Enable the opcache.
$ SEARCH=";opcache.enable=0"
$ REPLACE="opcache.enable=1"
$ sudo sed -i "s:$SEARCH:$REPLACE:" $FILEPATH
# Set the amount of memory we can use for caching.
# The production server has oooooodles of RAM.
$ SEARCH=";opcache.memory_consumption=64"
$ REPLACE="opcache.memory_consumption=256"
$ sudo sed -i "s:$SEARCH:$REPLACE:" $FILEPATH
# increase the number of files to cache
$ SEARCH=";opcache.max_accelerated_files=2000"
$ REPLACE="opcache.max_accelerated_files=1000000"
$ sudo sed -i "s:$SEARCH:$REPLACE:" $FILEPATH
# Don't bother revalidating files for a long time because
# they should never change.
# Obviously you need to undo this in dev.
$ SEARCH=";opcache.validate_timestamps=1"
$ REPLACE="opcache.validate_timestamps=3000"
$ sudo sed -i "s:$SEARCH:$REPLACE:" $FILEPATH
#重启服务
$ sudo service php7.0-fpm restart