安裝LNMP + 搭建WordPress個人博客

安裝LNMP + 搭建Wordpress個人博客

前言

來到馬哥教育也有幾個月了,學了很多知識。現在想要把這些知識能夠存儲在一個地方,隨時隨地的都能看到,于是乎我就想到了博客,以下我搭建Wordpress的過程。

安裝LNMP

一、關掉防火墻

# chkconfig iptables off

二、安裝開發包和庫文件

# yum -y install ntp make openssl openssl-devel pcre pcre-devel libpng libpng-devel libjpeg-6b libjpeg-devel-6b freetype freetype-devel gd gd-devel zlib zlib-devel gcc gcc-c++ libXpm libXpm-devel ncurses ncurses-devel libmcrypt libmcrypt-devel libxml2 libxml2-devel imake autoconf automake screen sysstat compat-libstdc++-33 curl curl-devel

三、查看是否已安裝apache、mysql、php。如果有將其卸載
我查看到自己的系統里只有mysql,所以將其卸載后接下來就是正式安裝了

# yum -y remove mysql*

四、安裝nginx

# yum -y install nginx

Loaded plugins: fastestmirror
Setting up Install Process
Loading mirror speeds from cached hostfile
 * base: centos.ustc.edu.cn
 * extras: centos.ustc.edu.cn
 * updates: centosx4.centos.org
No package nginx available.
Error: Nothing to do

發現在這里nginx無法用yum安裝,發現其實是Centos默認的標準源里沒有nginx軟件包

# wget http://www.atomicorp.com/installers/atomic
# sh ./atomic
# yum check-update

注意:在第二步中(# sh ./atomic)會有兩次提示,輸入yes就好。
現在就可以使用yum來安裝nginx啦~~~

# yum -y install nginx
# service nginx start
Starting nginx:                                            [  OK  ]
# chkconfig --levels 235 nginx on

現在就可以在你的瀏覽器里輸入你的服務器的IP地址了,查看nginx是否正常啟動了
QQ圖片20160531213546.png

五、安裝mysql

# yum -y install mysql mysql-server mysql-devel
# service mysqld start
Initializing MySQL database:  Installing MySQL system tables...
160601  5:39:11 [Note] libgovernor.so not found
160601  5:39:11 [Note] /usr/libexec/mysqld (mysqld 5.5.49-cll-lve) starting as process 1786 ...
OK
Filling help tables...
160601  5:39:11 [Note] libgovernor.so not found
160601  5:39:11 [Note] /usr/libexec/mysqld (mysqld 5.5.49-cll-lve) starting as process 1793 ...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
/usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

Please report any problems at http://bugs.mysql.com/

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

# chkconfig --levels 235 mysqld on

登陸mysql刪除空用戶,修改root密碼

# mysql                   #進入mysql

mysql> select user,host,password from mysql.user;
+------+-----------------------+----------+
| user | host                  | password |
+------+-----------------------+----------+
| root | localhost             |          |
| root | localhost.localdomain |          |
| root | 127.0.0.1             |          |
| root | ::1                   |          |
|      | localhost             |          |
|      | localhost.localdomain |          |
+------+-----------------------+----------+
6 rows in set (0.00 sec)

mysql> drop user ''@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> update mysql.user set password = PASSWORD('root') where user='root';
Query OK, 4 rows affected (0.00 sec)
Rows matched: 4  Changed: 4  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

六、安裝php

# yum -y install php lighttpd-fastcgi php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap

安裝php和所需組件使用php支持mysql、fastcgi模式

# yum -y install php-tidy php-common php-devel php-fpm php-mysql
# service php-fpm start
# chkconfig --levels 235 php-fpm on

七、配置nginx支持php

# mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak
//將配置文件改為備份文件

# cp /etc/nginx/nginx.conf.default /etc/nginx/nginx.conf
//將默認的配置文件作為配置文件

# vim /etc/nginx/nginx.conf

        location / {
            root   html;
            index  index.php index.html index.htm;    #增加index.php
        }

        location ~ \.php$ {
            root           /usr/share/nginx/html;     #修改為nginx默認路徑
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /usr/share/nginx/html$fastcgi_script_name;
            include        fastcgi_params;
        }

配置php,編輯php.ini文件,在末尾添加cgi.fix_pathinfo = 1

# vim /etc/php.ini

重啟nginx,php-fpm

# service nginx restart
Stopping nginx:                                            [  OK  ]
Starting nginx:                                            [  OK  ]
# service php-fpm restart
Stopping php-fpm:                                          [  OK  ]
Starting php-fpm:                                          [  OK  ]

建立info.php文件

# vim /usr/share/nginx/html/info.php 
<?php
    phpinfo();
?>

測試nginx是否解析php,在瀏覽器輸入:192.168.1.104/info.php
顯示php界面,環境搭建成功
123.png


環境已經搭建成功了,現在到了激動的時候了!安裝Wordpress?。。?/p>

安裝Wordpress

首先從官網上下載安裝包

# wget https://cn.wordpress.org/wordpress-4.5.2-zh_CN.tar.gz

安裝包下好之后,把它mv到nginx默認路徑下。

# mv wordpress-4.5.2-zh_CN.tar.gz /usr/share/nginx/html/

然后將安裝包解壓,把解壓出來的目錄里的文件放到/usr/share/nginx/html/

# tar zxvf wordpress-4.5.2-zh_CN.tar.gz
html]# cp -R wordpress/* ./

