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

推荐订阅源

钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Troy Hunt's Blog
P
Proofpoint News Feed
V
Vulnerabilities – Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
K
Kaspersky official blog
Cyberwarzone
Cyberwarzone
T
Tor Project blog
Cisco Talos Blog
Cisco Talos Blog
S
Securelist
L
Lohrmann on Cybersecurity
Security Latest
Security Latest
T
Threatpost
H
Heimdal Security Blog
W
WeLiveSecurity
A
Arctic Wolf
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
GRAHAM CLULEY
IT之家
IT之家
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
TaoSecurity Blog
TaoSecurity Blog
A
About on SuperTechFans
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
N
News and Events Feed by Topic
Hacker News - Newest:
Hacker News - Newest: "LLM"
Last Week in AI
Last Week in AI
T
The Blog of Author Tim Ferriss
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Microsoft Azure Blog
Microsoft Azure Blog
Hugging Face - Blog
Hugging Face - Blog
Google DeepMind News
Google DeepMind News
量子位
Stack Overflow Blog
Stack Overflow Blog
Know Your Adversary
Know Your Adversary
B
Blog RSS Feed
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
AI
AI
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
Apple Machine Learning Research
Apple Machine Learning Research
GbyAI
GbyAI
Vercel News
Vercel News
C
Cyber Attacks, Cyber Crime and Cyber Security
Latest news
Latest news
D
Darknet – Hacking Tools, Hacker News & Cyber Security
大猫的无限游戏
大猫的无限游戏
Forbes - Security
Forbes - Security

披萨盒的赛博日志

谈谈工作了半年的感受 使用策略模式重构复杂业务分支 像 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

披萨盒

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

个人主页