- Docker local deployment memcached comes with the docker compose deployment memcached/elasticsearch/kibana/php/nginx script
- 2, Why use memcached
- 3, Deployment installation
- 1. Version selection
- 2. Command line direct installation
- 3. Docker compose installation
- 4, Summary
- Hot Tags
- Saved searches
- Use saved searches to filter your results more quickly
- globalmac/laravel-sail-php-pgsql-memcached
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Docker Php Ext to Install Memcached
- what is docker Php ext?
- Memcached and docker Php ext
- Base Installation for docker Php ext install Memcached
- Requirements
- Alternative method
- Conclusion
- PREVENT YOUR SERVER FROM CRASHING!
Docker local deployment memcached comes with the docker compose deployment memcached/elasticsearch/kibana/php/nginx script
Memcached is a general distributed memory caching system. It is usually used to speed up dynamic database driven websites by caching data and objects in RAM to reduce the number of times that external data sources (such as databases or API s) must be read.
The Memcached API provides a very large hash table distributed across multiple machines. When the table is full, subsequent inserts cause old data to be purged in the least recently used order. Applications using Memcached typically tier requests and additions into RAM and then return to slower backup storage, such as databases.
2, Why use memcached
In the architecture of a single server, memcached is used to reduce the pressure on the database. For infrequently updated data, it is not necessary to request the database every time.
Similarly, the file cache I wrote before also works. However, the local file cache has a disadvantage that it cannot be used across projects. I can only read and write the cache I use within my own framework.
If my project is multi server or multi terminal, and neither api project nor web project is implemented in the same language, then use the file
3, Deployment installation
1. Version selection
Note that if you use latest, it is the default latest version. At present, the latest version is 1.6.
However, from the perspective of actual projects, most companies do not use the latest version in their production environment, so they must choose their own version according to the actual situation.
The version I choose here is 1.4.32.
Again, the version number in any environment is very important. You can’t use the latest version by default.
2. Command line direct installation
docker run -p 11211:11211 --name memcache memcached:1.4.32
If you do not specify the version after the colon, the default is the latest version.
(base) xxxx@xxxx ~ % telnet 127.0.0.1 11211 Trying 127.0.0.1. Connected to localhost. Escape character is '^]'.
3. Docker compose installation
Command line installation has some disadvantages, such as
- Team members are hard to copy
- Poor environment configuration and storage
- The complete set of environment is not easy to maintain
Docker compose can solve these shortcomings.
As like as two peas, docker-compose maintains a docker-compose.yml file, which integrates all the project environments together, so that all the project members have the same environmental configuration.
memcached: image: memcached:1.4.32 ports: - 11211:11211
At present, the local environment of docker compose I use includes
The local configuration is as follows, and the pro test is available.
version: "3" services: memcached: image: memcached:1.4.32 ports: - 11211:11211 elastic: image: elasticsearch:6.7.0 # image: elasticsearch:7.9.3 ports: - "9200:9200" environment: - bootstrap.system_call_filter=false # - node.name=node-1 # - cluster.initial_master_nodes=node-1 volumes: # - /opt/docker/elasticsearch/data:/usr/share/elasticsearch/data - ../elasticsearch-local/data:/usr/share/elasticsearch/data networks: web: ipv4_address: 172.25.0.3 kibana: image: kibana:6.7.0 # image: kibana:7.9.3 environment: - I18N_LOCALE=zh-CN - ELASTICSEARCH_HOSTS=http://172.25.0.3:9200 - ELASTICSEARCH_URL=http://172.25.0.3:9200 ports: - "5601:5601" networks: - web php: image: crunchgeek/php-fpm:7.0 volumes: - ./yii_env.php:/var/www/yii_env.php - ./php.ini:/usr/local/etc/php/php.ini - ./:/var/www/html networks: - web web: image: nginx ports: - "8001-8009:8001-8009" volumes: - ./yii_env.php:/var/www/yii_env.php - ./:/var/www/html - ./default:/etc/nginx/conf.d/default.conf - ./localcerts:/etc/nginx/certs networks: - web networks: web: ipam: driver: default config: - subnet: "172.25.0.0/16"
4, Summary
- It is recommended to use docker in the local environment, which is easy to deploy without burden.
- docker is not recommended for online environment, and performance loss can not be ignored.
Posted on Mon, 20 Sep 2021 18:50:19 -0400 by crouchl
Hot Tags
- Java — 7906
- Database — 3176
- Python — 3103
- Attribute — 2963
- Programming — 2938
- Javascript — 2788
- Spring — 2575
- xml — 2270
- Android — 2243
- Linux — 2204
- JSON — 2150
- less — 2137
- network — 2115
- github — 2063
- MySQL — 1760
- SQL — 1616
- PHP — 1559
- encoding — 1360
- Mobile — 1172
- Apache — 1137
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
Laravel Docker Sail compose stub for PHP 8.1, Postgres 13 and Memcached Server
globalmac/laravel-sail-php-pgsql-memcached
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
Laravel Docker Sail compose stub for PHP 8.1, Postgres 13 and Memcached Server
# DB DB_CONNECTION=pgsql DB_HOST=pgsql DB_PORT=5432 DB_DATABASE=test DB_USERNAME=test DB_PASSWORD=test ## Memcached MEMCACHED_HOST=memcached CACHE_DRIVER=memcached
docker-compose.yml
version: '3' services: laravel.test: build: context: ./vendor/laravel/sail/runtimes/8.1 dockerfile: Dockerfile args: WWWGROUP: '$' image: sail-8.1/app extra_hosts: - 'host.docker.internal:host-gateway' ports: - '$:80' environment: WWWUSER: '$' LARAVEL_SAIL: 1 XDEBUG_MODE: '$' XDEBUG_CONFIG: '$' volumes: - '.:/var/www/html' networks: - sail depends_on: - pgsql - redis pgsql: image: 'postgres:13' ports: - '$:5432' environment: PGPASSWORD: '$' POSTGRES_DB: '$' POSTGRES_USER: '$' POSTGRES_PASSWORD: '$' volumes: - 'sailpgsql:/var/lib/postgresql/data' networks: - sail healthcheck: test: [ "CMD", "pg_isready", "-q", "-d", "$", "-U", "$" ] retries: 3 timeout: 5s memcached: image: 'memcached:alpine' ports: - '11211:11211' networks: - sail networks: sail: driver: bridge volumes: sailpgsql: driver: local
About
Laravel Docker Sail compose stub for PHP 8.1, Postgres 13 and Memcached Server
Docker Php Ext to Install Memcached
Let us take a look at installing Memcached using the Docker Php ext in detail.
what is docker Php ext?
This command is used to activate the PHP extension. The PHP extension is not started by default when the user uses pecl to install it. They must configure this extension in PHP if they want to use it.
Memcached and docker Php ext
Memcached is a caching system that can improve back-end database performance. It can temporarily store information in memory. And, It can retain frequently or recently requested records. They reduce the number of direct requests to databases in this way.
Anyone can use the docker-php-ext-* commands to complete the docker PHP ext to install Memcached and process. It is critical to check out the source. The installation must begin with a Base installation process. Note that it is assumed that the user has already completed the installation of the necessary items to run the extension.
Base Installation for docker Php ext install Memcached
The user can run the following command after installing all of the necessary items for the Memcached extension.
RUN git clone -b php7 https://github.com/php-memcached-dev/php-memcached /usr/src/php/ext/memcached \
&& docker-php-ext-configure /usr/src/php/ext/memcached \ —disable-memcached-sasl \
&& docker-php-ext-install /usr/src/php/ext/memcached \
&& rm -rf /usr/src/php/ext/memcached
The repository will be cloned using this block. So the user must configure and install the extension before cleaning up.
Requirements
To build the extension for Docker Php ext install Memcached, the user will most likely need to install two packages. They can add and remove by doing the following: ENV MEMCACHED_DEPS zlib-dev libmemcached-dev cyrus-sasl-dev git
RUN set -xe \
&& apk add —no-cache libmemcached-libs zlib \
&& apk add —no-cache \
—virtual .memcached-deps \
$MEMCACHED_DEPS \
&& git clone -b php7 https://github.com/php-memcached-dev/php-memcached /usr/src/php/ext/memcached \
&& docker-php-ext-configure /usr/src/php/ext/memcached \
—disable-memcached-sasl \
&& docker-php-ext-install /usr/src/php/ext/memcached \
&& rm -rf /usr/src/php/ext/memcached \
&& apk del .memcached-deps
FROM php:7.4.28-apache
RUN apt-get install -y libz-dev libmemcached-dev && \
apt-get install -y memcached libmemcached-tools && \
pecl install memcached && \
docker-php-ext-enable memcached
And after this the user can start the daemon using: /etc/init.d/memcached start .
Alternative method
Firstly, use the pecl to install these extensions. The user must then use the docker command to open the extension.
RUN apk update && apk add —no-cache/
autoconf g++ make libmemcached-dev/
&& pecl install memcached/
&& docker-php-ext-enable memcached/
The installation is successful. To verify that the redis, Memcached, and swoole extensions have been installed, run php -m.
[Need assistance with similar queries? We are here to help]
Conclusion
To conclude the process of installing Memcached with the docker Php extension is extremely easy to do. A user can manage and complete the installation steps in a few simple steps. And, the extension will help to manage and improve back-end database performance.
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.