Install Nginx on ubuntu 22.04.1 from source and then use package manager - nginx

I'm using Nginx repository to make and make install Nginx from source on server. But in some articles they ran apt install nginx at least!
My steps:
wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz && \
tar xzf /usr/src/nginx-${NGINX_VERSION}.tar.gz
And then:
cd /usr/src/nginx-${NGINX_VERSION} && \
./configure \
--prefix=/etc/nginx \
--sbin-path=/usr/bin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--add-module=/usr/src/nginx-modules/incubator-pagespeed-ngx-${NPS_VERSION}-stable \
--with-pcre \
--pid-path=/var/run/nginx.pid \
--with-http_ssl_module \
--user=nginx \
--group=nginx \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_v2_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-compat \
--with-http_slice_module \
--with-stream_ssl_module \
--modules-path=/usr/lib/nginx/modules
and run
make && make install
Define a user:
adduser --system --no-create-home --shell /bin/false --group --disabled-login nginx
Till now everything is perfect.
In my case before install the nginx from package manager my nginx version was 1.23.1 (stable version) and after install it from package manager apt install nginx it goes (1.18)
Why we need to install Nginx from package managers(like apt in this case) when we did it from source?
How can I set some specific options when I use package manager to install the Nginx?

Nginx maintenairs publish compiled nginx binaries with some predefined options.
https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#prebuilt
Those binaries may not fit for everyone or every usage. One can compile nginx from source code and use it as you do.
But in some articles they ran apt install nginx at least!
Tutorials does not tend to complicate the learning process.
Why we need to install Nginx from package managers (like apt in this case) when we did it from source?
You don't have to use any package manager at all. But if you install nginx by using apt it will try to remove your custom binary. This is why you get a different nginx version.
How can I set some specific options when I use package manager to install the Nginx?
Nginx has mainline and stable binaries published at different repositories.
Mainline - Includes the latest features and bug fixes and is always up to date.
https://docs.nginx.com/nginx/admin-guide/installing-nginx/installing-nginx-open-source/#installing-a-prebuilt-ubuntu-package-from-the-official-nginx-repository
You can specify a package version when using apt
apt update
apt list -a nginx
apt install nginx=<specific-version...>
https://askubuntu.com/questions/92019/how-to-install-specific-ubuntu-packages-with-exact-version
nginx -V shows a nginx binary's configure arguments. You may use it to compile your custom nginx binary.
Hope, this helps.

Related

Copying R Libraries to Docker Image from Local Libraries

I created a renv for my Shiny app. As you know that when you build a dockerfile, it has to install every package and its dependencies. If there are many packages, it takes long time.
I already installed packages my local machine. Also, the app will run on the remote machine. Is there any chance to copy the all libraries without restoring the renv? My local machine is macOS and my remote machine is Ubuntu. Due to the different Operating Systems might not work to use libraries. Probably, there are different dependencies between macOS and Ubuntu for the R packages.
Which is the best way to install R packages in a Dockerfile? Should I wait long docker building every time?
Directory
FROM openanalytics/r-base
# system libraries of general use
RUN apt-get update && apt-get install -y \
sudo \
nano \
automake \
pandoc \
pandoc-citeproc \
libcurl4-openssl-dev \
libcairo2-dev \
libxt-dev \
libssl-dev \
libssh2-1-dev \
libssl1.1 \
libmpfr-dev \
# RPostgres
libpq-dev \
libssl-dev \
# rvest
libxml2-dev \
libssl-dev
# Install Packages
# RUN R -e "install.packages(c('janitor','DBI','RPostgres','httr', 'rvest','xml2', 'shiny', 'rmarkdown', 'tidyverse', 'lubridate','shinyWidgets', 'shinyjs', 'shinycssloaders', 'openxlsx', 'DT'), repos='https://cloud.r-project.org/')"
# copy the app to the image
RUN mkdir /root/appfile
COPY appfile /root/appfile
# renv restore
RUN Rscript -e 'install.packages("renv")'
RUN Rscript -e "renv::restore(lockfile = '/root/appfile/renv.lock')"
EXPOSE 3838
CMD ["R", "-e", "shiny::runApp('/root/appfile')"]
Thanks.

Not found bin/sh Docker Image

