搭建WordPress博客

环境:

os:

lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.4.1708 (Core)
Release: 7.4.1708
Codename: Core

查看是否安装有php

yum list |grep php

查看php版本

php -v

卸载旧版php

yum remove php

yum remove php*

安装php7

安装相关rpm
rpm -Uvh http://mirror.centos.org/centos/7/extras/x86_64/Packages/epel-release-7-9.noarch.rpm
rpm -Uvh http://repo.webtatic.com/yum/el7/x86_64/RPMS/webtatic-release-7-3.noarch.rpm
rpm -Uvh http://mirror.centos.org/centos/7/os/x86_64/Packages/centos-release-7-4.1708.el7.centos.x86_64.rpm

(RPM 可以到 https://pkgs.org/ 查找)

我安装的模块:

yum install php70w
yum install php70w-common
yum install php70w-fpm
yum install php70w-pdo
yum install php70w-xml
yum install php70w-mbstring

yum install php70w-mysql

安装nginx

yum install nginx

账号统一使用nginx

配置nginx
/etc/nginx/conf.d/ssl.afonddream.com.conf
/etc/nginx/cert #ssl 证书位置
user nginx;

http
#使用sock与php-fpm链接
# Upstream to abstract backend connection(s) for php
upstream php {
server unix:/dev/shm/php-cgi.sock;
# server 127.0.0.1:9000;
}

server {
listen 443;
server_name afonddream.com www.afonddream.com

##nginx日志不转化成ascii编码
log_escape_non_ascii off;

ssl on;

ssl_certificate cert/www.afonddream.com.pem;
ssl_certificate_key cert/www.afonddream.com.key;

ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;

root /www/wordpress-blog;
## This should be in your http block and if it is, it’s not needed here.
index index.php;

location = /favicon.ico {
log_not_found off;
access_log off;
}

location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}

location / {
# This is cool because no php is touched for static content.
# include the “?$args” part so non-default permalinks doesn’t break when using query string
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
#NOTE: You should have “cgi.fix_pathinfo = 0;” in php.ini
include fastcgi.conf;
fastcgi_intercept_errors on;
fastcgi_pass php;
}

location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}

配置php-fpm
/etc/php-fpm.d/www.conf
; RPM: apache Choosed to be able to access some dir as httpd
user = nginx
; RPM: Keep a group allowed to write in log dir.
group = nginx

;use socket instead of tcp
;listen = 127.0.0.1:9000
listen = /dev/shm/php-cgi.sock

listen.owner = nginx
listen.group = nginx

修改nginx 默认上传大小,默认是1M:
http{} 添加 client_max_body_size 20m 代表最大限制20M

修改php默认的文件上传大小,默认是是2M
; Maximum size of POST data that PHP will accept.
post_max_size = 20M

; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 20M

wordpress:5分钟安装教程

直接在服务器上修改wp-config.php ,填上你的数据库信息。确保防火墙和阿里云安全组已经开放相应的端口。http 80 https 443 .

然后浏览器访问:wp-admin/install.php 以便启动安装程序.

注意:
1使用相同的账号,避免权限问题,这里都是使用nginx

2低版本的php-pfm,可能不支持socket形式,与nginx连接

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.