-
1 # 使用者7004596690954
-
2 # 俠侶安全
想要搭建個人網站,就需要有單獨的伺服器,就在阿里雲購買了臺伺服器,選擇系統為“Ubuntu 14.04.5 LTS”,並在阿里雲買了個域名(域名是為了方便記憶,否則輸入ip地址訪問網站很不方便),下面就使用Ubuntu系統搭建WordPress個人網站。
安裝WordPress執行環境
1.安裝Mysql資料庫
apt update
apt upgrade
apt install mysql-server
檢視mysql是否安裝成功:
root@iZ2zeeg42qkecbhciml4pcZ:~# mysql --version
mysql Ver 14.14 Distrib 5.5.62, for debian-linux-gnu (x86_64) using readline 6.3
2.安裝PHP
apt-get install software-properties-common
add-apt-repository ppa:ondrej/php
apt update
apt install php7.2
apt install libapache2-mod-php7.2
apt install php7.2-mysql
apt install php7.2-fpm
檢視php是否安裝成功:
root@iZ2zeeg42qkecbhciml4pcZ:~# php -v
PHP 7.2.16-1+ubuntu14.04.1+deb.sury.org+1 (cli) (built: Mar 7 2019 20:42:24) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.2.16-1+ubuntu14.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend Technologies
3.安裝Nginx
install nginx
檢視Nginx是否安裝成功:
root@iZ2zeeg42qkecbhciml4pcZ:~# nginx -v
nginx version: nginx/1.4.6 (Ubuntu)
重啟Nginx後,在瀏覽器中輸入http://阿里雲伺服器網路IP地址/
service nginx stop
service nginx start
如果圖片顯示為下圖,說明阿里雲伺服器自動啟動了apache2的服務,apache2和nginx都使用80埠,80埠衝突。
關閉apache2的服務
重啟php7.2-fpm服務和Nginx服務:
在瀏覽器中輸入http://阿里雲伺服器網路IP地址/
安裝WordPress及其配置
1.Mysql建立資料庫和使用者:
root@iZ2zeeg42qkecbhciml4pcZ:~# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 44
Server version: 5.5.62-0ubuntu0.14.04.1 (Ubuntu)
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type "help;" or "\h" for help. Type "\c" to clear the current input statement.
mysql> create database 資料庫名稱 character set utf8 collate utf8_general_ci;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on 資料庫名稱.* to "使用者名稱"@localhost identified by "使用者密碼";
Query OK, 0 rows affected (0.00 sec)
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
mysql> quit
Bye
root@iZ2zeeg42qkecbhciml4pcZ:~#
2.下載WordPress並安裝:
將下載的wordpress-5.0.3-
zh_CN.tar.gz
上傳到雲伺服器上安裝wordPress:
root@iZ2zeeg42qkecbhciml4pcZ:~# ls
wordpress-5.0.3-zh_CN.tar.gz
root@iZ2zeeg42qkecbhciml4pcZ:~# mv wordpress-5.0.3-zh_CN.tar.gz /var/www/
root@iZ2zeeg42qkecbhciml4pcZ:~# cd /var/www/
root@iZ2zeeg42qkecbhciml4pcZ:/var/www# ls
html wordpress-5.0.3-zh_CN.tar.gz
root@iZ2zeeg42qkecbhciml4pcZ:/var/www# tar -zxvf wordpress-5.0.3-zh_CN.tar.gz
......
root@iZ2zeeg42qkecbhciml4pcZ:/var/www# ls
html wordpress wordpress-5.0.3-zh_CN.tar.gz
root@iZ2zeeg42qkecbhciml4pcZ:/var/www# cd wordpress/
root@iZ2zeeg42qkecbhciml4pcZ:/var/www/wordpress# ls
index.php readme.html wp-admin wp-comments-post.php wp-content wp-includes wp-load.php wp-
mail.php
wp-signup.php xmlrpc.phplicense.txt
wp-activate.php wp-blog-header.php wp-config-sample.php wp-cron.php wp-links-opml.php wp-login.php wp-settings.php wp-trackback.phproot@iZ2zeeg42qkecbhciml4pcZ:/var/www/wordpress# mv wp-config-sample.php wp-
config.php
使用vim命令編輯wp-config.php:
vim wp-config.php
修改檔案中的資料庫配置資訊,填寫剛才建立的資料庫資訊:
/** WordPress資料庫的名稱 */
define("DB_NAME", "資料庫名稱");
/** MySQL資料庫使用者名稱 */
define("DB_USER", "使用者名稱");
/** MySQL資料庫密碼 */
define("DB_PASSWORD", "資料庫密碼");
/**
* WordPress資料表字首。
*
* 如果您有在同一資料庫內安裝多個WordPress的需求,請為每個WordPress設定
* 不同的資料表字首。字首名只能為數字、字母加下劃線。
*/
$table_prefix = "wp_";
在阿里雲控制檯將域名解析到指定的伺服器上:
控制檯->域名->解析->新增紀錄
配置服務安全組策略,將80(http)埠和443(https)埠開放:
控制檯->雲伺服器ECS->網路和安全->安全組->配置規則
配置80埠:
配置443埠:
配置後檢視內容:
編輯Nginx配置檔案:/etc/nginx/sites-available/default
client_max_body_size 10m;
server {
listen 80;
listen [::]:80;
server_name localhost; #你的域名
root /var/www/wordpress;
index index.php index.html index.htm index.nginx-debian.html;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
# include fastcgi.conf;
include fastcgi_params;
fastcgi_buffer_size 128k;
fastcgi_buffers 32 32k;
#fastcgi_intercept_errors on;
# With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
# With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
}
重啟Nginx後,在瀏覽器中輸入http://阿里雲伺服器網路IP地址/
service nginx stop
service nginx start
在瀏覽器中訪問自己的域名,檢視是否成功:
到此WordPress就安裝成功了,你可以自行配製您的網站資訊。
回覆列表
可以,分目錄就可以,但是繫結兩個域名就不行,這種建議用pageadmin、sw這類專業的多站點cms來做。