惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
aimingoo的专栏
aimingoo的专栏
Microsoft Security Blog
Microsoft Security Blog
NISL@THU
NISL@THU
T
Threatpost
T
The Exploit Database - CXSecurity.com
T
Threat Research - Cisco Blogs
S
Securelist
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
人人都是产品经理
人人都是产品经理
B
Blog RSS Feed
S
Secure Thoughts
MyScale Blog
MyScale Blog
O
OpenAI News
P
Palo Alto Networks Blog
美团技术团队
C
Cyber Attacks, Cyber Crime and Cyber Security
TaoSecurity Blog
TaoSecurity Blog
量子位
L
Lohrmann on Cybersecurity
G
GRAHAM CLULEY
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
T
Tailwind CSS Blog
Know Your Adversary
Know Your Adversary
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Simon Willison's Weblog
Simon Willison's Weblog
宝玉的分享
宝玉的分享
PCI Perspectives
PCI Perspectives
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tenable Blog
I
InfoQ
D
Darknet – Hacking Tools, Hacker News & Cyber Security
Microsoft Azure Blog
Microsoft Azure Blog
Recent Announcements
Recent Announcements
S
Security @ Cisco Blogs
S
Schneier on Security
B
Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
The Cloudflare Blog
AWS News Blog
AWS News Blog
IT之家
IT之家
V
Vulnerabilities – Threatpost
The Hacker News
The Hacker News
H
Heimdal Security Blog
I
Intezer
A
Arctic Wolf
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
H
Help Net Security
W
WeLiveSecurity

披萨盒的赛博日志

谈谈工作了半年的感受 使用策略模式重构复杂业务分支 像 systemd 一样管理 MacOS 后台常驻任务 以ORM看封装的边界 Git Merge VS Git Rebase: 如何优雅地合并分支? 修改Linux内核模块以支持WG OpenLDAP折腾日记 非特权模式容器 ssh 登录问题 在 Linux 开发环境中使用网络代理 白嫖 Aseprite 像素绘图软件 MongoDB 增删改查 Python数据分析工具包-Numpy 解决 CLion 中文乱码问题 搭建 RLCraft 服务器 SpringBoot读取配置文件 部署项目时遇到的坑 浅谈 xhr 请求跨域问题 JavaScript 学习笔记 Eclipse配置Web开发环境 Vue2 基本知识 Ribbon 简单使用 Nacos 简单使用 Spring Cloud Alibaba 环境搭建 什么是RSS?什么是Feed?它们有什么关系? Docker基本使用 TensorFlow启用GPU加速 如何进行内网穿透 Hello World! Git基本使用 Butterfly常用标签外挂
Centos 配置 LNMP 环境
披萨盒 · 2022-09-15 · via 披萨盒的赛博日志

手把手教你配置 LNMP 环境,其中大部分学习过程中需要用到的模块也在安装过程中一并安装了,或许是初学者的福音😁😁

版本说明

请注意不同版本号的软件的安装方式和软件兼容性可能有差别!!!

软件名 版本号 官网 下载链接
Linux Centos8.0 https://www.centos.org/ /
Nginx 1.23.1 https://www.nginx.com/ https://nginx.org/download/nginx-1.23.1.tar.gz
MySQL 8.0.30 https://www.mysql.com/ https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.30-1.el8.x86_64.rpm-bundle.tar
PHP 8.0.23 https://www.php.net/ https://www.php.net/distributions/php-8.0.23.tar.gz

编译安装 Nginx

  1. 下载
1
2
3
4
5
mkdir /usr/local/nginx

cd /usr/local/nginx

wget https://nginx.org/download/nginx-1.23.1.tar.gz
  1. 安装依赖
1
yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
  1. 编译
1
2
3
4
5
tar -zxvf nginx-1.23.1.tar.gz

cd nginx-1.23.1/

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_sub_module --with-http_gzip_static_module --with-pcre
  1. 安装
1
make && make install
  1. 添加环境变量(可选)
1
vim /etc/profile

将光标移动到最后一行,添加如下内容(按 i 进入输入模式,输入完成之后按 esc 进入命令模式,输入 :wq 回车即可保存并退出):export PATH=$PATH:/usr/local/nginx/sbin

1
source /etc/profile
  1. 检验
1
nginx -V

至此,Nginx 安装完毕,离成功进了一步!


安装 MySQL

  1. 首先检查系统中是否已经有了 MySQL

检查:

1
2
rpm -qa | grep mysql
rpm -qa | grep mariadb

运行后如果没有反应那就是没事,如果有的话,就运行

1
rpm -e ***  (***为对应的软件名称)
  1. 安装依赖包
