手把手教你搭建网站LNMP平台(源码搭建centos7.6+mysql5.7+php7.3+nginx1.18)

news/2024/5/20 7:22:30/文章来源:https://blog.csdn.net/qq_34070818/article/details/112215924

准备环境

[root@lnmp src]# ll
总用量 169456
-rw-r--r--  1 root root 83709983 11月 23 00:27 boost_1_59_0.tar.gz
-rw-r--r--  1 root root 51822632 11月 23 00:22 mysql-5.7.21.tar.gz
-rw-r--r--  1 root root  1039530 12月 16 10:32 nginx-1.18.0.tar.gz
-rw-r--r--  1 root root 19675794 10月 27 19:30 php-7.3.24.tar.gz
-rw-r--r--  1 root root 17262366 1月   5 16:43 wordpress-5.6-zh_CN.zip

部署mysql5.7

##创建数据目录
[root@lnmp src]# mkdir -p /data/mysql##创建mysql用户
[root@lnmp src]# useradd -s /sbin/nologin mysql
[root@lnmp src]# chown -R mysql. /data/mysql/##安装boost库
[root@lnmp src]# tar xf boost_1_59_0.tar.gz 
[root@lnmp src]# ls
boost_1_59_0         debug    mysql-5.7.21.tar.gz  php-7.3.24.tar.gz
boost_1_59_0.tar.gz  kernels  nginx-1.18.0.tar.gz  wordpress-5.6-zh_CN.zip
[root@lnmp src]# mv boost_1_59_0 /usr/local/boost
###安装依赖
[root@lnmp src]# yum install gcc ncurses-devel libaio bison gcc-c++ git cmake ncurses-devel openssl openssl-devel -y##解压mysql源码包
[root@lnmp src]# tar xf mysql-5.7.21.tar.gz 
[root@lnmp src]# cd mysql-5.7.21/##预编译
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql57 \
-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \
-DMYSQL_DATADIR=/data/mysql \
-DSYSCONFDIR=/usr/local/mysql57 \
-DMYSQL_USER=mysql \
-DMYSQL_TCP_PORT=3306 \
-DWITH_XTRADB_STORAGE_ENGINE=1 \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DWITH_READLINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=1 \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DEXTRA_CHARSETS=all \
-DWITH_BIG_TABLES=1 \
-DWITH_DEBUG=0 \
-DENABLE_DTRACE=0 \
-DDOWNLOAD_BOOST=1 \
-DWITH_BOOST=/usr/local/boost##编译安装
[root@lnmp mysql-5.7.21]# make && make install##创建启动脚本
[root@lnmp mysql-5.7.21]#  cp support-files/mysql.server /etc/init.d/mysql
[root@lnmp mysql-5.7.21]# chmod +x /etc/init.d/mysql##创建配置文件
[root@lnmp mysql-5.7.21]# vim /usr/local/mysql57/my.cnf
[mysqld]
basedir=/usr/local/mysql57/
datadir=/data/mysql/
port=3306
pid-file=/data/mysql/mysql.pid
socket=/data/mysql/mysql.sock
[mysqld_safe]
log-error=/data/mysql/mysql.log##初始化
[root@lnmp mysql-5.7.21]# /usr/local/mysql57/bin/mysqld --initialize --user=mysql --datadir=/data/mysql --basedir=/usr/local/mysql572021-01-06T03:42:35.663282Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2021-01-06T03:42:35.843157Z 0 [Warning] InnoDB: New log files created, LSN=45790
2021-01-06T03:42:35.871667Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.
2021-01-06T03:42:35.940910Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 374bd87b-4fd1-11eb-a02b-000c2985902f.
2021-01-06T03:42:35.942940Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.
2021-01-06T03:42:35.944037Z 1 [Note] A temporary password is generated for root@localhost: k9!tnXws9sKh##启动mysql
[root@lnmp mysql-5.7.21]# /etc/init.d/mysql start
Starting MySQL.Logging to '/data/mysql/mysql.log'.SUCCESS! ##查看mysql进程
[root@lnmp mysql-5.7.21]# ps -ef |grep mysql
root      64137      1  0 11:43 pts/1    00:00:00 /bin/sh /usr/local/mysql57//bin/mysqld_safe --datadir=/data/mysql/ --pid-file=/data/mysql/mysql.pid
mysql     64365  64137  0 11:43 pts/1    00:00:03 /usr/local/mysql57/bin/mysqld --basedir=/usr/local/mysql57/ --datadir=/data/mysql --plugin-dir=/usr/local/mysql57//lib/plugin --user=mysql --log-error=/data/mysql/mysql.log --pid-file=/data/mysql/mysql.pid --socket=/data/mysql/mysql.sock --port=3306
root      67033   7546  0 13:23 pts/1    00:00:00 grep --color=auto mysql##查看mysql端口
[root@lnmp mysql-5.7.21]# netstat -nltp |grep mysql
tcp6       0      0 :::3306                 :::*                    LISTEN      64365/mysqld  ##登录mysql修改密码
[root@lnmp mysql-5.7.21]# /usr/local/mysql57/bin/mysql -uroot -p
Enter password:k9!tnXws9sKh
mysql> alter user user() identified by "123456";
Query OK, 0 rows affected (0.00 sec)###
##创建wordpress数据库
mysql> create database wordpress charset utf8;
Query OK, 1 row affected (0.00 sec)##授权wordpress用户可以访问wordpress数据库
mysql> grant all on wordpress.* to "wordpress"@localhost identified by "123456";
Query OK, 0 rows affected, 1 warning (0.00 sec)##刷新权限
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

