1.nginx的安装及使用
Nginx: www.nginx.org nginx官网,需要不同版本的可进行选择下载。
在使用nginx,mysql,php时,要优先关闭防火墙和高级权限。
systemctl stop firewalld
setenforce 0
yum -y install gcc make zlib-devel pcre pcre-devel openssl-devel #编译环境的准备
1.安装rpm 包
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-
0.el7.ngx.noarch.rpm
2.安装nginx
yum install -y nginx
3.启动Nginx
systemctl start nginx.service
4.安装后在配置文件在/etc/nginx/conf.d下
vim /etc/nginx/conf.d/s1.conf
server {
listen 82; #端口号随意
server_name localhost;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/rehtml/cyr; # 此处存放前端页面 前端代码路径
index index.html index.htm;
}
}
5.上传前端包到/usr/share/nginx/rehtml/
6.解压文件包
下载unzip : yum -y install unzip
unzip XXXXX.zip
7.访问页面
打开浏览器访问ip:端口
例如:
10.31.154.190:82
确认nginx是否安装成功:systemctl status nginx
2.MySQL的安装及使用
MySQL: http://www.mysql.com MySQL官网,需要不同版本的可进行选择下载。
1.安装rpm 包
wget https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm
2.安装MySQL
yum install -y mysql-community-server
3.启动MySQL
systemctl start mysqld.service
4.登录MySQL
MySql服务器初始化会创建 'root@localhost’的一个超级用户账号。设置超级用户的密码并将其存储在错误日志文件中
grep 'temporary password' /var/log/mysqld.log
使用临时密码登录
mysql -uroot -p '临时密码'
5.重置密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '12346';
如果密码设置的太简单可能会报错
解决方法:
set global validate_password_length=0;
set global validate_password_policy=0;
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456';
6.开启远程连接
进入mysql库执行命令
use mysql
select host ,user from user;
把root用户的host改为%
update user set host = "%" where user = "root";
刷新权限
flush privileges;
确认MySQL是否安装成功:systemctl status mysqld
远程连接数据库navicat:Navicat 中国 | 支持 MySQL、Redis、MariaDB、MongoDB、SQL Server、SQLite、Oracle 和 PostgreSQL 的数据库管理https://www.navicat.com.cn/
3.php的安装及使用
wget https://cn.wordpress.org/wordpress-5.6.2-zh_CN.tar.gz
tar -xf latest-zh_CN.tar.gz
1.导入源
yum -y install epel-release
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install php72* --skip-broken
2.修改php-fpm配置
vim /etc/php-fpm.d/www.conf
把user = apache和group = apache 改成
3.启动php-fpm
创建www用户:useradd www
启动php-fpm:systemctl restart php-fpm
检查是否启动:systemctl status php-fpm
4.安装nginx,安装方法按前面介绍。
5.测试php-fpm连接
创建/opt/www 并vim /opt/www/test_php.php
<?php
phpinfo();
?>
保存并退出
6.安装后在配置文件下进行
vim /etc/nginx/conf.d/s2.conf
server {
listen 83;
server_name localhost;
location / {
root /opt/www;
index index.php index.html;
}
location ~ \.php$ {
root /opt/www;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
}
}
确认MySQL是否安装成功:lsof -i:9000
重启nginx访问10.31.154.190:83/test_php.php
如图所示即为连接成功。
1.下载博客
地址:https://cn.wordpress.org/themes/
下载:wget https://cn.wordpress.org/wordpress-5.6.2-zh_CN.tar.gz
解压:tar -xf 文件名
将解压后的文件移动到/opt/下:mv wordpress/ /opt/
2.配置文件
切换到博客的目录下:cd /opt/wordpress/
复制 wp-config-sample.php 为wp-config.php:cp wp-config-sample.php wp-config.php
修改:
define( 'DB_NAME', 'database_name_here 改为 wordpress' );
define( 'DB_USER', 'username_here 改为 root' );
define( 'DB_PASSWORD', 'password_here 改为 123456' );
define( 'DB_HOST', 'localhost 改为 地址' );
3.创建数据库
create database 数据库名称;
访问博客页面:http://10.31.154.190:83/
注册并登录后,如图即为设置成功。