感谢大家不雅观看这期的内容,这期我们紧张是支配LNMP。
首先,我们先看NMP的软件版本
N nginx-1.20.2

M mysql-5.6.39
P php-5.6.40
而L,则为上两期安装的Ubuntu 20.04(192.168.48.93)与Centos 7 2009(192.168.48.92)的linux系统
接着,安装目录都定在/usr/local,即三个软件的安装路径为
/usr/local/nginx
/usr/local/php
/usr/local/mysql
而mysql的数据目录为 /data/dbs/mysql5.6
各个软件包都可以从官网高下载到,在这笔者就不啰嗦了,如果有不知道怎么下载的读者,可以留言。
在安装NMP之前,我们先安装一些根本包
在Centos中:
# yum install -y vim wget unzip make cmake nmap automake lrzsz gcc gcc-c++ openssl openssl-devel pcre pcre-devel zlib zlib-devel ncurses-devel ncurses libtool-ltdl libtool-ltdl-devel bison openssh-clients rsync gd-devel libcurl-devel libxml2 libxml2-devel libjpeg-devel libpng-devel libpng freetype freetype-devel glibc glibc-devel glib2 glib2-devel xinetd bind-utils ntpdate sysstat iptraf bc screen net-tools
Centos截图1
Centos截图2
而在Ubuntu中:
# apt-get update -y && apt-get install -y wget unzip zip make cmake lrzsz nmap xinetd bind9utils automake gcc g++ openssl bison rsync php-gd libxml2 libxml2-dev libjpeg-dev libpng-dev ntpdate sysstat iptraf bc screen net-tools libpcre3 libpcre3-dev libssl-dev zlib1g-dev libcurl4-openssl-dev libfreetype6 libfreetype6-dev libcurl4-openssl-dev
Ubuntu截图1
Ubuntu截图2
第2步,我们开始安装Nginx
在Centos与Ubuntu中,同一样命令
tar zxfnginx-1.20.2.tar.gzcdnginx-1.20.2./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_modulemake && make install
安装完成,检测是否安装成功
#/usr/local/nginx/sbin/nginx -V
centos:
centos的nginx
ubuntu:
ubuntu的nginx
涌现nginx版本信息,这就证明安装成功。
第3步,我们来安装php
php
在Centos中,先安装libmcrypt,这个yum安装比较折腾,在这就改为源码安装
tar zxf libmcrypt-2.5.7.tar.gz cd libmcrypt-2.5.7 ./configure --prefix=/usr/local/libmcrypt make && make instal
然后就安装php
tar zxf php-5.6.40.tar.gz cd php-5.6.40 ./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --disable-debug --with-iconv --enable-inline-optimization --with-zlib --enable-zip --enable-mbstring --enable-soap --with-curl --enable-pcntl --enable-bcmath --enable-sockets --enable-ftp --enable-exif --enable-gd-native-ttf --with-gd --with-freetype-dir=/usr/local --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-openssl --with-mcrypt=/usr/local/libmcrypt --with-gettextmake && make install
在Ubuntu中,可以apt安装libmcrypt
apt-get install -y mcrypt libmcrypt-dev
由于在20.04中,freetype版本2.10.1对付php-5.6.40来说,版本过高,须要安装一个低一点的版本,freetype-2.8.1
#tar zxf freetype-2.8.1.tar.gz #cd freetype-2.8.1 #./configure --prefix=/usr/local/freetype #make && make install
并且在20.04中,OpenSSL 1.1.1f对付php-5.6.40来说,版本也过高,须要安装一个低一点的版本,openssl-1.0.2k
#tar zxf openssl-1.0.2k.tar.gz #cd openssl-1.0.2k #./config --prefix=/usr/local/openssl #make && make install
然后就安装php-5.6.40了
#tar zxf php-5.6.40.tar.gz#cd php-5.6.40#./configure --prefix=/usr/local/php --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --disable-debug --with-iconv --enable-inline-optimization --with-zlib --enable-zip --enable-mbstring --enable-soap --with-curl --enable-pcntl --enable-bcmath --enable-sockets --enable-ftp --enable-exif --enable-gd-native-ttf --with-gd --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-openssl=/usr/local/openssl/ --with-mcrypt --with-gettext#make && make install
这个的安装韶光有点长,安装完成后,可以查看到版本信息,证明php安装成功
centos中的php
ubuntu中的php
第4步,安装mysql5.6.36
由于我们在第1步的时候安装了很多的根本依赖包,以是这里并未须要安装什么依赖包
centos:
yum install -y libxml2-python libxml2-static zlib-static
ubuntu:
apt-get install -y libncurses5-dev
开始安装:
chown mysql.mysql /data/dbs/mysql5.6tar zxf mysql-5.6.39.tar.gzcd mysql-5.6.39cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/dbs/mysql5.6 -DSYSCONFDIR=/srv/mysql5.6 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_FEDERATED_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306 -DWITH_DEBUG=0 -DENABLED_LOCAL_INFILE=1make && make install
安装完成后,查看版本信息
centos:
ubuntu
至此,LNMP安装完成,安装完成,还没有配置干系软件,若读者须要知道如何配置,可以评论留言,根据评论数来决定要不要单独做一期LNMP的配置