yum 安装 WordPress

前言

来到马哥教育也有几个月了,学了很多知识。现在想要把这些知识能够存储在一个地方,随时随地的都能看到,于是乎我就想到了博客,以下我搭建Wordpress的过程。

安装LNMP

一、关掉防火墙

1
# 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
1
# yum -y remove mysql*

三、查看是否已安装apache、mysql、php。如果有将其卸载
我查看到自己的系统里只有mysql,所以将其卸载后接下来就是正式安装了

四、安装nginx

1
2
3
4
5
6
7
8
9
10
# 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软件包

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

注意:在第二步中(# sh ./atomic)会有两次提示,输入yes就好。
现在就可以使用yum来安装nginx啦~~~

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

现在就可以在你的浏览器里输入你的服务器的IP地址了,查看nginx是否正常启动了
QQ图片20160531213546.png

五、安装mysql

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
# 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密码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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

1

# 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模式

1
2
3
# 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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# 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

1
# vim /etc/php.ini

重启nginx,php-fpm

1
2
3
4
5
6
# service nginx restart
Stopping nginx:                                            [  OK  ]
Starting nginx:                                            [  OK  ]
# service php-fpm restart
Stopping php-fpm:                                          [  OK  ]
Starting php-fpm:                                          [  OK  ]

建立info.php文件

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

测试nginx是否解析php,在浏览器输入:192.168.1.104/info.php
显示php界面,环境搭建成功
123.png


环境已经搭建成功了,现在到了激动的时候了!安装Wordpress!!!

安装Wordpress

首先从官网上下载安装包

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

安装包下好之后,把它mv到nginx默认路径下。

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

然后将安装包解压,把解压出来的目录里的文件放到/usr/share/nginx/html/

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

然后,打开浏览器,输入服务器的IP地址,就会显示安装wordpress界面
2.png

为wordpress创建数据库和用户

1
2
3
4
5
6
7
8
9
10
# 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文件,将数据库和用户名及密码填入进去即可。

1
2
3
4
5
6
7
8
9
10
# 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

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

返回浏览器,点击现在安装之后,跳出如下界面
blog.png

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

点击登陆之后,就到了登陆界面啦~~~大功告成!满满的成就感有木有!

性能优化:

实际使用中必须对一下文件作出修改 建议值为以下建议值 要不然实际使用过程中问题很大

nginx.conf    优化和上传的限制

worker_processes  8;    
events {
use epoll;
worker_connections 65535;
}       
http {
include   mime.types;
default_type  application/octet-stream; 
client_max_body_size 100m;
client_header_buffer_size 128k;
large_client_header_buffers 4 128k;
sendfileon;
tcp_nopush on;
tcp_nodelay   on;
keepalive_timeout  65;
include /etc/nginx/vhost/*;
gzip  on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;

php.ini         上传文件的限制

post_max_size = 20m
upload_max_filesize = 20M
max_file_uploads = 200

wp-config.php   解决无法定位文件的问题

/** Override default file permissions */
if(is_admin()) {
add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );
}

chmod -R 0755 你的FTP文件夹

vsftpd.conf  注意此配置文件中结尾处不能有空格

pam_service_name=vsftpd
userlist_enable=YES
chroot_list_enable=YES
ascii_upload_enable=YES
ascii_download_enable=YES
tcp_wrappers=YES
guest_enable=YES
guest_username=ftp
user_config_dir=/etc/vsftpd/vuser_conf
pasv_enable=YES
pasv_min_port=40000
pasv_max_port=40080
pasv_promiscuous=YES

vuser_passwd.txt  奇数行用户名偶数行密码

lethe
1234567890
xiaohei
1234567890

vuserconf/lethe

local_root=/data/web/wwwroot/www.lethe.com.cn/
write_enable=YES
anon_umask=022
anon_world_readable_only=NO
anon_upload_enable=YES
anon_mkdir_write_enable=YES
anon_other_write_enable=YES

原创文章,作者:wencx,如若转载,请注明出处:http://www.178linux.com/41905

(1)
wencxwencx
上一篇 2016-08-30
下一篇 2016-08-30

相关推荐

  • 趣文:一根网线发起的攻击

    原文出处: EtherDream 的博客(@EtherDream)   刚上大学没多久,就遇到件头疼事。 富二代们刚来就带着笔记本电脑,这让咱们只能玩手机的屌丝辈们羡慕嫉妒恨。要命的事来了,晚上断电不断网,于是熄灯后笔记本仍然可以玩。 不巧的是,我们寝室也有个。常常熄灯后,非得把电池用干净才罢休。边游戏边语音,还放着音乐,备受煎…

    2015-03-26
  • sed的基本用法详解

    在Linux的世界中,有着一个文本三剑客的称呼,它们分别代表grep(文本过滤),sed(流编辑器),awk(gawk)(报告生成器)。 它们是强大的文本处理工具,了解并掌握它们,可以让你对文本的处理更加从容和轻松。 今天我们主要是围绕sed来进行分析。 一、初识sed sed:Stream Editor 从名字上也可以直观的了解到它是一个流编辑工具。何为流…

    Linux干货 2015-06-08
  • 老王的心路历程:那个做了五年的产品经理

    前言: 老王的五年产品经理心路历程,对拍脑袋式产品决策的反思,及如何建立产品用户体验监控体系。 我从2003年”误入“运维软件行业,并在2010年开始做产品经理,5年来,我始终和优秀的团队在一起,从零开始创造了ITSM、CMDB产品,并得到了很多用户的认可。但不怕大家笑话,这5年中,我内心其实无比的纠结。面对产品的历次迭代,一方面要做出对用户有价值的功能,要…

    Linux资讯 2016-08-05
  • C++的std::string的“读时也拷贝”技术!

    C++的std::string的读时也拷贝技术! 嘿嘿,你没有看错,我也没有写错,是读时也拷贝技术。什么?我的错,你之前听说写过时才拷贝,嗯,不错的确有这门技术,英文是Copy On Write,简写就是COW,非常’牛’!那么我们就来看看这个’牛’技术的效果吧。 我们先编写一段程序 #include <string> #include…

    Linux干货 2015-04-03
  • 【福利贴-招聘】- 高级运维工程师 18k+

    范围: 18k+  职位: 高级运维工程师 要求: 大公司背景,电商尤佳         能干活,能干好活 优点: 可内推 公司: 饿了么 范围: 面议 职位: 运维开发 优点: 可内推 要求:编程基础好 范围: 面议 优点: 可内推 职位: 系统运维 联系人:  stanley…

    Linux职位 2015-03-06
  • Linux发展史

    一、从 Unix 到 Linux 这一段历史         早在 Linux 出现之前的二十年 ( 大约在 1970 年代 , 就有一个相当稳定而成熟的操作系统存在了!那就是 Linux 的老大哥『 Unix 』是也!怎么这么说呢?!他们这两个家伙有什么关系呀?这里就给他说一说啰!众所皆知的,Linux 的核心是由 …

    Linux干货 2016-10-14

评论列表(1条)

  • 马哥教育
    马哥教育 2016-09-01 12:03

    看完博客会有一个概览性的认识,但在逻辑表达的组织上显得略微混乱,如果能再优化下逻辑规划会更让人印象深刻