Linux搭建lnmp

LNMP安装

#购买一台新的服务器之后,当然是要安装环境啦!
#下面是安装LNMP的步骤

yum -y update

yum install gcc gcc-c++ make automake pcre pcre-devel zlip zlib-devel openssl openssl-devel expat-devel libtool autoconf -y

wget https://nginx.org/download/nginx-1.22.1.tar.gz

tar zvxf nginx-1.22.1.tar.gz && cd nginx-1.22.1

groupadd nginx

useradd nginx -g nginx -s /sbin/nologin -M

./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre

make && make install

mkdir /var/tmp/nginx/client -p

#新建文件
vim /usr/lib/systemd/system/nginx.service
#添加以下内容
[Unit]
Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s stop

[Install]
WantedBy=multi-user.target

#重载systemd
systemctl daemon-reload

#设置开机启动
systemctl enable nginx.service

yum -y install libxml2 libxml2-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel glibc glibc-devel glib2 glib2-devel ncurses curl gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel gmp-devel expat-devel xmlrpc-c xmlrpc-c-devel libicu-devel libmcrypt-devel libmemcached-devel libzip httpd-devel sqlite-devel -y

#进行这一步的时候,目录还在/root/nginx-1.22.1
#回到上一级目录操作下面的步骤
cd .. && wget https://www.php.net/distributions/php-7.4.33.tar.gz

wget https://github.com/Kitware/CMake/archive/refs/tags/v3.26.1.tar.gz
tar zxvf v3.26.1.tar.gz  && cd CMake-3.26.1
./configure
gmake && gmake install

wget https://libzip.org/download/libzip-1.9.2.tar.gz
tar zxvf libzip-1.9.2.tar.gz && cd libzip-1.9.2 
mkdir build && cd build && cmake .. && make && make install

wget -c https://github.com/kkos/oniguruma/archive/refs/tags/v6.9.7.1.tar.gz
tar -zvxf v6.9.7.1.tar.gz && cd oniguruma-6.9.7.1
./autogen.sh
./configure --bindir=/usr/sbin/
            --sbindir=/usr/sbin/
            --libexecdir=/usr/libexec
            --sysconfdir=/etc/
            --localstatedir=/var
            --libdir=/usr/lib64/
            --includedir=/usr/include/
            --datarootdir=/usr/share
            --infodir=/usr/share/info
            --localedir=/usr/share/locale
            --mandir=/usr/share/man/
            --docdir=/usr/share/doc/oniguruma
make && make install

groupadd www
useradd -g www www

tar zxvf php-7.4.33.tar.gz &&  cd php-7.4.33

./configure
--prefix=/usr/local/php
--with-config-file-path=/etc
--with-fpm-user=www
--with-fpm-group=www
--with-zlib-dir
--with-freetype-dir
--with-zlib-dir=DIR
--with-pcre-dir
--with-libzip=DIR
--enable-mbstring
--with-libxml-dir=/usr
--enable-xmlreader
--enable-xmlwriter
--enable-soap
--enable-calendar
--with-curl
--with-zlib
--with-gd
--with-pdo-sqlite
--with-pdo-mysql
--with-mysqli
--with-mysql-sock
--enable-mysqlnd
--disable-rpath
--enable-inline-optimization
--with-bz2
--with-zlib
--enable-sockets
--enable-sysvsem
--enable-sysvshm
--enable-pcntl
--enable-mbregex
--enable-exif
--enable-bcmath
--with-mhash
--enable-zip
--with-pcre-regex
--with-jpeg-dir=/usr
--with-png-dir=/usr
--with-openssl
--enable-ftp
--with-kerberos
--with-gettext
--with-xmlrpc
--with-xsl
--enable-fpm
--enable-opcache
--enable-fileinfo

make && make install

cp php.ini-production /etc/php.ini
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp sapi/fpm/php-fpm.service /usr/lib/systemd/system/php-fpm.service
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod a+x /etc/init.d/php-fpm 
cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf 
ln -s /usr/local/php/etc/php-fpm.d/www.conf /etc/www.conf

REDES 扩展
wget http://pecl.php.net/get/redis-4.3.0.tgz
tar zxvf redis-4.3.0.tgz && cd redis-4.3.0
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config
make && make install

GD扩展
cd ~/php-7.4.33/ext/gd
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-jpeg --with-freetype
make && make install

#php配置和启动
/etc/php.ini
/usr/local/php/etc/php-fpm.conf
/etc/www.conf
/etc/init.d/php-fpm restart
#NG配置&启动
/usr/local/nginx/conf/nginx.conf
/usr/local/nginx/sbin/nginx 
#第二篇文章中讲到如何创建软链接 该步骤即可简化为 nginx -s reload
/usr/local/nginx/sbin/nginx -s reload
本作品采用《CC 协议》,转载必须注明作者和本文链接
Reality
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
讨论数量: 9

要么宝塔,要么docker,原生安装太难受了 :joy:

1年前 评论
飞飞鱼 (楼主) 1年前
Weiwen 1年前
Dash007 1年前
勇敢的心 (作者) 1年前

还是用军哥的lnmp吧

1年前 评论
飞飞鱼 (楼主) 1年前
Dash007 1年前

一开始还以为是Lnmp集成包,没想到是源生安装。可以的。大佬 :+1:

1年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!