编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

LNMP的安装(linux安装lnmp环境)

wxchong 2024-07-20 08:44:37 开源技术 13 ℃ 0 评论

感谢大家观看这期的内容,这期我们主要是部署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



而在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



第2步,我们开始安装Nginx

在Centos与Ubuntu中,同一样命令

tar zxf nginx-1.20.2.tar.gz
cd nginx-1.20.2
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module
make && make install

安装完成,检测是否安装成功

#/usr/local/nginx/sbin/nginx -V

centos:


ubuntu:



出现nginx版本信息,这就证明安装成功。

第3步,我们来安装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-gettext
make && 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安装成功



第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.6
tar zxf mysql-5.6.39.tar.gz
cd mysql-5.6.39
cmake -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=1
make && make install 

安装完成后,查看版本信息

centos:


ubuntu



至此,LNMP安装完成,安装完成,还没有配置相关软件,若读者需要知道如何配置,可以评论留言,根据评论数来决定要不要单独做一期LNMP的配置

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表