search
HomeBackend DevelopmentPHP TutorialDetailed explanation of php7 installation yar and generating docker image

This article mainly introduces php7 to install yar and generate docker images. Friends who need it can refer to it

Docker contains three concepts:

(1) Remote The warehouse is the gathering place for all the images in the remote image library (not accessible for operation).

(2) The local image is the image pulled from the remote warehouse

(3) The local image that runs is called a container (layered operable)

Docker usage:

1. First, pull the corresponding information such as centos, ubuntu, tomcat, etc. through the third-party image library (c.163.com) as the basic image.

Docker pull xxxx

2. Run the downloaded image.

Docker run -dt -p host port: mirror port --name give a name mirror id/mirror name bash

-d run in the background
-t generate a pseudo terminal
-p Specify the port
--name Give a name to the running container

3. There are two ways to enter the container

(1) docker exec -it container name/container id bash (ctrl d will not stop the running container when exiting)

(2) Docker attach container name/container id (ctrl d will stop the running container when exiting)

4 .Start downloading the corresponding tools and required dependency packages required for the compilation environment

(1) yum installs wget and the compiled tools yum install -y wget gcc gcc-c make openssl-devel

(2) Update domestic yum source

Wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/xxx/
Xxx表示你要选择的yum源
-O 下载并以不同的文件名保存
CentOS-Base.repo 表示命名的yum源

(3) Download each version of nginx version

Wget http://nginx.org/download/xxx
Xxx表示你要选择的nginx的版本

(4) Download pcre

ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/xxx

Xxx represents the selected one Version

(5) Update yum to ensure the latest

Yum update

(6) Download php7

http://php.net/downloads. php

Select version, select country

(7) Paste all the downloaded things above into /usr/local/src and unzip them all

(8) Compile nginx

(1) Create nginx user

 groupadd -r nginx
useradd -r -g nginx nginx

(2) Compile and install nginx

cd xxx 切换到您的nginx目录
./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre=/usr/local/src/pcre-8.37
./configure参数说明:
--prefix=指定文件的安装目录
--user=指定用户
--group指定用户组
--with-使用已有的软件包和库文件
Make && make install 出现问题自行百度
echo "daemon off;" >> /usr/local/nginx/conf/nginx.conf #在nginx的配置文件里加上这一行很关键,这样nginx可以在docker启动的时候在后台运行!

(9) Compile php

(1) Prepare php dependency package

yum install -y bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel sqlite-devel

(2) Enter the php file directory

(3) Start compiling php

./configure --prefix=/usr/local/php --with-zlib-dir --with-freetype-dir --enable-mbstring --with-libxml-dir=/usr/local/libxml --enable-soap --enable-calendar --with-curl --with-mcrypt --with-zlib --with-gd --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --enable-exif --enable-bcmath --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-pdo-mysql --with-mysqli --with-jpeg-dir=/usr/local/libjpeg --with-png-dir=/usr/local/libpng --enable-gd-native-ttf --with-openssl --with-fpm-user=www --with-fpm-group=www --with-libdir=lib64 --enable-ftp --with-imap --with-imap-ssl --with-kerberos --with-gettext --with-xmlrpc --with-xsl --enable-opcache --enable-fpm --enable-xml --enable-shmop --enable-session --enable-ctype --with-iconv-dir --with-iconv

Note: If there is any problem, please refer to Baidu.

(4) make && make install

(5) Prepare php configuration file

cp php.ini-production /etc/php.ini
cd /usr/local/php/etc
cp php-fpm.conf.default php-fpm.conf

(6) Modify configuration File

;Remove the comment of daemonize = yes, and change yes to no

(7) Install yar extension

(1) Install binary packaging protocol msgpack

find / -name phpize 查找phpize是否存在
yum install php-devel 
pecl install msgpack

Note: Baidu if there is a problem

(2) Download yar wget http://pecl.php.net/get/xxx

Xxx indicates that it is very important to check the version with the php version.

(3) Decompress and compile tar -zxvf yar-2.0.0.tgz

(4) cd cd yar-2.0.0

( 5)/usr/bin/phpize

(6)./configure --with-php-config=/usr/bin/php-config7.0*

(7) make && make install

(8) If the module is not installed, you can use php --ini to check the relative adjustment of the ini path

