Docker: Instal & Konfig Lemp Ubuntu 16.04

3 menit waktu baca

Langsung saja, berikut docker images yang saya create untuk Lemp Ubuntu 16.04 (lebih detailnya: Ubuntu 16.04, Nginx, MariaDB 10.2.x, PHP 5.6.x, PHP 7.1.x, PhpMyadmin):

Pull Container

docker pull wiro/lemp-5.6-7.1-pma

Jalankan Continer

docker run -it -p 80:80 -p 443:443 wiro/lemp-5.6-7.1-pma

User & Password MariaDB: root:wiros4bleng

Berikut Dockerfile-nya apabila lebih memilih membuat images sendiri:

FROM ubuntu

ENV	MARIADB_VER=10.2
ENV	NODE_VER=8
ENV MYSQL_PWD wiros4bleng

# Update OS
RUN apt-get update && apt-get install -y unzip curl --no-install-recommends apt-utils && apt-get -y dist-upgrade && apt-get install -y software-properties-common python-software-properties

# Install PHP 5.6
RUN LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php \
	&& apt-get update \
	&& apt-get -y install \
	php-ssh2 \
	php5.6 \
	php5.6-cli \
	php5.6-curl \
	php5.6-mysql \
	php5.6-pgsql \
	php5.6-sqlite3 \
	php5.6-mysqlnd \
	php5.6-mcrypt \
	php5.6-fpm \
	php5.6-soap \
	php5.6-gd \
	php5.6-gmp \
	php5.6-imap \
	php5.6-json \
	php5.6-ldap \
	php5.6-curl \
	php5.6-zip \
	php5.6-bz2 \
	php5.6-bcmath \
	php5.6-xml \
	php5.6-xmlrpc \
	php5.6-zip \
	php5.6-cgi \
	php5.6-cg \
	php5.6-mbstring \
	php5.6-igbinary \
	php5.6-imagick \
	php5.6-intl \
	php5.6-mcrypt \
	php5.6-msgpack \
	php5.6-xdebug \
	php5.6-xsl \
	php5.6-opcache \
	php5.6-readline \
	php5.6-snmp \
	&& systemctl enable php5.6-fpm.service

	# Install PHP 7.1
	RUN apt-get -y install \
		php7.1 \
		php7.1-cli \
		php7.1-curl \
		php7.1-mysql \
		php7.1-pgsql \
		php7.1-sqlite3 \
		php7.1-mysqlnd \
		php7.1-mcrypt \
		php7.1-fpm \
		php7.1-soap \
		php7.1-gd \
		php7.1-gmp \
		php7.1-imap \
		php7.1-json \
		php7.1-ldap \
		php7.1-curl \
		php7.1-zip \
		php7.1-bz2 \
		php7.1-bcmath \
		php7.1-xml \
		php7.1-xmlrpc \
		php7.1-zip \
		php7.1-cgi \
		php7.1-cg \
		php7.1-mbstring \
		php7.1-igbinary \
		php7.1-imagick \
		php7.1-intl \
		php7.1-mcrypt \
		php7.1-msgpack \
		php7.1-xdebug \
		php7.1-xsl \
		php7.1-opcache \
		php7.1-readline \
		php7.1-snmp \
		&& systemctl enable php7.1-fpm.service

# Install MariaDB
RUN echo "mariadb-server mariadb-server/root_password password $MYSQL_PWD" | debconf-set-selections
RUN echo "mariadb-server mariadb-server/root_password_again password $MYSQL_PWD" | debconf-set-selections
RUN apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8 \
	&& echo "deb [arch=amd64,i386,ppc64el] http://sgp1.mirrors.digitalocean.com/mariadb/repo/${MARIADB_VER}/ubuntu $(lsb_release -sc) main" > /etc/apt/sources.list.d/mariadb.list \
  && apt-key adv --recv-keys --keyserver keyserver.ubuntu.com F1656F24C74CD1D8 \
	&& apt-get update && apt-get -y install mariadb-server \
	&& systemctl enable mariadb.service