安装nginx1.18

##解压nginx
[root@lnmp src]# tar xf nginx-1.18.0.tar.gz 
[root@lnmp src]# cd nginx-1.18.0/##预编译
[root@lnmp nginx-1.18.0]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module##编译安装
[root@lnmp nginx-1.18.0]# make && make install添加nginx用户
[root@lnmp nginx-1.18.0]# useradd -s /sbin/nologin nginx##修改nginx用户
[root@lnmp nginx-1.18.0]# vim /usr/local/nginx/conf/nginx.conf
user  nginx;##启动nginx
[root@lnmp nginx-1.18.0]# /usr/local/nginx/sbin/nginx
[root@lnmp nginx-1.18.0]# ps -ef |grep nginx
root      67058      1  0 12:00 ?        00:00:00 nginx: master process /usr/local/nginx/sbin/nginx
nginx     67059  67058  0 12:00 ?        00:00:00 nginx: worker process
root      67075   7546  0 12:02 pts/1    00:00:00 grep --color=auto nginx

安装PHP7.3

##解压php
[root@lnmp src]# tar xf php-7.3.24.tar.gz
[root@lnmp src]# cd php-7.3.24/##安装依赖
[root@lnmp php-7.3.24]# yum -y install gd curl curl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel -y##预编译
[root@lnmp php-7.3.24]# ./configure --prefix=/usr/local/php \--enable-fpm \--with-fpm-user=nginx \--with-fpm-group=nginx \--enable-debug \--with-gd \--with-jpeg-dir \--with-png-dir \--with-freetype-dir \--enable-mbstring \--with-curl \--with-mysqli=mysqlnd \--with-mysql-sock=/data/mysql/mysql.sock \--with-pdo-mysql=mysqlnd \--with-config-file-path=/usr/local/php/etc \--with-zlib-dir--with-openssl
##预编译结果
...
creating libtool
appending configuration tag "CXX" to libtoolGenerating files
configure: creating ./config.status
creating main/internal_functions.c
creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+Thank you for using PHP.config.status: creating php7.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/www.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.service
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating sapi/phpdbg/phpdbg.1
config.status: creating sapi/cgi/php-cgi.1
config.status: creating ext/phar/phar.1
config.status: creating ext/phar/phar.phar.1
config.status: creating main/php_config.h
config.status: executing default commands##编译安装
[root@lnmp php-7.3.24]# make && make install##创建配置文件
[root@lnmp php-7.3.24]# cp php.ini-development /usr/local/php/etc/php.ini
[root@lnmp php-7.3.24]# cp /usr/local/php/etc/php-fpm.conf.default  /usr/local/php/etc/php-fpm.conf##创建启动脚本
[root@lnmp php-7.3.24]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@lnmp php-7.3.24]# chmod +x /etc/init.d/php-fpm##如启动报错可执行下操作
###
[root@lnmp php-7.3.24]# /etc/init.d/php-fpm start
Starting php-fpm [06-Jan-2021 12:41:11] WARNING: Nothing matches the include pattern '/usr/local/php/etc/php-fpm.d/*.conf' from /usr/local/php/etc/php-fpm.conf at line 143.
[06-Jan-2021 12:41:11] ERROR: No pool defined. at least one pool section must be specified in config file
[06-Jan-2021 12:41:11] ERROR: failed to post process the configuration
[06-Jan-2021 12:41:11] ERROR: FPM initialization failedfailed##执行操作
[root@lnmp php-fpm.d]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf##启动php-fpm
[root@lnmp php-fpm.d]# /etc/init.d/php-fpm start
Starting php-fpm  done##查看进程
[root@lnmp php-fpm.d]# ps -ef |grep php
root      66722      1  0 12:41 ?        00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf)
nginx     66723  66722  0 12:41 ?        00:00:00 php-fpm: pool www
nginx     66724  66722  0 12:41 ?        00:00:00 php-fpm: pool www
root      66726   7546  0 12:45 pts/1    00:00:00 grep --color=auto php##查看端口
[root@lnmp php-fpm.d]# netstat -nltp |grep php
tcp        0      0 127.0.0.1:9000          0.0.0.0:*               LISTEN      66722/php-fpm: mast

