Dockerize Web Server using NGINX and PHP-FPM

Dockerize Web Server using NGINX and PHP-FPM

Hi Welcome. In this video, i’m gonna show you how to dockerize your webserver using nginx and php-fpm. Ok. Assume you already install docker daemon and docker-compose in your system. So, we can be focus with docker-compose file. Let’s me start to configure. For this example, i will place docker-compose file inside of directory /opt and /nginx-php. Okey. Create docker-compose file. Okey, version 3 Service web, I’m using nginx alpine for small container. and Port forwarding, port 80. and i will mount volume public_html, to /public_html and mount also directory conf.d, /etc/nginx/conf.d for nginx virtual host configuration. And set network as nginxphp. For php, i’m using specific image. php-7 alpine And i will mount also Directory / public_html and i will expose port 9000 And set network nginxphp. Okey, docker-compose file already done. Okey, make sure We don’t have misconfiguration. Okey, and then we need to create document root. for public_html. Okey, index.html done. And we need to create info.php. for make sure nginx can be handle php file. Okey, in this file i’m just call fuctions phpinfo(); to show information about module in the php. Okey, close file. Okey, and then we need to create default.conf to replace default virtualhost in the container. in server block, we define listen port as default http server. and servername and document root /public_html. location / index.php and index.html and then create php conf. location for file extension php Okey, fastcgi_pass php container Port 9000 include fastcgi_param Okey Script filename document root and fastcgi script name. Okey fastcgi param for path info. Okey, done. Check again, servername php container Okey Close file. Can try docker-compose up. Ups! we have a problem in the docker-compose file line 16. i’m forgot this. Re-run again. Okey, Successfully. Check with command docker-compose ps. Okey, php and nginx is running well. Listen in port 9000 and 80. And then, we need to try in browser. successfully. And then, we can try info.php. Successfully Okey, that’s all guys. Thanks for watching this video, if you have question please comment in below. don’t forget to subscribe, and.. See you next time.

About the author


Leave a Reply

Your email address will not be published. Required fields are marked *