Build lnmp environment on centos source code

Source: Internet
Author: User
Tags openssl version
Preface

1. Prerequisites:

  • Centos Linux release 7.5.1804;
  • Sudo user (root permission required );

2. components to be installed:

  • Nginx stable version: nginx-1.14.0;
  • Mariadb 10.3.10 stable;
  • PHP 7.2.11 stable;

3. Procedure:

  • Add environment dependency packages;
  • Install libiconv and libmcrypt;
  • Install nginx;
  • Install PHP;
  • Install mariadb;
Download the installation package
wget http://nginx.org/download/nginx-1.14.0.tar.gz &&  tar xzvf nginx-1.14.0.tar.gz wget http://am1.php.net/distributions/php-7.2.11.tar.gz && tar xzvf php-7.2.11.tar.gzwget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz &&  tar xzvf libiconv-1.14.tar.gzwget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz && tar xzvf ./libmcrypt-2.5.8.tar.gz

Delete unnecessary source code packages:

rm -rf *.tar.gz
Add environment dependency package

The following dependency packages are the basic dependency packages required during the entire lnmp build process. If an error occurs during the installation process and a dependency package is missing, you can install it on your own:

# Run the following command, parameters are separated by spaces. sudo Yum-y install zlib-devel PCRE-devel OpenSSL-devel GCC gcc-C ++ ncurses-devel Perl-extutils-embedlibjpeg libjpeg- devel libpng-devel FreeType-devel libxml2 libxml2-devel curl-devel libxslt-devel Gd-devel geoip-devel
Compile nginx

To enable HTTP/2 for nginx, you must install nginx in the source code and specify that the version of -- With-OpenSSL is later than version 1.0.2./usr/local/srcDirectory:

$ cd /usr/local/src/# PCRE version 8.40$ sudo wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz && sudo tar xzvf pcre-8.40.tar.gz# zlib version 1.2.11$ sudo wget https://www.zlib.net/zlib-1.2.11.tar.gz && sudo tar xzvf zlib-1.2.11.tar.gz# OpenSSL version openssl-1.1.0h$ sudo wget https://www.openssl.org/source/openssl-1.1.0h.tar.gz && sudo tar xzvf openssl-1.1.0h.tar.gz

Delete unnecessary packages

sudo rm -rf *.tar.gz

Compile nginx

cd ~/src/nginx-1.14.0
sudo ./configure --prefix=/etc/nginx             --sbin-path=/usr/sbin/nginx             --modules-path=/usr/lib64/nginx/modules             --conf-path=/etc/nginx/nginx.conf             --error-log-path=/var/log/nginx/error.log             --pid-path=/var/run/nginx.pid             --lock-path=/var/run/nginx.lock             --user=nginx             --group=nginx             --build=CentOS             --builddir=nginx-1.14.0             --with-select_module             --with-poll_module             --with-threads             --with-file-aio             --with-http_ssl_module             --with-http_v2_module             --with-http_realip_module             --with-http_addition_module             --with-http_xslt_module=dynamic             --with-http_image_filter_module=dynamic             --with-http_geoip_module=dynamic             --with-http_sub_module             --with-http_dav_module             --with-http_flv_module             --with-http_mp4_module             --with-http_gunzip_module             --with-http_gzip_static_module             --with-http_auth_request_module             --with-http_random_index_module             --with-http_secure_link_module             --with-http_degradation_module             --with-http_slice_module             --with-http_stub_status_module             --http-log-path=/var/log/nginx/access.log             --http-client-body-temp-path=/var/cache/nginx/client_temp             --http-proxy-temp-path=/var/cache/nginx/proxy_temp             --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp             --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp             --http-scgi-temp-path=/var/cache/nginx/scgi_temp             --with-mail=dynamic             --with-mail_ssl_module             --with-stream=dynamic             --with-stream_ssl_module             --with-stream_realip_module             --with-stream_geoip_module=dynamic             --with-stream_ssl_preread_module             --with-compat             --with-pcre=/usr/local/src/pcre-8.40             --with-pcre-jit             --with-zlib=/usr/local/src/zlib-1.2.11             --with-openssl=/usr/local/src/openssl-1.1.0h             --with-openssl-opt=no-nextprotoneg             --with-debug

Above--prefix=/etc/nginxIs the installation directory.

sudo make && sudo make install

Create a soft link

sudo ln -s /usr/lib64/nginx/modules /etc/nginx/modules

In this way, you can load the dynamic module: load_module modules/ngx_foo_module.so; In the nginx configuration file ;.

View compilation Information

sudo nginx -V

Modify/etc/nginx. conf

Removeuser nobody;Comments of a row.

Check for potential configuration errors

# When performing the check, the following error may be reported: sudo nginx-tngbid: the configuration file/etc/nginx. conf syntax is oknginx: [emerg] mkdir () "/var/Cache/nginx/client_temp" failed (2: no such file or directory) nginx: configuration file/etc/nginx. conf test failed # if an error is reported, run the following code sudo mkdir-P/var/Cache/nginx & sudo nginx-T

Create an nginx System Service Unit

Edit file:

sudo vi /usr/lib/systemd/system/nginx.service

Copy the following content

[Unit]Description=nginx - high performance web serverDocumentation=https://nginx.org/en/docs/After=network-online.target remote-fs.target nss-lookup.targetWants=network-online.target[Service]Type=forkingPIDFile=/var/run/nginx.pidExecStartPre=/usr/sbin/nginx -t -c /etc/nginx/nginx.confExecStart=/usr/sbin/nginx -c /etc/nginx/nginx.confExecReload=/bin/kill -s HUP $MAINPIDExecStop=/bin/kill -s TERM $MAINPID[Install]WantedBy=multi-user.target

Start nginx and set startup

sudo systemctl start nginx.service && sudo systemctl enable nginx.service

So far, nginx installation has ended. For nginx source code Installation Reference: centos7 install nginx by compiling the source code;

Next, compile the source code and install PHP.

Compile and install PHP

PHP requires libiconv, libmcrypt, and other dependencies. Compile the code below: [read the original article]

Build lnmp environment on centos source code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.