时间:2023-08-12 10:42:02 | 来源:网站运营
时间:2023-08-12 10:42:02 来源:网站运营
腾讯云服务wordpress建站:vi /etc/yum.repos.d/nginx.repo
按 i 切换至编辑模式,写入以下内容。[nginx] name = nginx repo baseurl = https://nginx.org/packages/mainline/centos/7/$basearch/ gpgcheck = 0 enabled = 1
按 Esc,输入 :wq,保存文件并返回。yum install -y nginx
执行以下命令,打开 default.conf 文件。vim /etc/nginx/conf.d/default.conf
一直按d,删除文件中的所有内容,再按i 切换至编辑模式,编辑 default.conf 文件,将下面内容copy进去。server { listen 80; root /usr/share/nginx/html; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; # location / { index index.php index.html index.htm; } #error_page 404 /404.html; #redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } #pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ .php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }}
按 Esc,输入 :wq,保存文件并返回。systemctl start nginx
执行以下命令,设置 Nginx 为开机自启动。systemctl enable nginx
rpm -Uvh https://mirrors.cloud.tencent.com/epel/epel-release-latest-7.noarch.rpmrpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpmyum -y install mod_php72w.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-mysqlnd php72w-fpm.x86_64
执行以下命令,启动 PHP-FPM 服务。systemctl start php-fpm
执行以下命令,设置 PHP-FPM 服务为开机自启动。systemctl enable php-fpm
查看PHP是否安装好了输入php -v会展示如下版本内容[root@VM-0-14-centos ~]# php -vPHP 7.2.34 (cli) (built: Oct 1 2020 13:37:37) ( NTS )Copyright (c) 1997-2018 The PHP GroupZend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
cd /usr/lcoalwget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz tar -xvf mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz mv -v mysql-5.7.22-linux-glibc2.12-x86_64 /usr/lcoal/mysqlmkdir data
增加MySQL用户groupadd mysqluseradd -r -g mysql mysqlchown -R mysql.mysql /usr/local/mysql
初始化MySQLyum -y install numactlyum search libaioyum install libaio/usr/local/mysql/bin/mysqld --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data --initialize
编辑配置文件 /etc/my.cnf vim /etc/my.cnf
将文件替换成下面内容[mysqld]datadir=/usr/local/mysql/databasedir=/usr/local/mysqlsocket=/tmp/mysql.sockuser=mysqlport=3306character-set-server=utf8# 取消密码验证skip-grant-tables# Disabling symbolic-links is recommended to prevent assorted security riskssymbolic-links=0# skip-grant-tables[mysqld_safe]log-error=/var/log/mysqld.logpid-file=/var/run/mysqld/mysqld.pid
MySQL加入到服务并开机启动、最后启动cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqlchkconfig mysql onservice mysql start
增加MySQL配置vim /etc/profile
最后一行增加export PATH=$PATH:/usr/local/mysql/bin
再次执行source /etc/profile
执行下面命令、输入下面命令直接回车mysql -u root -p
MySQL数据库设置密码最好提前先建个数据库(wordpress)CREATE DATABASE IF NOT EXISTS wordpress DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci;Root密码设置update user set authentication_string=password('你的密码') where user='root';用户名 uwordpress 密码 abcd2021X123456 按自己需求修改CREATE USER 'uwordpress'@'localhost' IDENTIFIED BY 'abcd2021X123456';GRANT ALL PRIVILEGES ON wordpress.* TO 'uwordpress'@'localhost' IDENTIFIED BY 'abcd2021X123456';flush privileges;
如果你想远程连接update user set host='%' where user = 'root';flush privileges;
退出MySQLexit
目前为止所需环境已经安装好了。最好提前先建个数据库(wordpress)CREATE DATABASE IF NOT EXISTS wordpress DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci;用户名 uwordpress 密码 abcd2021X123456 按自己需求修改GRANT ALL PRIVILEGES ON wordpress.* TO 'uwordpress'@'localhost' IDENTIFIED BY 'abcd2021X123456';flush privileges;
进入操作目录cd /usr/share/nginx/html
下载WordPresswget https://cn.wordpress.org/latest-zh_CN.tar.gztar zxvf latest-zh_CN.tar.gzcd /usr/share/nginx/html/wordpresscp wp-config-sample.php wp-config.phpvim wp-config.php
编辑 wp-config.php // ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wordpress'); /** MySQL database username */ define('DB_USER', 'uwordpress'); /** MySQL database password */ define('DB_PASSWORD', 'abcd2021X123456'); /** MySQL hostname */ define('DB_HOST', 'localhost');
修改完成后,按 Esc,输入 :wq,保存文件返回。执行以下命令,重启 Nginx 服务。systemctl restart nginx
启动wordpress在浏览器地址栏输入 http://192.xxx.xxx.xx/wordpress 192.xxx.xxx.xx是你的外网域名,如下图中:
如果显示数据库连接错误,你需要将上面 wp-config.php 中 define('DB_HOST', 'localhost'); localhost 改成内外IP地址,内网IP在上图外网的下面哈。如果显示下图说明你已经成功了,开启你的wordpress之旅了哈。关键词:服务