上传wordpress网站程序

##解压发布目录
[root@lnmp src]# unzip wordpress-5.6-zh_CN.zip -d /usr/local/nginx/html/##设置wordpress目录权限
[root@lnmp src]# chown -R nginx. /usr/local/nginx/html/wordpress/##创建虚拟主机配置文件目录
[root@lnmp src]# mkdir -p /usr/local/nginx/conf/vhost##创建wordpress虚拟机
#指定应用虚拟主机目录(主配置文件http指令)
[root@lnmp src]# vim /usr/local/nginx/conf/nginx.conf
include vhost/*.conf;##创建主机配置文件
[root@lnmp nginx-1.18.0]# vim /usr/local/nginx/conf/vhost/blog.wscyun.com.conf
server {listen    80;server_name blog.wscyun.com;charset utf8;
#       access_log logs/wordpress.access.log main;location / {root html/wordpress;index index.php index.html index.htm;}#reeor_page 404      /404.html;error_page 500 502 503 504 /50x.html;location = /50x.html {root html;}location ~ \.php$ {root    html/wordpress;fastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;include fastcgi_params;}}

安装wordpress

##访问blog.wscyun.com

在这里插入图片描述

##输入准备好的数据库及密码

在这里插入图片描述

##输入网站信息

在这里插入图片描述

##开始安装

在这里插入图片描述

##登录
在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

##查看网站

在这里插入图片描述

##上传wordpress主题

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_900753.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

webstorm入门 网站收集

1.点击打开链接 2.点击打开链接 3.点击打开链接 4.点击打开链接 5.点击打开链接 6.点击打开链接 7. 点击打开链接

基于JSP的班级信息网站

技术:Java、JSP等 摘要:班级信息网站是为了合理利用网络资源、提供班级学习与交流、有效管理班级事务的网络平台。本网站基于B/S模式,在MYECLIPSE集成开发环境下采用JSP语言开发完成。本网站由用户模块、在线论坛、班级相册、留言簿模块与管理…

Java、JSP个人信息门户网站

技术:Java、JSP等 摘要:首先,技术可行性。本系统仅需要一台装有Office软件的计算机即可,对机器本身没有太高的要求,一般当前学校或个人电脑完全可满足要求。对于软件技术要求,现在的程序设计语言已非常成熟…

C1-3网站界面开发

一、编程解决问题的流程 二、HTML标签 三、CSS标签 四、JavaScript 自测 1、HTML5为了使img元素可拖放,需要增加什么属性? 在img标签内加入draggable”true” 2、HTML5哪一个input类型可以选择一个无时区的日期选择器? type”date” 3、CSS盒子模型中的Marg…

HTML实现简易旅行网站主页

我在顶着上课的厌恶之情,终于认真的听了网页课,以下是我做的第一个简易网页,希望这个过程能被我记录下来。 下面是这个小网页的成品: 过程如下: 1: 准备工具:一个文件夹,vscode(或者…

Linux - 搭建个人网站

购买阿里云服务器 学生版有两种: 学生专享-限24周岁以下/阿里云云服务器ECS/专业运维学生专享-限24周岁以下/阿里云轻量服务器/简单易操作。 为啥选择轻量应用服务器 标题写明专业运维和简单易操作,既然是初次搭建网站,选择容易上手的服务…

Node.js + Express 构建网站预备知识

Node.js Express 构建网站预备知识 目录 前言新建express项目并自定义路由规则如何提取页面中的公共部分?如何提交表单并接收参数? GET 方式POST 方式 如何字符串加密?如何使用session?如何使用cookies?如何清除session和cookies?写在之后 前言 前面经过五篇Node.js的学…

HTTP 网站升级到 HTTPS 。

为了升级到 HTTP/2 协议,必须先启用 HTTPS。如果你不了解 HTTPS 协议(学名 TLS 协议),可以参考我以前的文章。 《HTTPS 协议概述》 《图解 HTTPS 协议》 《HTTPS 协议的七个误解》 《HTTPS 协议的延迟有多大?》 本文介…

网站结构设计规划书

昨天,一位mm找我,让我帮她看看她做的网站!拿过来一看,汗!果然是新手,所有的东西都放在了一起,没有任何分类,想象自己以前也是如此,而且加上这个妹妹还是我们的老乡&#…

分享一个网站,里面有一些关于编程的题,上去练习下不错

http://218.4.165.132:8080/oj/ 先注册一个账号,随便填填就行了,要记住账号和密码哈~

网站常用广告代码大全

网站常用广告代码大全 <li class"list-group-item"> <center><iframe width"280" scrolling"no" height"25" frameborder"0" allowtransparency"true" src"http://i.tianqi.com/index.php?c…

nginx(1)之安装、默认网站、目录权限、日志管理

什么是nginx Nginx (engine x) 是一个高性能的HTTP和反向代理服务&#xff0c;也是一个IMAP/POP3/SMTP服务。Nginx是由伊戈尔赛索耶夫为俄罗斯访问量第二的Rambler.ru站点&#xff08;俄文&#xff1a;Рамблер&#xff09;开发的&#xff0c;第一个公开版本0.1.0发布于2…

Chrome 高级技巧:使用 “\ + 关键字” 快速打开指定网站

你访问一个网站需要按几次键盘&#xff1f;如果不算回车键的话&#xff0c;即使最短的域名也要按四次吧&#xff0c;比如G.CN。但是在Chrome中&#xff0c;如果你经常访问G.cn的话&#xff0c;那么你只需要输入一个关键字&#xff08;比如G&#xff09;&#xff0c;就会自动匹配…

There is a chrome web app for that:探测与网站匹配的扩展

iPhone的广告词“There is an app for that”已经成为一句流行语&#xff0c;而Chrome工程师Mihai Parparita携“Theres a web app for that”这枚Chrome扩展将这句话带入了Chrome网页应用商店&#xff0c;当然我们需要将广告词改成&#xff1a;There is a Chrome web app for …

让钟爱的网站变成Chrome应用

在Chrome上&#xff0c;每次创建新标签页&#xff0c;都会打开Chrome默认的起始页。页面包括两个分页&#xff0c;一个是“最常访问的”页面&#xff0c;上面排列了八个用户最常访问的网址的缩略图&#xff08;图像会不断更新&#xff09;&#xff0c;另一部分展现的是用户从Ch…

用 Chrome 扩展将下载网站中的真实下载链接醒目显示

乱花渐欲迷人眼的各大下载站们和软件推广商们&#xff0c;为了骗取软件下载量经常将自己的软件广告图伪装成下载按钮。 当然&#xff0c;对于Geek来说&#xff0c;要么不去下载站&#xff0c;要么就很熟悉下载站的“潜规则”了&#xff0c;下载软件时绝对不会下错。但是对于刚…

避免在 Chrome 上输错网站登录密码的办法

很多人会将自己的密码设置成非常难以破解的高强度密码&#xff0c;但是高强度密码又很有可能输错&#xff0c;尤其是像支付宝这样的网站&#xff0c;如果连续5次输错密码的话&#xff0c;就意味着账户将在接下来的3小时都无法登录&#xff0c;所以避免输错密码也同样非常重要。…

企业网站建设方案书

一、网站建设目标 1.1背景分析 现在网络的发展已呈现商业化、全民化、全球化的趋势。目前&#xff0c;几乎世界上所有的公司都在利用网络传递商业信息&#xff0c;进行商业活动&#xff0c;从宣传企业、发布广告、招聘雇员、传递商业文件乃至拓展市场、网上销售等&#xff0c;…

LaTeX 学习网站资源汇总 (六篇博客总结)

GitHub资源&#xff1a;https://github.com/qinnian/LaTeX 微信公众号【孙钦念】&#xff1a;LaTeX 教程资源汇总&#xff08;推荐&#xff09; 一、写在前面 LaTeX作为⼀⻔⾮常受欢迎的排版语⾔&#xff0c;被⼴泛运⽤在各个⾏业&#xff0c;⽐如学术界、出版界。LaTeX 和 …

爬取哔哩哔哩等视频网站方法

爬取哔哩哔哩等视频网站方法 安装python安装you-get工具包 下载举例 安装python 具体安装方法&#xff0c;百度就可 安装you-get工具包 如下图打开cmd命令窗口&#xff0c;执行命令 pip install you-get下载举例 执行命令 you-get -o F:\test https://www.bilibili.com/v…