基于ssm的个人博客_基于 CentOS7 搭建 WordPress 个人博客
1.準(zhǔn)備 LNMP 環(huán)境
LNMP 是 Linux、Nginx、MySQL 和 PHP 的縮寫,是 WordPress 博客系統(tǒng)依賴的基礎(chǔ)運(yùn)行環(huán)境。我們先來準(zhǔn)備 LNMP 環(huán)境
1.1.安裝 Nginx
安裝過程參考博客:使用nginx將阿里云服務(wù)器升級為https安裝成功后在瀏覽器中輸入虛擬機(jī)ip地址,來確認(rèn)是否已經(jīng)安裝成功。下面是成功過界面
將 Nginx 設(shè)置為開機(jī)自動(dòng)啟動(dòng):
chkconfig nginx on1.2.安裝 MySQL
安裝MySQL參考博客:Centos7安裝和配置MySQL5.7
安裝成功連接MySQL如下:
1.3.安裝 PHP
使用 yum 安裝 PHP:
yum install php-fpm php-mysql -y安裝成功:
安裝之后,啟動(dòng) PHP-FPM 進(jìn)程:
service php-fpm start啟動(dòng)之后,可以使用下面的命令查看 PHP-FPM 進(jìn)程監(jiān)聽哪個(gè)端口
netstat -nlpt | grep php-fpm把 PHP-FPM 也設(shè)置成開機(jī)自動(dòng)啟動(dòng):
chkconfig php-fpm onPHP-FPM 默認(rèn)監(jiān)聽 9000 端口安裝并配置 WordPress任務(wù)時(shí)間:30min ~ 60min
2.安裝 WordPress
2.1.下載配置 WordPress
配置好 LNMP 環(huán)境后,開始下載 WordPress:(官網(wǎng):https://cn.wordpress.org/download/releases/)
wget https://cn.wordpress.org/wordpress-4.8.3-zh_CN.tar.gz如果不能下載,請去資源界面軟件部分下載壓縮包:網(wǎng)站資源 ;解壓:
tar -zxvf wordpress-4.8.3-zh_CN.tar.gz文件目錄
安裝完成后,就可以在 /usr/share/wordpress 看到 WordPress 的源代碼了。連接MySQL
mysql -u root -p為 WordPress 創(chuàng)建一個(gè)數(shù)據(jù)庫:
CREATE DATABASE wordpress;MySQL 部分設(shè)置完了,我們退出 MySQL 環(huán)境:
exit然后將wordpress目錄下的 wp-config-sample.php 重命名為 wp-config.php
mv wp-config-sample.php wp-config.php然后把上述的 DB 配置同步到 WordPress 的配置文件(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', 'root');/** MySQL database password */define('DB_PASSWORD', 'MySQLroot用戶的密碼');/** 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');注意修改MySQL的密碼
2.2.配置 Nginx
WordPress 已經(jīng)安裝完畢,我們配置 Nginx 把請求轉(zhuǎn)發(fā)給 PHP-FPM 來處理修改配置文件,
vim /usr/local/nginx/conf/nginx.conf參考內(nèi)容如下,其中root /usr/share/wordpress;是我的wordpress目錄
worker_processes 1;events { worker_connections 1024;}http { # 設(shè)置nginx允許上傳文件的大小 client_max_body_size 10m; include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; gzip on; 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。然后訪問
http://ip/wp-admin/install.py3.安裝成功
下面是成功的界面:
填寫完信息之后登錄,登錄成功界面
網(wǎng)站主頁
網(wǎng)站到這里就搭建成功了。可以自己研究研究.....
注意當(dāng)前版本比較低,大家可以安裝最新版本(我安裝最新版本的時(shí)候,說php版本過低emmm,果斷放棄)
總結(jié)
以上是生活随笔為你收集整理的基于ssm的个人博客_基于 CentOS7 搭建 WordPress 个人博客的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python最好的教程_喜大普奔~可能是
- 下一篇: python3虚拟环境搭建_python