(9) docker commit - m "Description" -a "Author" Container id Warehouse information mydocker/nginx: version information v1

(10) docker save xxx > /home/save.tar

(11)Docker load xxx

If an error is reported during the compilation and installation process, follow the error prompts to use yum to resolve the dependencies; if the current yum source cannot be resolved, then you can try:

 wget http://www.atomicorp.com/installers/atomic
    chmod +x atomic
    ./atomic 
    yum install -y XXX XXX

Related recommendations:

php7Install yarExtension method

Comprehensive analysis of php7Installing yarExtension method

What is yarn? yarHow does n manage front-end project module dependencies instead of npm?

The above is the detailed content of Detailed explanation of php7 installation yar and generating docker image. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Performance Tuning for High Traffic WebsitesPHP Performance Tuning for High Traffic WebsitesMay 14, 2025 am 12:13 AM

ThesecrettokeepingaPHP-poweredwebsiterunningsmoothlyunderheavyloadinvolvesseveralkeystrategies:1)ImplementopcodecachingwithOPcachetoreducescriptexecutiontime,2)UsedatabasequerycachingwithRedistolessendatabaseload,3)LeverageCDNslikeCloudflareforservin

Dependency Injection in PHP: Code Examples for BeginnersDependency Injection in PHP: Code Examples for BeginnersMay 14, 2025 am 12:08 AM

You should care about DependencyInjection(DI) because it makes your code clearer and easier to maintain. 1) DI makes it more modular by decoupling classes, 2) improves the convenience of testing and code flexibility, 3) Use DI containers to manage complex dependencies, but pay attention to performance impact and circular dependencies, 4) The best practice is to rely on abstract interfaces to achieve loose coupling.

PHP Performance: is it possible to optimize the application?PHP Performance: is it possible to optimize the application?May 14, 2025 am 12:04 AM

Yes,optimizingaPHPapplicationispossibleandessential.1)ImplementcachingusingAPCutoreducedatabaseload.2)Optimizedatabaseswithindexing,efficientqueries,andconnectionpooling.3)Enhancecodewithbuilt-infunctions,avoidingglobalvariables,andusingopcodecaching

PHP Performance Optimization: The Ultimate GuidePHP Performance Optimization: The Ultimate GuideMay 14, 2025 am 12:02 AM

ThekeystrategiestosignificantlyboostPHPapplicationperformanceare:1)UseopcodecachinglikeOPcachetoreduceexecutiontime,2)Optimizedatabaseinteractionswithpreparedstatementsandproperindexing,3)ConfigurewebserverslikeNginxwithPHP-FPMforbetterperformance,4)

PHP Dependency Injection Container: A Quick StartPHP Dependency Injection Container: A Quick StartMay 13, 2025 am 12:11 AM

APHPDependencyInjectionContainerisatoolthatmanagesclassdependencies,enhancingcodemodularity,testability,andmaintainability.Itactsasacentralhubforcreatingandinjectingdependencies,thusreducingtightcouplingandeasingunittesting.

Dependency Injection vs. Service Locator in PHPDependency Injection vs. Service Locator in PHPMay 13, 2025 am 12:10 AM

Select DependencyInjection (DI) for large applications, ServiceLocator is suitable for small projects or prototypes. 1) DI improves the testability and modularity of the code through constructor injection. 2) ServiceLocator obtains services through center registration, which is convenient but may lead to an increase in code coupling.

PHP performance optimization strategies.PHP performance optimization strategies.May 13, 2025 am 12:06 AM

PHPapplicationscanbeoptimizedforspeedandefficiencyby:1)enablingopcacheinphp.ini,2)usingpreparedstatementswithPDOfordatabasequeries,3)replacingloopswitharray_filterandarray_mapfordataprocessing,4)configuringNginxasareverseproxy,5)implementingcachingwi

PHP Email Validation: Ensuring Emails Are Sent CorrectlyPHP Email Validation: Ensuring Emails Are Sent CorrectlyMay 13, 2025 am 12:06 AM

PHPemailvalidationinvolvesthreesteps:1)Formatvalidationusingregularexpressionstochecktheemailformat;2)DNSvalidationtoensurethedomainhasavalidMXrecord;3)SMTPvalidation,themostthoroughmethod,whichchecksifthemailboxexistsbyconnectingtotheSMTPserver.Impl

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor