從0到1搭建wordpress

推薦一個(gè)很棒的網(wǎng)站騰訊云的開發(fā)者實(shí)驗(yàn)室

作者就是跟著開發(fā)者實(shí)驗(yàn)室的教程搭的第一個(gè)wordpress滑沧,教程很棒不過有些小坑,根據(jù)其教程略作修改如下,另外由于價(jià)格原因最終選了阿里云搭建本博客= =!


本實(shí)驗(yàn)用centos 6.8 64位系統(tǒng)躬它,其他系統(tǒng)可能在linux命令有點(diǎn)差別


  • 安裝Nginx

    • 用yum安裝Nginx
      yum install nginx -y
    • 修改/etc/nginx/default.conf(nginx的默認(rèn)配置腾啥,沒啥用,后面會(huì)被代替)冯吓,去除對IPv6的監(jiān)聽,示例如下:

    CentOS 6 不支持 IPv6倘待,需要取消對 IPv6 地址的監(jiān)聽,否則 Nginx 不能成功啟動(dòng)组贺。

    server {
        listen       80 default_server;
        # listen       [::]:80 default_server;
        server_name  _;
        root         /usr/share/nginx/html;
    
        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;
    
        location / {
        }
    
        error_page 404 /404.html;
            location = /40x.html {
        }
    
        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    
    }
    
    • 修改完成后啟動(dòng)nginx:
      nginx
    • 此時(shí)凸舵,可訪問本機(jī)外網(wǎng)ip 來確認(rèn)是否已經(jīng)安裝成功。
      *將nginx設(shè)為開機(jī)啟動(dòng):
      chkconfig nginx on
  • 安裝Mysql

    • 使用yum安裝Mysql:
      yum install mysql-server -y
    • 安裝完成后锣披,啟動(dòng)Mysql服務(wù):
      service mysqld restart
    • 設(shè)置Mysql賬戶root密碼:
      /usr/bin/mysqladmin -u root password 'yourPassword'
    • 將Mysql設(shè)置為開機(jī)啟動(dòng):
      chkconfig mysqld on
    • 安裝PHP
    • 使用 yum 安裝PHP:
      yum install php-fpm php-mysql php-gd -y

    騰訊教程上未安裝php-gd包會(huì)導(dǎo)致贞间,在wordpress上傳圖片裁剪時(shí)報(bào)錯(cuò)

    • 啟動(dòng)php-fpm 進(jìn)程(默認(rèn)監(jiān)聽9000):
      service php-fpm start
    • 設(shè)置PHP-FPM 為開機(jī)啟動(dòng)
      chkconfig php-fpm on
    • 至此LNMP環(huán)境安裝完成
  • 安裝WordPress

    • 使用yum 安裝WordPress
      yum install wordpress -y

    在/usr/share/press 可以看到wordpress的源碼

    默認(rèn)安裝了最新版英文包贿条,會(huì)導(dǎo)致在wordpress后臺(tái)選網(wǎng)站語言選中文沒反應(yīng)雹仿,因?yàn)槿鄙僦形恼Z言包。
    解決方案:到網(wǎng)上下載一個(gè)中文版整以,將wordpress-content中的lanuages文件夾加入到服務(wù)器相同目錄下(wordpress-content文件夾下)

  • 配置wordpress數(shù)據(jù)庫

    • 進(jìn)入Mysql胧辽,創(chuàng)建 wordpress 數(shù)據(jù)庫
    mysql -uroot --password='yourPassword';
    CREATE DATABASE wordpress;
    exit
    
    • 在wordpress配置文件(/etc/wordpress/wp-config.php)中配置數(shù)據(jù)庫,配置文件如下:
<?php
/**
 * The base configuration for WordPress
 *
 * The wp-config.php creation script uses this file during the
 * installation. You don't have to use the web site, you can
 * copy this file to "wp-config.php" and fill in the values.
 *
 * This file contains the following configurations:
 *
 * * MySQL settings
 * * Secret keys
 * * Database table prefix
 * * ABSPATH
 *
 * @link https://codex.wordpress.org/Editing_wp-config.php
 *
 * @package WordPress
 */

// ** 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', 'root');

/** MySQL database password */
define('DB_PASSWORD', 'yourPassword');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

/**#@+
 * Authentication Unique Keys and Salts.
 *
 * Change these to different unique phrases!
 * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}
 * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again.
 *
 * @since 2.6.0
 */
define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

/**#@-*/

/**
 * WordPress Database Table prefix.
 *
 * You can have multiple installations in one database if you give each
 * a unique prefix. Only numbers, letters, and underscores please!
 */
$table_prefix  = 'wp_';

/**
 * See http://make.wordpress.org/core/2013/10/25/the-definitive-guide-to-disabling-auto-updates-in-wordpress-3-7
 */