1
yum -y install ncurses-devel libaio-devel libaio
  1. 下载MySQL
1
2
3
4
5
mkdir /usr/local/mysql

cd /usr/local/mysql

wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.30-1.el8.x86_64.rpm-bundle.tar
  1. 解压MySQL
1
tar -xvf mysql-8.0.30-1.el8.x86_64.rpm-bundle.tar
  1. 安装MySQL

依次每条执行以下命令(顺序很重要):

1
2
3
4
5
6
7
8
9
10
11
rpm -ivh mysql-community-common-8.0.30-1.el8.x86_64.rpm

rpm -ivh mysql-community-client-plugins-8.0.30-1.el8.x86_64.rpm

rpm -ivh mysql-community-libs-8.0.30-1.el8.x86_64.rpm

rpm -ivh mysql-community-client-8.0.30-1.el8.x86_64.rpm

rpm -ivh mysql-community-icu-data-files-8.0.30-1.el8.x86_64.rpm

rpm -ivh mysql-community-server-8.0.30-1.el8.x86_64.rpm

至此,MySQL 就安装完毕了,我们离成功又近了一步。

  1. 启动 MySQL
1
systemctl start mysqld
  1. 重置 MySQL 的 root 密码

MySQL 会有一个初识密码,通过命令获得临时密码:

1
grep "password" /var/log/mysqld.log

image-20220915215909934

登录(密码是不会显示的,放心输入):

1
mysql -u root -p

输入如下命令进行改密码:

1
2
3
alter user user() identified by "******";  (******为密码,需包含大小写字母、数字以及符号,不然报错密码过于简单)

flush privileges;
  1. 设置数据库可以以 root 身份远程访问

以 root 身份登录 MySQL,然后执行如下命令:

1
2
3
4
5
6
7
use mysql;

create user 'root'@'%' identified by '******'; //******为自己设置的密码

grant all privileges on *.* to 'root'@'%' with grant option;

flush privileges;

马上就要成功了,只差最后一个PHP!!!


编译安装 PHP

  1. 下载
1
2
3
4
5
mkdir /usr/local/php

cd /usr/local/php

wget https://www.php.net/distributions/php-8.0.23.tar.gz
  1. 安装依赖
1
yum install -y libtool automake sqlite* gcc gcc-c++  make zlib zlib-devel pcre pcre-devel  libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5* openldap* nss_ldap
  1. 有个依赖需要单独安装
1
2
3
4
5
6
7
8
9
wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O oniguruma-6.9.4.tar.gz

tar -zxvf oniguruma-6.9.4.tar.gz

cd oniguruma-6.9.4

./autogen.sh && ./configure --prefix=/usr

make && make install
  1. 编译
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
cd /usr/local/php

tar -zxvf php-8.0.23.tar.gz

cd php-8.0.23/

./configure \
--prefix=/usr/local/php \
--with-config-file-path=/usr/local/php \
--enable-mbstring \
--with-openssl \
--enable-ftp \
--with-gd \
--with-jpeg-dir=/usr \
--with-png-dir=/usr \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-pear \
--enable-sockets \
--with-freetype-dir=/usr \
--with-zlib \
--with-libxml-dir=/usr \
--with-xmlrpc \
--enable-zip \
--enable-fpm \
--enable-xml \
--enable-sockets \
--with-gd \
--with-zlib \
--with-iconv \
--enable-zip \
--with-freetype-dir=/usr/lib/ \
--enable-soap \
--enable-pcntl \
--enable-cli \
--with-curl
  1. 安装
1
make && make install
  1. 使用默认的配置文件
1
2
3
4
5
6
7
8
9
cp php.ini-production /etc/php.ini

cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

chmod +x /etc/init.d/php-fpm
  1. 增加用户和组
1
2
3
4
5
6
7
8
9
10
11
adduser www             

passwd www

groupadd www



usermod -G www www

gpasswd -a www www
  1. 配置用户和用户组
1
vim /usr/local/php/etc/php-fpm.d/www.conf

修改如下内容

image-20220915213306963

  1. 添加环境变量(可选)
1
vim /etc/profile

将光标移动到最后一行,添加如下内容(按 i 进入输入模式,输入完成之后按 esc 进入命令模式,输入 :wq 回车即可保存并退出):export PATH=$PATH:/usr/local/php/bin

1
source /etc/profile
  1. 验证
1
php --version

至此,恭喜您 LNMP 环境搭建完毕!接下来愉快的敲代码吧😘😘

版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-ND 4.0 许可协议。转载请注明来源 披萨盒的赛博日志


avatar

披萨盒

反正身体这么好,今天继续笑下去吧

个人主页