時間:2023-08-12 10:42:02 | 來源:網(wǎng)站運營
時間:2023-08-12 10:42:02 來源:網(wǎng)站運營
騰訊云服務(wù)wordpress建站:vi /etc/yum.repos.d/nginx.repo
按 i 切換至編輯模式,寫入以下內(nèi)容。[nginx] name = nginx repo baseurl = https://nginx.org/packages/mainline/centos/7/$basearch/ gpgcheck = 0 enabled = 1
按 Esc,輸入 :wq,保存文件并返回。yum install -y nginx
執(zhí)行以下命令,打開 default.conf 文件。vim /etc/nginx/conf.d/default.conf
一直按d,刪除文件中的所有內(nèi)容,再按i 切換至編輯模式,編輯 default.conf 文件,將下面內(nèi)容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
執(zhí)行以下命令,設(shè)置 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
執(zhí)行以下命令,啟動 PHP-FPM 服務(wù)。systemctl start php-fpm
執(zhí)行以下命令,設(shè)置 PHP-FPM 服務(wù)為開機自啟動。systemctl enable php-fpm
查看PHP是否安裝好了輸入php -v會展示如下版本內(nèi)容[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
將文件替換成下面內(nèi)容[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加入到服務(wù)并開機啟動、最后啟動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
再次執(zhí)行source /etc/profile
執(zhí)行下面命令、輸入下面命令直接回車mysql -u root -p
MySQL數(shù)據(jù)庫設(shè)置密碼最好提前先建個數(shù)據(jù)庫(wordpress)CREATE DATABASE IF NOT EXISTS wordpress DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci;Root密碼設(shè)置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;
如果你想遠(yuǎn)程連接update user set host='%' where user = 'root';flush privileges;
退出MySQLexit
目前為止所需環(huán)境已經(jīng)安裝好了。最好提前先建個數(shù)據(jù)庫(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,保存文件返回。執(zhí)行以下命令,重啟 Nginx 服務(wù)。systemctl restart nginx
啟動wordpress在瀏覽器地址欄輸入 http://192.xxx.xxx.xx/wordpress 192.xxx.xxx.xx是你的外網(wǎng)域名,如下圖中:
如果顯示數(shù)據(jù)庫連接錯誤,你需要將上面 wp-config.php 中 define('DB_HOST', 'localhost'); localhost 改成內(nèi)外IP地址,內(nèi)網(wǎng)IP在上圖外網(wǎng)的下面哈。如果顯示下圖說明你已經(jīng)成功了,開啟你的wordpress之旅了哈。關(guān)鍵詞:服務(wù)
微信公眾號
版權(quán)所有? 億企邦 1997-2025 保留一切法律許可權(quán)利。