安装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!!!

安装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.178linux.com/17222

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

相关推荐

  • 网络基础

    计算机网络     计算机网络,是指将地理位置不同的具有独立功能的多台计算机及其外部设备,通过通信线路连接起来,在网络操作系统,网络管理软件及网络通信协议的管理和协调下,实现资源共享和信息传递的计算机系统。 1、网络通信设备     网络通信设备种类繁多,且日新月异,网络通信设备通常由网络线缆、网卡、集线器、中继器、网桥、交换机、路由器等组成。 网桥(Bri…

    Linux干货 2016-12-16
  • N25-第二周作业

    ①Linux文件管理命令常用方法 Linux常见文件类型 -:files,常规文件 d: directory,目录文件 b: block device,块设备文件 c:character device,字符设备文件 l:symbolic link,符号链接文件 p: pipe,命名管道 s: socket,套接字文件 命令管理工具指南:cp、rm、mv 1.…

    Linux干货 2016-12-13
  • Linux程序包管理(rpm、yum、make)

    linux系统程序安装的方法有rpm yum 以及make手动编译3种方法: rpm这个机制最早由Redhat公司开发出来,后来由于实在好用,所以被很多发行版所使用作为软件安装的管理方式。不过由于使用RPM安装软件时有时会涉及到文件的依赖信,此时需要手动去逐个安装被依赖的包操作起来十分复杂,于是yum这种线上升级的机制便出现了,它会自己主动解决各文件的依赖关…

    Linux干货 2017-10-02
  • redis主/从配置及基于sentinel的故障转移

     一、NoSQL基础概念: ACID:原子性、一致性、隔离性、持久性;特性:数据量大、数据变化非常大(数据增长化、流量分布变化、数据间耦合结构变化)、数据源很多; CAP、BASECAP C:多个数据节点的的数据一致;A:用户发出请求后的有限时间范围内返回结果;P:network partition,网络发生分区后,服务是否依可用;CAP理论:一个分布式系统…

    Linux干货 2017-12-18
  • 编程命名中的7+1个提示

    前几天Neo写过《编程中的命名设计那点事》,这里也有另外一篇和程序命名的文章,可以从另一个角度看看。 1.- 变量应该是尽可能的望文知意。千万不要使用教材中的命名方式。 好的变量: daysDateRange, flightNumber, carColor. 坏的变量: days, dRange, temp, data, aux… 在我们…

    Linux干货 2015-04-03
  • Week 1–Linux基础2

    四. Linux系统命令使用格式:  但首先,在linux中我们要知道linux系统中基本的命令格式如下: 命令字 【命令选项】 【命令参数】   Command 【option】 【arguments】 在这里主要介绍这几个命令的使用格式(Ifconfig,echo, tty, startx, export, pwd, history, shut…

    Linux干货 2016-12-05

评论列表(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技术博客大赛–复审阶段》帖子下才有效哦!