I am trying to deploy my Shiny app on my own server, but I cannot solve this issue. This is my docker image
FROM rocker/tidyverse
## App folder
WORKDIR /home/admin/shinyAppCovid/
ADD /shinyApp /shinyApp/
ADD /dependencias.txt /usr/local/bin/
RUN apt-get update && apt-get install -y \
sudo \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev \
libxt-dev \
libssl-dev \
libssh2-1-dev
# expose port
EXPOSE 8080
# Download and install library
RUN R -e 'install.packages(read.csv("/usr/local/bin/dependencias.txt")[,1], depencencies=TRUE, repos="http://cran.rstudio.com/")'
# run app on container start
CMD ['/usr/bin/R', "-e", "shiny::runApp("/shinyApp/shiny", host = '0.0.0.0', port = 8080)"]
The problem is that when i a try to run a container this is what i have
/bin/sh: 1: [/usr/bin/R,: not found
I changed the last line for jus R and is not working I am still having the same issue, How can I do?

cannot install devtools in r shiny docker

I'm trying to build a docker image for my shiny app. Below is my dockerfile. When I build my images, everything else seems fine, except I got error message Error in library(devtools) : there is no package called ‘devtools’ Execution halted. I also tried devtools::install_github('nik01010/dashboardthemes') with no success. I have non clue why? What could go wrong? Do anyone know what is wrong with my dockerfile? Thanks a lot.
# Install R version 3.6
FROM r-base:3.6.0
# Install Ubuntu packages
RUN apt-get update && apt-get install -y \
sudo \
gdebi-core \
pandoc \
pandoc-citeproc \
libcurl4-gnutls-dev \
libcairo2-dev/unstable \
libxt-dev \
libssl-dev
# Download and install ShinyServer (latest version)
RUN wget --no-verbose https://s3.amazonaws.com/rstudio-shiny-server-os-build/ubuntu-12.04/x86_64/VERSION -O "version.txt" && \
VERSION=$(cat version.txt) && \
wget --no-verbose "https://s3.amazonaws.com/rstudio-shiny-server-os-build/ubuntu-12.04/x86_64/shiny-server-$VERSION-amd64.deb" -O ss-latest.deb && \
gdebi -n ss-latest.deb && \
rm -f version.txt ss-latest.deb
# Install R packages that are required
RUN R -e "install.packages(c('devtools', 'shiny','shinythemes','shinydashboard','shinyWidgets','shinyjs', 'tidyverse', 'dplyr', 'ggplot2','rlang','DT','lubridate', 'plotly', 'leaflet', 'mapview', 'tigris', 'rgdal', 'visNetwork', 'wordcloud2', 'arules'), repos='http://cran.rstudio.com/')"
RUN R -e "library(devtools)"
RUN R -e "install_github('nik01010/dashboardthemes')"
# Copy configuration files into the Docker image
COPY shiny-server.conf /etc/shiny-server/shiny-server.conf
COPY /app /srv/shiny-server/
# Make the ShinyApp available at port 80
EXPOSE 80
# Copy further configuration files into the Docker image
COPY shiny-server.sh /usr/bin/shiny-server.sh
CMD ["/usr/bin/shiny-server.sh"]
There are a few approaches you might try.
Easiest:
Use remotes::install_github instead of devtools. remotes has many fewer dependencies if you don't need the other functionality.
Second Easiest:
Use rocker/tidyverse image from Docker Hub instead of baseR image.
docker pull rocker/tidyverse
Change line 2:
FROM rocker/verse
Hardest:
Otherwise, you will need to figure out which dependencies you need to install inside your docker image before you can install devtools. It will likely be obvious if you try to install it interactively.
Make sure the container is running
Get the container name using docker ps
Start a shell with docker exec -it <container name> /bin/bash
Start R and try to install devtools interactively

./configure: error: the HTTP XSLT module requires the libxml2/libxslt libraries

I recently updated my mac-os to Mojave. I was using Nginx and it was working on my previous os but after updating to Mojave, I am not able to start my Nginx.
So I tried to install it again, first, it gave me c compiler error, So I downloaded the Xcode command-line tools and it was gone. Now it gives me libxml2/libxslt libraries not found. I tried to install it using brew but I still get the same error. I am not sure what is going wrong.
I have downloaded libxml2 and libxslt using brew install.
My configure script.
./configure \
--prefix=/opt/nginx/$NGINX_NAME_VERSION \
--pid-path=/var/run/nginx.pid \
--conf-path=/etc/nginx/$NGINX_NAME_VERSION/conf/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--lock-path=/var/lock/nginx.lock \
--http-client-body-temp-path=/var/tmp/nginx/body \
--http-fastcgi-temp-path=/var/tmp/nginx/fastcgi \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--with-debug \
--with-http_addition_module \
--with-http_dav_module \
--with-http_geoip_module \
--with-http_gzip_static_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-http_sub_module \
--with-http_xslt_module \
--with-mail \
--with-mail_ssl_module \
--with-cc-opt=-I/usr/local/opt/openssl/include \
--with-ld-opt=-L/usr/local/opt/openssl/lib \
--builddir=$NGINX_BUILD_PATH
Error :
checking for OpenSSL library ... found
checking for zlib library ... found
checking for libxslt ... not found
checking for libxslt in /usr/local/ ... not found
checking for libxslt in /usr/pkg/ ... not found
checking for libxslt in /opt/local/ ... not found
You can see it is able to find OpenSSL, zlib but not libxslt. Please someone help me to resolve the issue.
Try the following
sudo apt-get install libxslt-dev
You might also need
sudo apt-get install libgd-dev # for the "error: the HTTP image filter module requires the GD library." error
sudo apt-get install libgeoip-dev # for the GeoIP package
Sometimes you know you have installed libxslt but nginx still keeps yelling you are not.
The actual problem behind is not about whether libxslt has been installed, is about can nginx successfully link to it. In the end, I discovered that libxlst links to an older version of icu installed on my environment. I then realize that my libxml2 is too old. After upgrading my libxml2, everything works again.

How to add support of "secure_link" to already installed OpenResty?

I have an error in the logs of OpenResty:
unknown directive secure_link
I'm on Arch Linux and I installed OpenResty the standard way
yay -S openresty
How do I add support of secure_link to it?
You don't. The only way to add new modules to nginx is to recompile it.
Here's a snippet from the bash script I use pretty much everywhere to install openresty:
latest='openresty-1.13.6.2'
apt-get -y install libpcre3-dev libssl-dev perl make build-essential curl libzip-dev
wget 'https://openresty.org/download/'$latest'.tar.gz'
tar -xzf $latest'.tar.gz'
cd $latest
./configure \
--with-http_v2_module \
--with-http_ssl_module \
&& make -j $(nproc) && make install || exit
cd ..
find -maxdepth 1 -name "$latest*" | xargs rm -rf
From there you should be able to copy and paste your way to a working openresty installation.

Resources