然后,打開瀏覽器,輸入服務器的IP地址,就會顯示安裝wordpress界面
2.png

為wordpress創建數據庫和用戶

# mysqladmin -u root -p create BLOG          #創建BLOG數據庫
# mysql -u root -p 
Enter password:*******
mysql> use BLOG;
Database changed

mysql> GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP
    -> ON BLOG.*
    -> TO 'yanglei'@'localhost'
    -> IDENTIFIED BY 'yanglei123';

創建好后,在瀏覽器點擊現在就開始!會出現以下界面,按照提示輸入
44455.png

輸入完成之后,會跳出下面這個界面
66666.png

這時候,我們到/usr/share/nginx/html目錄下,編輯wp-config-sample.php文件,將數據庫和用戶名及密碼填入進去即可。

# vim /usr/share/nginx/html/wp-config-sample.php
// ** MySQL 設置 - 具體信息來自您正在使用的主機 ** //
/** WordPress數據庫的名稱 */
define('DB_NAME', 'BLOG');

/** MySQL數據庫用戶名 */
define('DB_USER', 'yanglei');

/** MySQL數據庫密碼 */
define('DB_PASSWORD', 'yanglei123');

保存并退出!然后將該文件改名為wp-config.php

# mv wp-config-sample.php wp-config.php

返回瀏覽器,點擊現在安裝之后,跳出如下界面
blog.png

現在,就可以填寫信息啦,填寫完成之后就是如下界面
789987789789789.png

點擊登陸之后,就到了登陸界面啦~~~大功告成!滿滿的成就感有木有!

原創文章,作者:黑白子,如若轉載,請注明出處:http://www.www58058.com/17222

(10)
黑白子黑白子
上一篇 2016-05-31
下一篇 2016-06-01

相關推薦

  • 第十五周作業

    1、總結sed和awk的詳細用法; sed:     模式空間:sed是一種在線編輯器、行編輯器,一次處理一行內容,在處理時,把當前處理的行存儲在臨時緩沖區當中,并在該緩沖區中完成后續的處理,該緩沖區被稱為”模式空間”。     保持空間:在模式空間中處理完一行內容后會繼續處理下一行,但是對于處…

    Linux干貨 2017-04-18
  • N26-第三周作業-邢巖

    馬哥門徒-N26-邢巖   “精深練習×一萬小時=世界級技能”。髓鞘質是不可逆的,就讓我們包裹一層厚厚的髓鞘質吧!今天繼續我的練習。   第一題,列出當前系統上所有已經登錄的用戶的用戶名,注意:同一個用戶登錄多次,則只顯示一次即可  ~]# who | cut -d' ' -f1 | sort -u &nbs…

    Linux干貨 2017-02-14
  • mysql/mariadb基于ssl的主從復制

     當mysql/mariadb跨越互聯網進行復制時別人可以竊取到mysql/mariadb的復制信息, 這些信息是明文的, 因此存在不安全性, 這里通過ssl對復制的信息進行加密      1. 創建證書中心 在主服務器上創建證書中心 cd /etc/pki/CA 生成私鑰 (umask&…

    Linux干貨 2016-12-05
  • CentOS 7 tomcat 7.0.54 的功能實現及詳解

    一、 jdk 安裝配置 # yum install java-1.8.0-openjdk-devel (依賴的java-1.8.0-openjdk,java-1.8.0-openjdk,headless也會被安裝 ) # alternatives -h # vim /e…

    Linux干貨 2014-06-09
  • Mysql備份II

    Mysql備份II V.II.I單臺或共用機器,數據量和訪問量小50G< 1 Mysqldump(全導出,導庫,導表) 鎖表 如果這時有些入會鎖住或者超時 2 至少停止寫入 防止innodb配置還沒刷到磁盤里 先flash tables /usr/local/mysql/bin/mysqladmin -S /tmp/mysql.so…

    Linux干貨 2016-06-09
  • 掛載

    掛載的相關介紹

    Linux干貨 2017-12-10

評論列表(7條)

  • Net17_得得
    Net17_得得 2016-05-31 23:34

    贊!

  • wangquan8628
    wangquan8628 2016-06-13 14:22

    0805+內容不錯,排版很好

  • sky138170
    sky138170 2016-06-13 14:25

    對實驗很有幫助,再加上原理就更好了

    • xxrenzhe
      xxrenzhe 2016-06-13 14:59

      @sky138170回復在原始博客下是無效評論哦,要評論在《馬哥教育首屆IT技術博客大賽–復審階段》帖子下才有效哦!

  • sky138170
    sky138170 2016-06-13 14:34

    0805+簡單明了,通俗易懂,解釋很詳細!對我幫助很大!不錯!不錯

    • xxrenzhe
      xxrenzhe 2016-06-13 14:58

      @sky138170回復在原始博客下是無效評論哦,要評論在《馬哥教育首屆IT技術博客大賽–復審階段》帖子下才有效哦!

欧美性久久久久