您的位置:首页 > 其它

博客和内容管理系统WordPress手动安装指南

2017-02-16 17:20 615 查看

安装MariaDB

下载解压

wget https://downloads.mariadb.org/interstitial/mariadb-10.1.21/bintar-linux-glibc_214-x86_64/mariadb-10.1.21-linux-glibc_214-x86_64.tar.gz

tar -zxvf mariadb-10.1.21-linux-glibc_214-x86_64.tar.gz

增加linux用户

添加用户MarsZhang

adduser MarsZhang

赋予root权限

修改 /etc/sudoers 文件,找到下面一行

Allows people in group wheel to run all commands(这行是注释)

这行下面应该就是

root ALL=(ALL) ALL,在下面添加一行

MarsZhang ALL=(ALL) ALL 其中tommy是你要加入的用户名称

这个文件需要强行保存退出,命令如下

:w !sudo tee %

将其加入root组

usermod -g root MarsZhang

设置密码

passwd MarsZhang 输入这个用户的密码

配置MariaDB

参考链接 https://mariadb.com/kb/zh-cn/installing-mariadb-alongside-mysql/

配置数据文件所在的目录

我这里将其放在了/home/MarsZhang/mariadb-data 目录下

拷贝原始的配置文件,support-files就在原始的解压目录下

cp support-files/my-medium.cnf /home/MarsZhang/mariadb-data/my.cnf

如果是root用户进行这个拷贝操作,还需要修改拥有者

chown MarsZhang:pwd mariadb-data/my.cnf

修改my.cnf文件,主要修改就socket和datadir和basedir以及user

# The following options will be passed to all MariaDB clients

[client]

#password = your_password

port = 3306

socket = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MariaDB server

[mysqld]

datadir = /home/MarsZhang/mariadb-data

basedir = /home/MarsZhang/my1/mariadb-10.1.21-linux-glibc_214-x86_64

user = MarsZhang

port = 3306

socket = /tmp/mysql.sock

skip-external-locking

key_buffer_size = 16M

max_allowed_packet = 1M

table_open_cache = 64

sort_buffer_size = 512K

net_buffer_length = 8K

read_buffer_size = 256K

read_rnd_buffer_size = 512K

myisam_sort_buffer_size = 8M

修改启动脚本support-files/mysql.server

basedir=/home/MarsZhang/my1/mariadb-10.1.21-linux-glibc_214-x86_64(根据实际解压目录替换)

datadir=/home/MarsZhang/mariadb-data

寻找$bindir/mysqld_safe,在之后添加(别的啥都不动) –defaults-file=/home/MarsZhang/mariadb-data/my.cnf

运行命令

scripts/mysql_install_db −−defaults-file=/home/MarsZhang/mariadb-data/my.cnf

启动停止数据库

support-files/mysql.server start

support-files/mysql.server stop

安全配置

bin/mysql_secure_installation −−basedir=./ −−socket=/tmp/mysql.sock

第一次启动的时候root密码为空

设置远程访问

进入数据库

bin/mysql -u root -p −−socket=/tmp/mysql.sock

这时候出现MariaDB [(none)]> 类似的提示符,输入

grant all privileges on . to MarsZhang@’%’ identified by ‘yourpassword’;

并让其立即生效

flush privileges;

解释:

all PRIVILEGES 表示赋予所有的权限给指定用户,这里也可以替换为赋予某一具体的权限,例如:select,insert,update,delete,create,drop 等,具体权限间用“,”半角逗号分隔

.表示权限是作用于哪个数据库哪个表的,.表示所有数据库的所有表,格式为:数据库名.表名,*表示所有。

MarsZhang表示你授权的用户名,该用户可存在可不存在

‘%’表示所有ip,也可以是特定的ip

‘yourpassword’是访问的密码。

安装Nginx

安装pcre

wget https://svwh.dl.sourceforge.net/project/pcre/pcre/8.40/pcre-8.40.zip ./configure --enable-utf8
make
make install


安装openssl

wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2j.tar.gz 下面是php需要(--with-openssl=/usr/local/ssl)
./Configure
./config
make
make install


安装zlib

wget https://superb-dca2.dl.sourceforge.net/project/libpng/zlib/1.2.11/zlib-1.2.11.tar.gz ./configure
make
make install


安装nginx

下载nginx rtmp和nginx

wget https://github.com/arut/nginx-rtmp-module/archive/master.zip

wget http://nginx.org/download/nginx-1.10.3.tar.gz

编译

./configure −−add-module=/home/MarsZhang/my1/nginx-rtmp/nginx-rtmp-module-master –with-openssl=/home/MarsZhang/my1/openssl-1.0.2j

最终位置如下

Configuration summary

using system PCRE library

using OpenSSL library: /usr/local/ssl

md5: using OpenSSL library

sha1: using OpenSSL library

using system zlib library

nginx path prefix: “/usr/local/nginx”

nginx binary file: “/usr/local/nginx/sbin/nginx”

nginx modules path: “/usr/local/nginx/modules”

nginx configuration prefix: “/usr/local/nginx/conf”

nginx configuration file: “/usr/local/nginx/conf/nginx.conf”

