推薦一個(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
- 用yum安裝Nginx
-
安裝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)境安裝完成
- 使用yum安裝Mysql:
-
安裝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文件夾下) - 使用yum 安裝WordPress
-
配置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)站沒備案= =!被封了