CentOS7上搭建WordPress博客

進入CentOS7系統php

一  安裝 Apache HTTPhtml

yum install httpd

2)啓動服務,開啓mod_rewrite模塊mysql

//進行httpd.conf
vi /etc/httpd/conf/httpd.conf
//定位到AllowOverride None把None修改成All
AllowOverride None
//啓動服務
systemctl start httpd.service

二  安裝 MySqlweb

rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum install mysql mysql-server mysql-libs mysql-server

2)設置sql服務開機自動啓動sql

systemctl enable mysql.service

3)啓動sql服務數據庫

systemctl restart  mysql.service

4)進入mysql,首次進入默認密碼無,直接回車便可apache

mysql -u root -p

5)修改密碼vim

//查看全部數據庫
show databases;
//使用mysql數據庫
use mysql;
//修改密碼
update user set password=password('新密碼') where user='root';
//刷新用戶權限
flush privileges;

6)建立一個wordpress數據庫api

create database wordpress;

三   安裝 PHP 以及相關 PHP 組件瀏覽器

yum -y install php php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl

2)安裝調試phpmyadmin

//安裝所在的軟件源
yum -y install epel-release
//安裝phpmyadmin
yum -y install phpmyadmin
//啓動phpmyadmin服務
systemctl restart httpd.service

四  下載安裝 WordPress

//在臨時目錄下建立一個文件存放
mkdir /tmp/wp
//進入建立的文件目錄
cd /tmp/wp
//下載wordpress
wget http://wordpress.org/latest.zip

2)解壓文件

unzip -q latest.zip -d /var/www/html/

3)更改wordpree權限

chown -R apache:apache /var/www/html/wordpress
chmod -R 777 /var/www/html/wordpress

4)建立一個能夠上傳的目錄upload,並將屬主改成apache

mkdir -p /var/www/html/wordpress/wp-content/uploads

chown -R :apache /var/www/html/wordpress/wp-content/uploads

5)修改配置文件,以即可以訪問數據庫,wp-config.php中用戶名和密碼須要更改

cd /var/www/html/wordpress/
mkdir wp-config.php
vim wp-config.php
//插入類容以下
<?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', '用戶名');

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

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

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

/** 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',         'Qch&gb#c@7Uy3C8QuVa0+T9rOcy>CeLft/dZh>]_<78b)fXY/k-1{ctA$A81jCrS');
define('SECURE_AUTH_KEY',  'Bmq3kgkmWe/eR([N#k)rkX8YB+dG5NlCy{Dkzk:F=LFN$PcVfGcKAsGRjcM^YUF4');
define('LOGGED_IN_KEY',    'h1-2#zc]oy]{GVsrvR4[}X>}/=EyW|N*~.;:O:.07P@U#SdIp`(cOP^oT={[dgy@');
define('NONCE_KEY',        'xWVnU!.|`9_)Vx/yB(fb$fJH+fV:7OoGV#0QwE3x|+,G=u8P)Pmv=w}}3El| 7pN');
define('AUTH_SALT',        '0ZV@k69Ghs{Zt@*`F(IzEVhsRdm9[wPf2.sy0aX{4f~%_o 2!:@9f=u>C*t/^o^i');
define('SECURE_AUTH_SALT', 'T)][P8^m!~o|:}fQ)zjX%oLMJp+7& 4h4botpk.xhwc&0l ?g t$.5O[RRP(N@.]');
define('LOGGED_IN_SALT',   '5t%TV+jFB3YUU3`yZ711`F BM-k{.s8Fkz>mFOixRB?UiRx.A/rtv1NfsLr`.3F@');
define('NONCE_SALT',       ')@Z:O/M=>WpL4iUR]w$aTS-)LY`4~<~fTsa1MnK^=3 c:xK1WUB<0LygnfRG9)$1');

/**#@-*/

/**
 * 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_';

/**
 * 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', dirname(__FILE__) . '/');

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

6)瀏覽器輸入http://http://服務器地址/wordpress 後就能夠進行最後的登錄安裝

7)建立.htaccess文件和編輯.htaccess文件

//建立
touch /var/www/html/wordpress/.htaccess
//編輯
vim /var/www/html/wordpress/.htaccess
//編輯內容以下,若是存在就不須要添加
<IfModule mod_rewrite.c>

RewriteEngine On

RewriteBase /wordpress/

RewriteRule ^index\.php$ - [L]

RewriteCond %{REQUEST_FILENAME} !-f

RewriteCond %{REQUEST_FILENAME} !-d

RewriteRule . /wordpress/index.php [L]</IfModule>

//修改權限
chmod 664 /data/www/default/wordpress/.htaccess
相關文章
相關標籤/搜索