mysql root用户改密码。基于LNMP架构搭建网站。
假如MySQL root用户密码忘记,可以通过修改配置文件来登录MySQL,修改密码。修改配置文件,在 /etc/my.cnf 中,
https://i-blog.csdnimg.cn/blog_migrate/e3c48b35072a7492500a2b5417db9e27.png
https://i-blog.csdnimg.cn/blog_migrate/d0ad963e5c8eca785ab4d3740f23b3fc.png
https://i-blog.csdnimg.cn/blog_migrate/f5619102ea425c6a3223a3aa2ca2deac.png
生存并退出,重启MySQL,
systemctl restart mysql
d https://i-blog.csdnimg.cn/blog_migrate/2c00c18d36165a888ca2c6f67266d26a.png
此时进入MySQL,就已经不须要密码了,直接输入MySQL就会进入。
mysql
https://i-blog.csdnimg.cn/blog_migrate/b6b3d73faaca7ea7d85c7209c75d7352.png
更改密码
update mysql
.user set authentication_string=password('123456') where user'root' and host'localhost'; https://i-blog.csdnimg.cn/blog_migrate/94577948d4a458c8bb1a95e23855b217.png
革新权限
flush privileges; https://i-blog.csdnimg.cn/blog_migrate/b970fc2e1c6741a87a862bd8831b34c8.png
修改完之后要及时删除配置项
vim /etc/my.cnf
https://i-blog.csdnimg.cn/blog_migrate/7db9984d74ef8c68dd4e9299be2ab99f.png
更改完文件之后,要重启MySQL。
https://i-blog.csdnimg.cn/blog_migrate/cb74ab8924613600fee939d2c88ab2e4.png
此时用新密码登录MySQL root用户。
mysql
-uroot -p123456 https://i-blog.csdnimg.cn/blog_migrate/0eb9c004c88700978d8cd454fa0b3c19.png
https://i-blog.csdnimg.cn/blog_migrate/a9ec066dc963d7a7c4fb5418f1cd7398.png
yum 安装nginx
yum install nginx
https://i-blog.csdnimg.cn/blog_migrate/21101afd531a58f665c071140828abfc.png
启动nginx
nginx
用命令查看80端口
ss -nplt | grep 80
发现nginx
已经启动。
https://i-blog.csdnimg.cn/blog_migrate/ca766e382c22bcd9d8071506cf6f25d9.png
摆设php
进入rpm软件包仓库网站。
https://rpms.remirepo.net/ 是一个 RPM 软件包仓库,它提供大量的 PHP 和相干扩展包
Remi's RPM repository (remirepo.net)https://i-blog.csdnimg.cn/blog_migrate/003a2ce7eb50c2e24a8c624c260c5930.pnghttps://rpms.remirepo.net/
https://i-blog.csdnimg.cn/blog_migrate/ba97890e532f40c608e65df3a4e7bdbf.png
右键-复制链接。
https://i-blog.csdnimg.cn/blog_migrate/01a1097669257b7bb0fbf8123ede0ea8.png
在终端中用yum举行下载。
https://i-blog.csdnimg.cn/blog_migrate/042ac3091d89c3f0cdde558377822dd9.png
https://i-blog.csdnimg.cn/blog_migrate/41ff79f22d15d34e806b47947eb6e79f.png
yum -y install php74-php-fpm yum -y install php74-php-xsl php74-php php74-php-cli php74-php-devel php74-php-gd php74-php-pdo php74-php-mysql
php74-php-fpm https://i-blog.csdnimg.cn/blog_migrate/3f9c29a6949d9870e9d23124c03a4a73.png
https://i-blog.csdnimg.cn/blog_migrate/0def3313e0229eed878bfec8006508a7.png
启动php
systemctl restart php74-php-fpm https://i-blog.csdnimg.cn/blog_migrate/e3b3e8ca96ed372d385a7c33abd4724d.png
查抄是否启动乐成
ss -nplt | grep 9000 https://i-blog.csdnimg.cn/blog_migrate/a3f9f249bfc73a8970f2a48ec50cbae2.png
nginx
关联php
将nginx
文件备份,文件在 /etc/nginx
/nginx
.conf。
cp /etc/nginx
/nginx
.conf /etc/nginx
/nginx
.conf.bak https://i-blog.csdnimg.cn/blog_migrate/a710106982e9665c91cdd5760ae13c67.png
对nginx
配置文件举行编辑
vim /etc/nginx
/nginx
.conf 可以用 加个+42来指定文件开启时光标在第42行。
vim +42 /etc/nginx
/nginx
.conf https://i-blog.csdnimg.cn/blog_migrate/02f4fbe13fe79b0bd4ed00564de65a9c.png
https://i-blog.csdnimg.cn/blog_migrate/18ce4c1217cbe08c9749bff87af9ae07.png
在第42行下举行编辑,添加以下代码
index index.php index.html index.htm; location ~ \.php$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/share/nginx
/html/$fastcgi_script_name; } https://i-blog.csdnimg.cn/blog_migrate/8e6d43475196e66ccb4dccca1990322b.png
可以用nginx
-t 来检测是否有语法问题
nginx
-t https://i-blog.csdnimg.cn/blog_migrate/07be86df51702c04841d820e1a68fdbe.png
配置文件语法没有问题后,重启nginx
nginx
-s reload https://i-blog.csdnimg.cn/blog_migrate/6eb7928e3cb48f14886c7422c13afc6b.png
编写一个探测文件来查看nginx
和php是否毗连乐成
vim index.php <?php
phpinfo();
?> https://i-blog.csdnimg.cn/blog_migrate/c834e9cabcb6c785578db6757da7560d.png
用欣赏器访问ip地址,显示下面界面,就体现毗连乐成。
https://i-blog.csdnimg.cn/blog_migrate/c9b2fa2b13caf77d033eb41f436b960a.png
接下来就是让项目上线
将压缩包从本地上传到虚拟机中。解压
tar -zxvf wordpress-6.2.2-zh_CN.tar.gz
https://i-blog.csdnimg.cn/blog_migrate/3905a5aa857b2f76a1ef0da1d19ab87f.png
将解压后的目录下的文件和目录拷贝到 /usr/share/nginx
/html/ 目录下
cp -r /root/wordpress/* /usr/share/nginx
/html/ 删除之前的测试文件index.php。
rm -rf index.php https://i-blog.csdnimg.cn/blog_migrate/4ee8ef36bcdd9141aa388ea32dd36c92.png
https://i-blog.csdnimg.cn/blog_migrate/1b2b4f2dc08af4f53ed3f187f8d2b263.png
进入mysql
中创建数据库
create database wordpress; https://i-blog.csdnimg.cn/blog_migrate/9008ec1e1484a8dfb7dc891e47038143.png
打开欣赏器访问ip地址。
https://i-blog.csdnimg.cn/blog_migrate/a82c93f0e52af11d7118d7275dc11528.png
这里输入刚刚创建的数据库名wordpress,用户名root 。
https://i-blog.csdnimg.cn/blog_migrate/c1a5f1afce432135b0d5e503742a5a18.png
点击提交后,看到无法写入wp-config.php文件,须要我们手动创建并配置。
https://i-blog.csdnimg.cn/blog_migrate/82cc01bcfad273843d567f54b8328457.png
须要创建在 /usr/share/nginx
/html 目录下,
vim wp-config.php 将以下代码添加到文件中。
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the installation.
* You don't have to use the web site, you can copy this file to "wp-config.php"
* and fill in the values.
*
* This file contains the following configurations:
*
* * Database settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* @link https://wordpress.org/documentation/article/editing-wp-config-php/
*
* @package WordPress
*/
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordpress' );
/** Database username */
define( 'DB_USER', 'root' );
/** Database password */
define( 'DB_PASSWORD', '123' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8mb4' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
/**#@+
* Authentication unique keys and salts.
*
* Change these to different unique phrases! You can generate these using
* the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
*
* You can change these at any point in time to invalidate all existing cookies.
* This will force all users to have to log in again.
*
* @since 2.6.0
*/
define( 'AUTH_KEY', '^ES>dqfaA%hn5{P[VB!I d3 gezm;J`agkJ~m<E58/*a<(q:D, O)7rIjQGkd|1@' );
define( 'SECURE_AUTH_KEY','kqD}9<+<?Mc3d+4N+v71Zq+OS=|m-@l(J|lSMKi_x5+Wi-!b|uvDs%qT!`MDJ[*=' );
define( 'LOGGED_IN_KEY', 'I.$A3BAHf<grZ.;q3]c+D{3%cS#&L!SDo%NIi_PXjvq3Bivt*Ue+h&TX-{Wj9%}?' );
define( 'NONCE_KEY', 'rJW2hf(L|8T(!.ek^GFLCDr0.#K3_mYnP3HO@:s6Q(%:tAUwYCE_[~M%f$)?[Ck%' );
define( 'AUTH_SALT', 'wH/OAd`MEb9[gzu3PT_tVv3m/I%p*@eo*CVe`^KyH5_:{`WdN2%Z-xns0.E_+W#g' );
define( 'SECURE_AUTH_SALT', 'q~ej>{5{%3(59J&hOP;Z{Gn-NLbsIaLvZRniA=jkhCNj/&|3ssR*(r%R,xq==1NW' );
define( 'LOGGED_IN_SALT', '<t*,_SprcP>6EG=wSXIFm]93SK$A8Vc-B0E>*d2lg[<CE#X}{m:nvtE4%5c#kip]' );
define( 'NONCE_SALT', 'QP9To>rx:oA,X5D%2cV^Ni,Zr7S_BwUdAvEj)@scV-To9Hv%?U$O=v*]1Z[+|Sr!' );
/**#@-*/
/**
* WordPress database table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* @link https://wordpress.org/documentation/article/debugging-in-wordpress/
*/
define( 'WP_DEBUG', false );
/* Add any custom values between this line and the "stop editing" line. */
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';
https://i-blog.csdnimg.cn/blog_migrate/eae3eaca42df1b42149f46df436a4af2.png
然后点击运行安装程序。会进入这个界面。填入信息。
https://i-blog.csdnimg.cn/blog_migrate/472b6b4eac260422f5b738032487c43d.png
https://i-blog.csdnimg.cn/blog_migrate/68fa8ce3885db71ec1795c4281efc79e.png
点击安装WordPress。安装乐成。点击登录。
https://i-blog.csdnimg.cn/blog_migrate/bdfd300b17b02a7fc5f8c6b7839516ff.png
输入用户名和密码,登录。
https://i-blog.csdnimg.cn/blog_migrate/946030f51bd68c689b1243e1115c3701.png
显示这个界面,乐成了。
https://i-blog.csdnimg.cn/blog_migrate/ceeaf11b5438a94afe81bc483a3aba19.png
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
页:
[1]