搭建wordpress

 首先要搭建LNMP環境,關於LNMP的安裝請參照個人上一篇文章:(http://wangwq.blog.51cto.com/8711737/1712811javascript

安裝好LNMP環境以後,開始安裝wordpress。php

若是下面有的命令不適用你本身,請參照個人LNMP安裝的文章作出對應。css

 

1.下載wordpress源碼包html

  wordpress官網地址:https://cn.wordpress.org/, 下載源碼包,若是是在windows中下載的,下載完用ftp工具傳輸到linux系統中便可。java

2.解壓node

1
tar  zxvf wordpress-4.3.1-zh_CN. tar .gz

解壓完成,將/usr/local/nginx/html下的文件刪除:mysql

1
rm  -rf  /usr/local/nginx/html/ *

而後將解壓以後的wordpress裏的全部文件拷貝到/usr/local/nginx/html下(注意是wordpress目錄下的全部文件,不是wordpress目錄):linux

1
cp  -R wordpress/*  /usr/local/nginx/html/

3.添加mysql數據庫nginx

1
2
3
/usr/local/mysql/bin/mysql  -uroot -p
create database wordpress;        // 建立庫
use wordpress;      // 應用庫

4.配置nginxsql

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
vim  /usr/local/nginx/conf/nginx .conf    // 清空原來的配置,加入以下內容:
 
user nobody nobody;
  worker_processes 2;
  error_log  /usr/local/nginx/logs/nginx_error .log crit;
  pid  /usr/local/nginx/logs/nginx .pid;
  worker_rlimit_nofile 51200;
  events
  {
      use epoll;
      worker_connections 6000;
  }
  http
 
  {
      include mime.types;
      default_type application /octet-stream ;
      server_names_hash_bucket_size 3526;          // 這個數別太大,通常256就能夠了
      server_names_hash_max_size 4096;
      log_format combined_realip  '$remote_addr $http_x_forwarded_for [$time_local]'
      '$host "$request_uri" $status'
      '"$http_referer" "$http_user_agent"' ;
      sendfile on;
      tcp_nopush on;
      keepalive_timeout 30;
      client_header_timeout 3m;
      client_body_timeout 3m;
      send_timeout 3m;
      connection_pool_size 256;
      client_header_buffer_size 1k;
      large_client_header_buffers 8 4k;
      request_pool_size 4k;
      output_buffers 4 32k;
      postpone_output 1460;
      client_max_body_size 10m;
      client_body_buffer_size 256k;
      client_body_temp_path  /usr/local/nginx/client_body_temp ;
      proxy_temp_path  /usr/local/nginx/proxy_temp ;
      fastcgi_temp_path  /usr/local/nginx/fastcgi_temp ;
      fastcgi_intercept_errors on;
      tcp_nodelay on;
      gzip  on;
      gzip_min_length 1k;
      gzip_buffers 4 8k;
      gzip_comp_level 5;
      gzip_http_version 1.1;
      gzip_types text /plain  application /x-javascript  text /css  text /htm  application /xml ;
 
  server
 
  {
      listen 80;
      server_name localhost;
      index index.html index.htm index.php;
      root  /usr/local/nginx/html ;
 
      location ~ \.php$ {
          include fastcgi_params;
          fastcgi_pass 127.0.0.1:9000;
          fastcgi_index index.php;
          fastcgi_param SCRIPT_FILENAME  /usr/local/nginx/html $fastcgi_script_name;
      }
  }
  }

5.配置php-fpm

php的配置根據本身的狀況配置,若是隻是作實驗,這裏有一個配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[global] 
pid =  /usr/local/php-fpm/var/run/php-fpm .pid
error_log =  /usr/local/php-fpm/var/log/php-fpm .log 
[www] 
listen =  /tmp/php-fcgi .sock              // 也能夠寫tcp /ip ,如 listen = 127.0.0.1:9000
user = php-fpm 
group = php-fpm
listen.owner = nobody     // 和後面的nginx的一致
listen.group = nobody     //  同上
pm = dynamic 
pm.max_children = 50 
pm.start_servers = 20 
pm.min_spare_servers = 5              // 最小空閒子進程
pm.max_spare_servers = 35           // 最大空閒子進程
pm.max_requests = 500 
rlimit_files = 1024

6.重啓服務

1
2
3
service mysqld restart
service nginx restart
service php-fpm restart

7.網頁配置安裝

上述步驟完成以後,在瀏覽器中輸入ip,顯示出如圖界面:

 

wKioL1ZRbFOhxX0kAAB0lrCGp7Y990.png

 

上圖給的信息是要建立一個文件,這個文件是建立在/usr/local/nginx/html中的,因此要修改這個目錄的權限爲777:

1
chmod  777  /usr/local/nginx/html

或者能夠不用修改,下面的步驟會給出解決方法。

點擊「如今就開始!」,進入配置:

wKioL1ZRbkrAlOz7AABq7eXa5l0377.png

 

若是上面沒有修改文件權限,則會出現下圖的內容:

wKiom1ZRcLSBnLs1AABiiUisSwo496.png

這時能夠手動建立:

1
vim  /usr/local/nginx/html/wp-config .php

而後複製圖中框裏的內容,保存退出。

若是在前面就已經修改了權限,則不用手動建立。

點擊「進行安裝」,進入下一步:

wKiom1ZRceywsvr-AABkNklsGHk184.png

至此已經基本完成安裝,輸入標題、用戶及密碼、郵件,點擊「安裝wordpress」:

wKioL1ZRczWR-Gs0AAA1FLVANIU184.png

安裝成功,點擊「登陸」進入登陸界面:

wKioL1ZRc5qSefAQAAAncH4HZCA538.png

 

輸入用戶名及密碼,點擊「登陸」,完成登陸。

wKiom1ZRc-zSXiUYAABajFNcu60062.png

相關文章
相關標籤/搜索