nginx pid file: “/usr/local/nginx/logs/nginx.pid”

nginx error log file: “/usr/local/nginx/logs/error.log”

nginx http access log file: “/usr/local/nginx/logs/access.log”

nginx http client request body temporary files: “client_body_temp”

nginx http proxy temporary files: “proxy_temp”

nginx http fastcgi temporary files: “fastcgi_temp”

nginx http uwsgi temporary files: “uwsgi_temp”

nginx http scgi temporary files: “scgi_temp”

创建用户和组

创建nginxgroup组,在该组内创建nginxuser用户,不准登陆,也不生成该用户的目录

groupadd nginxgroup

useradd nginxuser -g nginxgroup -s /sbin/nologin -M

chown -R nginxuser:nginxgroup /usr/local/nginx/html

修改/usr/local/nginx/conf/nginx.conf文件,首行添加

user nginxuser nginxgroup;

运行测试

sbin/nginx -v 查看版本

sbin/nginx -t 查看配置是否正确

/usr/local/nginx/sbin/nginx 启动

/usr/local/nginx/sbin/nginx -s reload # 重新载入配置文件

/usr/local/nginx/sbin/nginx -s reopen # 重启 Nginx

/usr/local/nginx/sbin/nginx -s stop # 停止 Nginx

安装Php

yum search bzip2
yum install bzip2-libs.x86_64
yum install bzip2-devel.x86_64
yum install libcurl-devel
yum install libpng-devel
wget http://cn2.php.net/distributions/php-7.1.1.tar.gz ./configure --with-pdo-mysql=/home/MarsZhang/my1/mariadb-10.1.21-linux-glibc_214-x86_64 --with-mysqli=/home/MarsZhang/my1/mariadb-10.1.21-linux-glibc_214-x86_64/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-openssl=/usr/local/ssl --with-zlib --with-bz2 --with-curl --with-gd --enable-zip --enable-fpm --enable-opcache
make
sudo make install

说明


−−with-mysql[=DIR]:包含MySQL扩展,[=DIR]指定mysql安装目录,省略[=DIR]则为默认位置/usr

−−with-mysqli[=FILE]:包含MySQLI扩展,[=FILE]指定mysql_config文件位置,省略[=FILE]则为默认位置/usr/bin/mysql_config

−−with-pdo-mysql[=DIR]:包含PDO:MySQL扩展,[=DIR]指定mysql安装目录,省略[=DIR]则为默认位置/usr

−−with-apxs2[=FILE]:编译为Apahce2共享模块,[=FILE]指定apache2 apxs文件位置,省略[=FILE]则为默认位置/usr/sbin/apxs

2. 环境配置

- 拷贝

cp php.ini-production /usr/local/lib/php.ini

cp sapi/fpm/php-fpm /usr/local/bin

(有文档建议cp sapi/fpm/php-fpm /etc/init.d/php-fpm,但未采用)

cp /usr/local/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf

cp /usr/local/etc/php-fpm.d/www.conf.default /usr/local/etc/php-fpm.d/www.conf

具体环境配置可以用php -h看帮助 php –ini看实际php.ini需要的位置。php-fpm -t 看php-fpm.conf文件的具体位置

- 弄好日志文件的存储位置

cd /usr/local/var/log

mkdir php-fpmlog

chown -R nginxuser:nginxgroup php-fpmlog

- php-fpm只能够强杀,开启直接运行即可,强杀命令如下

ps -ef

kill -s 9 进程号

- 修改www.conf文件

user = nginxuser

group = nginxgroup

catch_workers_output = yes

php_flag[display_errors] = on //此项可以考虑不开

php_admin_value[error_log] = /usr/local/var/log/php-fpmlog/php-fpm.log

php_admin_flag[log_errors] = on

php-fpm.conf文件中添加

include=/usr/local/etc/php-fpm.d/*.conf

error_log = log/php-fpmlog/php-fpm.log

删除 [www]

删除 catch_workers_output = yes

php.ini文件修改如下

log_errors = On

error_log = “/usr/local/var/log/php-fpmlog/php-fpm.log”

error_reporting=E_ALL&~E_NOTICE

修改/usr/local/nginx/conf/nginx.conf文件

将index.html 改为index.php

放开php的对应配置项,并将其中的一项修改如下

fastcgi_param SCRIPT_FILENAME documentrootfastcgi_script_name;

在/usr/local/nginx/html下添加index.php.内容如下

<?php phpinfo(); ?>


安装WordPress

wget https://cn.wordpress.org/wordpress-4.7.2-zh_CN.tar.gz tar zxvf wordpress-4.7.2-zh_CN.tar.gz
cp -r /home/MarsZhang/my1/wordpress/ /usr/local/nginx/html/
mv wordpress blog
cd blog
mv wp-config-sample.php wp-config.php
根据中文提示,配置该文件
记得务必将该文件保存成ansi编码形式再上传,或者直接用英文版进行编辑以避免编码问题
chown -R nginxuser:nginxgroup /usr/local/nginx/html

输入域名/blog/index.php  开始著名的五分钟安装程序
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  wordpress