1. 程式人生 > 其它 >centos安裝部署wordpress

centos安裝部署wordpress

Wordpress專案介紹:wordpress 是開源的部落格系統
更多學習課程請訪問首頁:
https://edu.51cto.com/lecturer/14390454.html

1.1 手動部署Wordpress
#1.安裝nginx
[root@laowang ~]# vim /etc/yum.repos.d/nginx.repo
[root@laowang ~]# cat /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
[root@laowang ~]# yum install nginx -y

#2.配置Wordpress的nginx配置檔案
[root@laowang ~]# cd /etc/nginx/conf.d/
[root@laowang conf.d]# ls
default.conf
[root@laowang conf.d]# rm -f default.conf 
[root@laowang conf.d]# vim /etc/nginx/conf.d/wordpress.com.conf
[root@laowang conf.d]# cat /etc/nginx/conf.d/wordpress.com.conf
server {
        listen       80;
        root   /usr/share/nginx/html;
        server_name  localhost;
    location / {
            index index.php index.html index.htm;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
            root    /usr/share/nginx/html;
    }
    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;
    }
}

[root@laowang conf.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
[root@laowang conf.d]# systemctl start nginx
[root@laowang conf.d]# systemctl enable nginx
  • 安裝php
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

#安裝PHP
yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel -y
  • php配置
#1.修改PHP配置
[root@laowang ~]# vim /etc/php.ini
# 修改下面
session.save_path = “/var/lib/php/session”

#2.更改/var/lib/php/session目錄下所有檔案的屬組都改成 nginx 和 nginx。
[root@laowang ~]# mkdir -p /var/lib/php/session
[root@laowang ~]# chown -R nginx:nginx /var/lib/php/session
  • 3.下載Wordpress安裝包
[root@laowang ~]# mkdir code
[root@laowang ~]# cd code/
[root@laowang code]# wget https://cn.wordpress.org/wordpress-5.2.3-zh_CN.tar.gz
[root@laowang code]# tar xf wordpress-5.2.3-zh_CN.tar.gz 
[root@laowang code]# ls
wordpress  wordpress-5.2.3-zh_CN.tar.gz
[root@laowang code]# cd wordpress
[root@laowang wordpress]# ls
index.php    wp-activate.php     wp-comments-post.php  wp-cron.php        wp-load.php   wp-settings.php   xmlrpc.php
license.txt  wp-admin            wp-config-sample.php  wp-includes        wp-login.php  wp-signup.php
readme.html  wp-blog-header.php  wp-content            wp-links-opml.php  wp-mail.php   wp-trackback.php
  • 4.安裝資料庫(這裡使用mariadb)
#1.安裝資料庫
[root@laowang ~]# yum -y install mariadb-server mariadb
[root@laowang ~]# systemctl start mariadb
[root@laowang ~]# systemctl enable mariadb
#2.設定root使用者名稱密碼為admin123
[root@laowang ~]# mysqladmin -u root -p password admin123  #因為沒有密碼,所以直接回車建立

#3.測試登入
[root@laowang ~]# mysql -uroot -padmin123
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 8
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
#4.建立資料庫Wordpress
MariaDB [(none)]> CREATE DATABASE wordpress;


#5.寫入資料庫資訊
[root@laowang ~]# cd code/wordpress
[root@laowang wordpress]# cp wp-config-sample.php wp-config.php
[root@laowang wordpress]# vim wp-config.php 
/** WordPress資料庫的名稱 */
define( 'DB_NAME', 'wordpress' );
/** MySQL資料庫使用者名稱 */
define( 'DB_USER', 'root' );
/** MySQL資料庫密碼 */
define( 'DB_PASSWORD', 'admin123' );
/** MySQL主機 */
define( 'DB_HOST', 'localhost:3306' );
/** 建立資料表時預設的文字編碼 */
define( 'DB_CHARSET', 'utf8' );
/** 資料庫整理型別。如不確定請勿更改 */
define( 'DB_COLLATE', '' );

#6.將原始碼拷貝到預設目錄
[root@laowang wordpress]# cp -rp ./* /usr/share/nginx/html/
[root@laowang wordpress]# systemctl start php-fpm
[root@laowang wordpress]# systemctl enable php-fpm
[root@laowang wordpress]# nginx -s reload

#7.瀏覽器訪問
ip


輸入賬號密碼:laowang admin@123456登入