摘要
本篇文章搬自网站搭建 - lukeewin的博客
本章主要通过终端安装环境的方式来编译代码等
安装Nginx
首选初始化系统后,需要执行下面命令
yum update
安装下面依赖
yum -y install gcc gcc-c++ libstdc++-devel pcre pcre-devel zlib zlib-devel openssl openssl-devel
下载源码并解压
wget https://nginx.org/download/nginx-1.26.2.tar.gz
tar -zxvf nginx-1.26.2.tar.gz
如果你需要选择其它版本,可以访问下面网址
https://nginx.org/en/download.html
进入源码
cd nginx-1.26.2
执行配置
./configure --prefix=/usr/local/nginx/ --with-http_ssl_module --with-stream --with-threads --with-file-aio --with-poll_module --with-http_gzip_static_module --with-http_secure_link_module --with-http_slice_module
上面的参数中--prefix指定安装的位置
编译安装
make && make install
注册为系统服务,在下面路径中创建一个文件,并写入下面内容
vim /lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
启动nginx
systemctl start nginx
设置开机自启
systemctl enable nginx
查看是否启动成功
ps aux|grep nginx
开启防火墙端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
firewall-cmd --list-ports
安装MySQL
安装依赖
dnf install perl-devel perl-Error perl-JSON perl-Memoize perl-Sys-Hostname perl-Time-HiRes perl-English perl-Time-Local
dnf install perl-CPAN
cpan
install Time::localtime
exit
下载rpm压缩包
wget https://downloads.mysql.com/archives/get/p/23/file/mysql-8.0.32-1.el9.x86_64.rpm-bundle.tar
解压缩
tar -xvf mysql-8.0.32-1.el9.x86_64.rpm-bundle.tar
安装
rpm -ivh mysql-community-common-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-debuginfo-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-libs-debuginfo-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-client-plugins-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-client-plugins-debuginfo-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-libs-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-client-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-client-debuginfo-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-debugsource-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-devel-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-icu-data-files-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-server-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-server-debug-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-server-debug-debuginfo-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-server-debuginfo-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-test-8.0.32-1.el9.x86_64.rpm
rpm -ivh mysql-community-test-debuginfo-8.0.32-1.el9.x86_64.rpm
配置文件在/etc/my.cnf
启动MySQL
systemctl start mysqld
systemctl status mysqld
修改数据库密码
grep 'temporary password' /var/log/mysqld.log
临时设置一个密码
ALTER USER 'root'@'localhost' identified by '12345678Aa?';
flush privileges;
查看密码规则
show variables like 'validate_password%';
更改密码规则
set global validate_password.length=6;
set global validate_password.policy=0;
set global validate_password.mixed_case_count=0;
set global validate_password.special_char_count=0;
flush privileges;
更改密码
ALTER USER 'root'@'localhost' identified by 'new password';
flush privileges;
安装WP
安装WordPress
下载源码
wget https://cn.wordpress.org/latest-zh_CN.zip
解压源码
unzip latest-zh_CN.zip
修改nginx.conf
vim /usr/local/nginx/conf/nginx.conf
location / {
root /usr/local/src/wordpress/;
index index.html index.htm index.php;
}
location ~ .php$ {
root /usr/local/src/wordpress/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location ~ /.ht {
deny all;
}
重启nginx
/usr/local/nginx/sbin/nginx -s stop
systemctl start nginx
开放防火墙端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
创建数据库
create database wordpress;
访问你服务器的ip就可以进入安装向导
后台访问地址ip/wp-admin
域名解析
修改nginx.conf
vim /usr/local/nginx/conf/nginx.conf
修改前
server_name localhost;
修改后
server_name lukeewiner.top;
重启nginx
systemctl reload nginx
暂无评论内容