YUM LNMP 安装 wordpress

1配置防火墙

Iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允许80端口通过防火墙
iptables-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允许3306端口通过防火墙
service iptables save

2关闭SELINUX

Setgenfoce 0

vi /etc/selinux/config

#SELINUX=enforcing 
#SELINUXTYPE=targeted 
SELINUX=disabled

3卸载httpd php

yum remove httpd* php*

4安装并启动nginx

yum install nginx -y  #安装nginx 
chkconfig nginx on #设置nginx开机启动
service nginx start #启动nginx

5安装并启动mysql

yum install mysql mysql-server 
service mysqld start 
chkcongfig mysqld on
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

6为mysql设置密码

mysqladmin -uroot password mypassword

7为wordpress创建库

mysql -uroot -p mypassword

mysql>create database wordpress;
mysql>desc database;
mysql>Bye

8安装PHP

yum install -y php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt php php-fpm

9配置nginx

cp /etc/nginx/nginx.conf /etc/nginx/nginx.confbak
vi /etc/nginx/nginx.conf
   user nginx;

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;

cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.confbak
vi /etc/nginx/conf.d/default.conf

index index.php index.html index.htm; 
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
解决固定连接404问题
location / {
root   /usr/local/www/nginx;
index  index.php index.html index.htm;
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}

}

service nginx restart

10配置PHP

vi /etc/php.ini

date.timezone = PRC 
expose_php = Off 
short_open_tag = ON 
open_basedir = .:

post_max_size = 20m
upload_max_filesize = 20M
max_file_uploads = 200

11配置php-fpm

cp /etc/php-fpm.d/www.conf /etc/php-fpm.d/www.confbak
vi /etc/php-fpm.d/www.conf
   user = nginx
   group = nginx

cd /usr/share/nginx/html
vi index.php

<?php
phpinfo();
?>

访问你的网站/info.php测试

12安装wordpress

unzip wordpress-4.5.2-zh_CN.zip 
cd wordpress
cp -r ./* /usr/share/nginx/html/
cd /usr/share/nginx/html
cp wp-config-smaple.php wp-congfig.php
vi wp-config.php

define('DB_NAME', 'wordpress');

/** MySQL数据库用户名 */
define('DB_USER', 'root');

/** MySQL数据库密码 */
define('DB_PASSWORD', 'mypassword');

/** MySQL主机 */
define('DB_HOST', 'localhost');

/** 创建数据表时默认的文字编码 */
define('DB_CHARSET', 'utf8');

/** 数据库整理类型。如不确定请勿更改 */
define('DB_COLLATE', '');

13切换用户和权限

不做这步的话安装插件需要FTP服务
cd ../ 
chown -R html/*
chmod 755 html/* -R
或者也可以编辑wp-config.php
/** Override default file permissions */
if(is_admin()) {
add_filter('filesystem_method', create_function('$a', 'return "direct";' ));
define( 'FS_CHMOD_DIR', 0751 );
}

14访问你的网站/wp-admin按提示安装

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

(0)
双庆 李双庆 李
上一篇 2016-06-22 15:49
下一篇 2016-06-22 16:15

相关推荐

  • 双主模型的Nginx高可用负载均衡集群

    实验目的:使用keepalived实现Nginx的双主高可用负载均衡集群 实验环境:两台Nginx proxy(双主Nginx,各需要两块网卡,eth0连接内网,eth1连接外网)、两台web server(请求的负载均衡)、一台client用于验证结果。 注意:为了不影响实验结果,在实验开始前先关闭iptables和selinux 操作步骤: 一、配置IP…

    2017-05-13
  • nginx实现代理服务器功能

    nginx实现代理服务器功能1: #环境: 172.16.253.223 #CentOS7.3,安装nginx作为代理服务器 172.16.253.224 #CentOS7.3,安装httpd作为服务器 172.16.253.188 #CentOS6.8,咱庄httpd作为图片服务器 #223主机: yum install nginx vim /etc/ng…

    Linux干货 2017-06-28
  • 脚本编程部分_第十周练习

    Q1:写一个脚本: (1) 能接受四个参数:start, stop, restart, status;start: 输出“starting 脚本名 finished.”其余参数类似; (2) 其它任意参数,均报错退出; #!/bin/bash # read -p "The following choices&…

    Linux干货 2017-01-01
  • yum命令的使用及磁盘管理中命令的使用方法(mkfs ,blkid,e2label等)

    yum      #cd /etc/yum.repos.d          #yum repolist(在 #cd下)其他命令在 #cd /etc/yum.repos.d运行          #yum-config-manag…

    2017-08-19
  • 初入Linux世界 —马哥教育网络班N22_第二周课程练习

    一、Linux上的文件管理类命令都有哪些,其常用的使用方法及其相关示例演示。        Linux上的文件管理有三个:cp, mv, rm     1、cp命令:copy             源文件;目标文件;   &nb…

    Linux干货 2016-08-22
  • iptables练习

    iptables练习 一、COMMAND 1、列出所有链的规则:iptables -L ,显示某条链的规则就是iptables -L INPUT 详细信息:iptables -vnL 2、清楚所有链的规则 :iptables -F 3、设置默认规则策略:iptables -P INPUT DROP,iptables -P OUTPUT DROP , ipta…

    Linux干货 2016-12-20