/* Disable all file change, as RPM base installation are read-only */
define('DISALLOW_FILE_MODS', true);

/* Disable automatic updater, in case you want to allow
   above FILE_MODS for plugins, themes, ... */
define('AUTOMATIC_UPDATER_DISABLED', true);

/* Core update is always disabled, WP_AUTO_UPDATE_CORE value is ignore */

/**
 * For developers: WordPress debugging mode.
 *
 * Change this to true to enable the display of notices during development.
 * It is strongly recommended that plugin and theme developers use WP_DEBUG
 * in their development environments.
 *
 * For information on other constants that can be used for debugging,
 * visit the Codex.
 *
 * @link https://codex.wordpress.org/Debugging_in_WordPress
 */
define('WP_DEBUG', false);

/* That's all, stop editing! Happy blogging. */

/** Absolute path to the WordPress directory. */
if ( !defined('ABSPATH') )
    define('ABSPATH', '/usr/share/wordpress');

/** Sets up WordPress vars and included files. */
require_once(ABSPATH . 'wp-settings.php');


  • 配置nginx

    • 配置nginx 將請求轉(zhuǎn)發(fā)給php
    • 刪掉default.conf 文件, 在/etc/nginx/conf.d 創(chuàng)建wordpress.conf,文件內(nèi)容如下:
    server {
        listen 80;
        root /usr/share/wordpress;
        location / {
            index index.php index.html index.htm;
            try_files $uri $uri/ /index.php index.php;
        }
        # 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;
        }
    }
    
    • 重啟nginx公黑,加載配置
      nginx -s reload

    如果有域名的話可以在wordpress 文件中配置邑商,配置項(xiàng) server_name www.yourdomain.com;

部署完成,通過ip訪問地址: http://<您的域名>/wp-admin/install.php

域名購買凡蚜,解析后續(xù)再說~
最后附上我搭建的博客人断,羞恥的域名~
網(wǎng)站沒備案= =!被封了

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末朝蜘,一起剝皮案震驚了整個(gè)濱河市恶迈,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌谱醇,老刑警劉巖暇仲,帶你破解...
    沈念sama閱讀 218,284評論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件步做,死亡現(xiàn)場離奇詭異,居然都是意外死亡奈附,警方通過查閱死者的電腦和手機(jī)全度,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,115評論 3 395
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來斥滤,“玉大人将鸵,你說我怎么就攤上這事∮悠模” “怎么了咨堤?”我有些...
    開封第一講書人閱讀 164,614評論 0 354
  • 文/不壞的土叔 我叫張陵,是天一觀的道長漩符。 經(jīng)常有香客問我一喘,道長,這世上最難降的妖魔是什么嗜暴? 我笑而不...
    開封第一講書人閱讀 58,671評論 1 293
  • 正文 為了忘掉前任凸克,我火速辦了婚禮,結(jié)果婚禮上闷沥,老公的妹妹穿的比我還像新娘萎战。我一直安慰自己,他們只是感情好舆逃,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,699評論 6 392
  • 文/花漫 我一把揭開白布蚂维。 她就那樣靜靜地躺著,像睡著了一般路狮。 火紅的嫁衣襯著肌膚如雪虫啥。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 51,562評論 1 305
  • 那天奄妨,我揣著相機(jī)與錄音涂籽,去河邊找鬼。 笑死砸抛,一個(gè)胖子當(dāng)著我的面吹牛评雌,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播直焙,決...
    沈念sama閱讀 40,309評論 3 418
  • 文/蒼蘭香墨 我猛地睜開眼景东,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了奔誓?” 一聲冷哼從身側(cè)響起斤吐,我...
    開封第一講書人閱讀 39,223評論 0 276
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒想到半個(gè)月后曲初,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體体谒,經(jīng)...
    沈念sama閱讀 45,668評論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,859評論 3 336
  • 正文 我和宋清朗相戀三年臼婆,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了抒痒。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,981評論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡颁褂,死狀恐怖故响,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情颁独,我是刑警寧澤彩届,帶...
    沈念sama閱讀 35,705評論 5 347
  • 正文 年R本政府宣布,位于F島的核電站誓酒,受9級特大地震影響樟蠕,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜靠柑,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,310評論 3 330
  • 文/蒙蒙 一寨辩、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧歼冰,春花似錦靡狞、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 31,904評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至腮恩,卻和暖如春梢杭,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背庆揪。 一陣腳步聲響...
    開封第一講書人閱讀 33,023評論 1 270
  • 我被黑心中介騙來泰國打工式曲, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留妨托,地道東北人缸榛。 一個(gè)月前我還...
    沈念sama閱讀 48,146評論 3 370
  • 正文 我出身青樓,卻偏偏與公主長得像兰伤,于是被迫代替她去往敵國和親内颗。 傳聞我的和親對象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,933評論 2 355

推薦閱讀更多精彩內(nèi)容