more /var/log/messages(检查有无系统级错误信息)
dmesg (检查硬件设备是否有错误信息)
cat /proc/cpuinfo (检查 CPU 频率是否正常)
top (按 1 检测 CPU 核数是否正常,内存大小是否正常)
ifconfig(检查网卡设置是否正确)
ping www.baidu.com(检查网络是否正常)
systemctl stop firewalld
关闭selinux安全子系统 并设置参数
setenforce 0
可以使用getenforce检查是否关闭
vi /etc/selinux/config 修改第七行为permissive
新安装的虚拟机,当前需要先配置本地源才可以使用yum
创建一个挂载点 mkdir /opt/centos
mount -o loop /dev/sr0 /mnt/
cp -rfv /mnt/* /opt/centos
rm -rf /etc/yum.repos.d/*
vi /etc/yum.repos.d/local.repo
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
然后
yum clean all 清空原有yum缓存ls
yum makecache 建立元数据
echo ‘nameserver 114.114.114.114’ >> /etc/resolv.conf
配置网络源yum
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
yum -y update 升级软件包
基础开发环境
yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libtiff-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel fontconfig-devel zlib zlib-devel libevent-devel gcc gcc-c++ flex bison bzip2-devel libXpmlibXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc+±33 curl curl-devel
wget -O ./ https://nginx.org/packages/centos/7/x86_64/RPMS/nginx-1.20.1-1.el7.ngx.x86_64.rpm
rpm -ivh nginx-1.20.1-1.el7.ngx.x86_64.rpm
yum -y install nginx
systemctl start nginx
ps -ef | grep nginx
netstat -tunlp | grep 80
nginx 动态站点部署
wget https://dev.mysql.com/get/Downloads/MySQL-8.0/mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
tar -xf mysql-8.0.20-linux-glibc2.12-x86_64.tar.xz
进入目录 cd mysql-8.0.20-linux-glibc2.12-x86_64
vim /etc/profile
export PATH=$PATH:/root/mysql-8.0.20-linux-glibc2.12-x86_64/bin
然后source /etc/profile 才会生效
显示已经成功写入环境变量
groupadd mysql
useradd -r -g mysql mysql -s /sbin/nologin
mkdir -p /data/mysql8_data
chown -R mysql:mysql /data/mysql8_data
chmod -R 750 /data/mysql8_data
在/usr/local/etc/下写一个配置文件my.cnf
vi /usr/local/etc/my.cnf
[mysql]
default-character-set=utf8mb4
[client]
port = 3306
socket = /tmp/mysql.sock
[mysqld]
port = 3306
server-id = 3306
user = mysql
socket = /tmp/mysql.sock
basedir = /usr/local/mysql8
datadir = /data/mysql8_data/mysql
log-bin = /data/mysql8_data/mysql/mysql-bin
innodb_data_home_dir =/data/mysql8_data/mysql
innodb_log_group_home_dir =/data/mysql8_data/mysql
log-error =/data/mysql8_data/mysql/mysql.log
pid-file =/data/mysql8_data/mysql/mysql.pid
character-set-server=utf8mb4
lower_case_table_names=1
autocommit =1
skip-external-locking
key_buffer_size = 256M
max_allowed_packet = 1M
table_open_cache = 1024
sort_buffer_size = 4M
net_buffer_length = 8K
read_buffer_size = 4M
read_rnd_buffer_size = 512K
myisam_sort_buffer_size = 64M
thread_cache_size = 128
#query_cache_size = 128M
tmp_table_size = 128M
explicit_defaults_for_timestamp = true
max_connections = 500
max_connect_errors = 100
open_files_limit = 65535
binlog_format=mixed
binlog_expire_logs_seconds =864000
default_storage_engine = InnoDB
innodb_data_file_path = ibdata1:10M:autoextend
innodb_buffer_pool_size = 1024M
innodb_log_file_size = 256M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50
transaction-isolation=READ-COMMITTED
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 256M
sort_buffer_size = 4M
read_buffer = 2M
write_buffer = 2M
[mysqlhotcopy]
interactive-timeout
mysqld --defaults-file=/usr/local/etc/my.cnf --basedir=/usr/local/mysql8 --datadir=/data/mysql8_data/mysql --user=mysql --initialize-insecure
ls /data/mysql8_data/mysql
nohup mysqld_safe --defaults-file=/usr/local/etc/my.cnf &
netstat -tunlp | grep 3306
mysql -uroot 登录
ALTER USER ‘root’@‘localhost’ IDENTIFIED WITH mysql_native_password BY ‘123456’;
flush privileges;
成功登录
create user ‘root’@‘%’ ;
ALTER USER ‘root’@‘%’ IDENTIFIED WITH mysql_native_password BY ‘123456’;
GRANT ALL PRIVILEGES ON . TO ‘root’@‘%’;
刷新权限
flush privileges;
连接MySQL
php要配置第三方源
sudo yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum -y install yum-utils
sudo yum-config-manager --enable remi-php74
sudo yum update
sudo yum -y install php php-cli php-fpm php-mysqlnd php-zip php-devel php-gd php-mcrypt php-mbstring php-curl php-xml php-pear php-bcmath php-json
php -v
修改php,启动进程,权限问题
sed -i ‘/^user/c user = nginx’ /etc/php-fpm.d/www.conf
sed -i ‘/^group/c group = nginx’ /etc/php-fpm.d/www.conf
useradd -s /sbin/nologin nginx
systemctl start php-fpm
cat > info.php
测试
cd /etc/nginx/conf.d/ (注意千万不要写到nginx下,浏览器无法访问或者端口没有开启就想看是否是自己的路径写错了)
vi discuz.conf
server{
listen 10020;
server_name _;
###### #静态请求
root /discuz;
index index.php index.html;
###### #动态请求
location ~ \.php$ {
root /discuz;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}
}
systemctl restart nginx
netstat -tunlp | grep nginx
mkdir /discuz
cd /discuz
测试nginx加上php是否可以正常运行
vi hello.php
在宿主机浏览器中访问
成功访问运行
wget https://gitee.com/Discuz/DiscuzX/attach_files/1345207/download
unzip Discuz_X3.5_SC_UTF8_20230316.zip
mv /root/upload/* /discuz
然后在浏览器中输入虚拟机ip:10020 直接回车
进入安装界面发现用户www没有r权限 提权
chown -R www.www /discuz
如果第一步显示无法解析主机地址就是因为没有配置dns服务器地址(在其他配置无误的情况下)
echo 'nameserver 114.114.114.114
om/Discuz/DiscuzX/attach_files/1345207/download
unzip Discuz_X3.5_SC_UTF8_20230316.zip
mv /root/upload/* /discuz
然后在浏览器中输入虚拟机ip:10020 直接回车
进入安装界面发现用户www没有r权限 提权
chown -R www.www /discuz
如果第一步显示无法解析主机地址就是因为没有配置dns服务器地址(在其他配置无误的情况下)
[外链图片转存中…(img-sfXM2cVr-1705668122822)]
echo 'nameserver 114.114.114.114
nameserver 8.8.8.8’ >> /etc/resolv.conf