# Install Nginx
RUN add-apt-repository -y ppa:nginx/stable \
	&& apt-get -y install nginx \
	&& systemctl enable nginx.service \
	&& service nginx stop

# Install self-signed SSL
RUN openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/ssl/private/nginx.key -out /etc/ssl/certs/nginx.crt \
	&& chmod 400 /etc/ssl/private/nginx.key

# Config NGINX
RUN curl -L https://gitlab.com/tohir212/instan-install-lemp/raw/master/server-configs-nginx-1.13.x.tar.gz | tar -xz \
	&& rm /etc/nginx/sites-available/* \
	&& mv server-configs-nginx-1.13.x/sites-available/* /etc/nginx/sites-available \
	&& mv server-configs-nginx-1.13.x/nginx.conf /etc/nginx \
	&& cp server-configs-nginx-1.13.x/fastcgi_params /etc/nginx

# Setup Permission
RUN chown -R $whoami:www-data /usr/share/nginx/html \
	&& sh -c 'find /usr/share/nginx/html -type d -print0 | xargs -0 chmod 0750' \
	&& sh -c 'find /usr/share/nginx/html -type d -print0 | xargs -0 chmod g+s' \
	&& sh -c 'find /usr/share/nginx/html -type f -print0 | xargs -0 chmod 0640' \
	&& chown -R www-data:root /var/lib/nginx \
	&& chown -R www-data:root /var/lib/php \
	&& chmod 755 /var/lib/php/sessions \
	&& chown -R www-data:root /var/run/php \
	&& chown -R www-data:root /usr/lib/php/5.6 \
	&& chown -R www-data:root /usr/lib/php/7.1

# Config pool 5.6
RUN sed -i 's|pm.max_children = 5|pm.max_children = 100|g' /etc/php/5.6/fpm/pool.d/www.conf \
	&& sed -i 's|pm.start_servers = 2|pm.start_servers = 5|g' /etc/php/5.6/fpm/pool.d/www.conf \
	&& sed -i 's|pm.min_spare_servers = 1|pm.min_spare_servers = 3|g' /etc/php/5.6/fpm/pool.d/www.conf \
	&& sed -i 's|pm.max_spare_servers = 3|pm.max_spare_servers = 10|g' /etc/php/5.6/fpm/pool.d/www.conf \
	&& sed -i 's|;pm.max_requests = 500|pm.max_requests = 200|g' /etc/php/5.6/fpm/pool.d/www.conf

# Config pool 7.1
RUN sed -i 's|pm.max_children = 5|pm.max_children = 100|g' /etc/php/7.1/fpm/pool.d/www.conf \
	&& sed -i 's|pm.start_servers = 2|pm.start_servers = 5|g' /etc/php/7.1/fpm/pool.d/www.conf \
	&& sed -i 's|pm.min_spare_servers = 1|pm.min_spare_servers = 3|g' /etc/php/7.1/fpm/pool.d/www.conf \
	&& sed -i 's|pm.max_spare_servers = 3|pm.max_spare_servers = 10|g' /etc/php/7.1/fpm/pool.d/www.conf \
	&& sed -i 's|;pm.max_requests = 500|pm.max_requests = 200|g' /etc/php/7.1/fpm/pool.d/www.conf

RUN apt-get install -y ssh

RUN cd /usr/share/nginx/html/ \
	&& wget https://files.phpmyadmin.net/phpMyAdmin/4.7.9/phpMyAdmin-4.7.9-all-languages.zip \
	&& unzip phpMyAdmin-4.7.9-all-languages.zip \
	&& rm phpMyAdmin-4.7.9-all-languages.zip \
	&& mv phpMyAdmin-4.7.9-all-languages pma

RUN service nginx restart
RUN service php5.6-fpm restart
RUN service php7.1-fpm restart
RUN service mysql restart

EXPOSE	22 80 443 3306

Tinggalkan komentar