Related articles: Install Docker using yum under CentOS7 Using Docker to build a PHP operating environment in Win10 environment 1. Create a private network docker network create lnmp The private network is created successfully: 2. Install Nginx Mirror address: https://hub.docker.com/_/nginx?tab=tags You can install the latest version of Nginx. Here, you can search for tags and pull the Nginx1.18.0 image: docker pull nginx:1.18.0 Use the docker images command to check that the Nginx image is installed successfully: Run Nginx: #Run the container docker run --name nginx -p 8080:80 -v /root/docker/nginx/html:/usr/share/nginx/html -d nginx:1.18.0 #Move to the configuration directory cd /root/docker/nginx #Copy the configuration file docker cp nginx:/etc/nginx/conf.d conf.d #Stop the container docker stop nginx #Delete the container docker rm nginx #Run again docker run --name nginx -p 8080:80 --network lnmp -v /root/docker/nginx/html:/usr/share/nginx/html -v /root/docker/nginx/conf.d:/etc/nginx/conf.d/ -d nginx:1.18.0 Test: Create an index.html file in the html directory of the Nginx site root directory and write the following text: echo "Nginx Server" >> /root/docker/nginx/html/index.html The browser accesses the host address 127.0.0.1:8080 as follows, and Nginx is installed successfully: 3. Install MySQL Mirror address: https://hub.docker.com/_/mysql?tab=tags , pull the MySQL5.7.34 image here: docker pull mysql:5.7.35 Run MySQL: docker run --name mysql5.7 --network lnmp -v /root/docker/mysql/:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=123456 -d --privileged=true mysql:5.7.35 4. Install PHP Mirror address: https://hub.docker.com/_/php?tab=tags, pull the PHP7.4 image here: docker pull php:7.4-fpm Run PHP: #Run the image docker run --name php7.4 --network lnmp -d php:7.4-fpm #Create directory mkdir -p /root/docker/php #Move directory cd /root/docker/php/ #Copy www.conf docker cp php7.4:/usr/local/etc/php-fpm.d/www.conf www.conf #Enter the container docker exec -it php7.4 bash #Move directory cd /usr/src/ #Unzip the file xz -d php.tar.xz #Unzip the file tar -xvf php.tar #Exit the image exit #Copy php.ini docker cp php7.4:/usr/src/php-7.4.22/php.ini-production php.ini #Stop the image docker stop php7.4 #Delete the image docker rm php7.4 #Run the image again docker run --name php7.4 --network lnmp -v /root/docker/nginx/html:/var/www/html -v /root/docker/php/www.conf:/usr/local/etc/php-fpm.d/www.conf -v /root/docker/php/php.ini:/usr/local/etc/php/php.ini -d php:7.4-fpm Edit the Nginx configuration file vim /root/docker/nginx/conf.d: server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { root /usr/share/nginx/html; index index.php index.html index.htm; try_files $uri $uri/ =404; } error_page 404 /404.html; location = /40x.html { root /user/share/nginx/html; } # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ \.php$ { root /var/www/html/; fastcgi_pass php7.4:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } Create the index.php file: vim /root/docker/nginx/html/index.php <?php phpinfo(); Restart the Nginx image: (The process ID is viewed through the docker ps command) docker restart 43aea5a90446 At this time, the browser accesses the host address 127.0.0.1:8080 as follows, and PHP is installed successfully: This is the end of this article about using Docker to build a PHP operating environment in a CentOS7 environment. For more information about using Docker to build a PHP operating environment, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
>>: Example of implementing grouping and deduplication in MySQL table join query
Table of contents A. Docker deployment of springb...
mysql permissions and indexes The highest user of...
MySQL is a free relational database with a huge u...
1. Tomcat service is not open Enter localhost:808...
1. mysql export file: SELECT `pe2e_user_to_compan...
1: Install SVN yum install -y subversion 2. Creat...
1. Filter Example: <!DOCTYPE html> <html...
Preface Take Element Plus as an example to config...
1. MySQL rpm package installation # Download the ...
In the previous article, we introduced how to use...
Introduction to four commonly used MySQL engines ...
Today I designed a dynamic window style for publis...
question When installing Docker using Alibaba Clo...
Table of contents 1. What is a design pattern? 2....
Messy log Nginx in daily use is mostly used as bo...