创建CentOS 7 VM& Update

sudo -i

yum update -y
yum install epel-释放yum-utils -y
yum清洁安装

Install Nginx

yum安装nginx -y
服务nginx开始
*浏览器到VM的Public IP进行测试
sudo systemctl启用nginx
sudo systemctl启动nginx

Install MariaDB

yum安装mariadb-server -y
服务MariaDB开始
mysql_secure_installation.

然而,MariaDB会向您询问root密码,因为这是初始安装,因此您没有任何内容,只需按Enter键。下一个提示将询问您是否要设置root密码,请输入y并按照说明操作:

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorization.

New password: password
Re-enter new password: password
Password updated successfully!
Reloading privilege tables..
 ... Success!

您可以安全地单击“输入密钥”并接受所有其他问题的默认设置。完成设置后,请继续进一步到PHP安装。

创建WordPress DB.

mysql -u root -p
CREATE DATABASE wordpress;
CREATE USER wordpressuser@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
exit

Install PHP7.2

sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm


rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
sudo yum安装yum-utils -y

sudo yum-config-manager -enable remi-php72
sudo yum安装php-cli php-fpm php-mysql php-json php-opcache php-mbstring php-xml php-gd php-curl
Configure PHP 7通过修改PHP的配置文件。确保取消注释&更改; cgi.fix_pathinfo = 1到cgi.fix_pathinfo = 0。
# vi /etc/php.ini
cgi.fix_pathinfo=0
Openphp-fpm配置文件和modify线条与下面相同的线条。
# vi /etc/php-fpm.d/www.conf
user = nginx
group = nginx

listen = /var/run/php-fpm/php-fpm.sock
 
listen.owner = nginx
listen.group = nginx

服务PHP-FPM重新启动

sudo systemctl启用php-fpm
sudo systemctl启动php-fpm

回声“” >phpversion.php.

注意:PHP 7.1安装 - 已验证:

PHP7.3安装(未验证):

#先把php版本升级为7
yum安装php73-php-fpm php73-php-mysql

#安装nginx和mysql

# 启动PHP-FPM

systemctl启动php73-php-fpm
# 开机启动
SystemCtl启用PHP73-PHP-FPM
# 启动mysql
systemctl启动mysqld.

# 回车输入密码即可
mysql -u root -p
#创建名为Wordpress的数码
创建数据库WordPress;

#创建数据用词,wordpress,密码[电子邮件 protected]
grant all privileges on wp.* to ‘wordpress’@’%’ identified by ‘[电子邮件 protected]’;

# 刷新授权
齐平特权;

#下载更新版本的WordPress
#目录为/选择/申请
wget //cn.wordpress.org/latest-zh_CN.tar.gz
tar -xvf lo nal-zh_cn.tar.gz

# 用模板复制修改配置文件
cp wp-config-sample.php wp-config.php
#修改wp-config.php为如下
// ** mysql设置 - 具体信息来自于使用的手机** //
/ ** wordpress数码的名称* /
定义('db_name','wordpress');
/ ** mysql数据用名* /
定义('db_user','wordpress');
/ ** mysql数码库密码* /
定义('db_password','[电子邮件 protected]’ );
/** MySQL主机 */
定义('db_host','localhost');
/ **创建数码表时默认的文章编码* /
定义('db_charset','utf8');
/ **数码管理类型。如不确定请勿* /
定义('db_collat​​e',“);

#配置文章默认在/usr/local/nginx/conf/nginx.conf

server {
# 监听的端口
listen 80;
# 域名
server_name www.javashitang.com;
index index.html index.php;
# 访问日志目录
Access_log /var/log/nginx/blog_access.log main;
# 网站根目录
root / opt / application / wordpress;

location / {
根/数据/ www;
  }

位置〜\ .php $ {
  # php程序启动的端口
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param script_filename $ document_root $ fastcgi_script_name;
包括fastcgi_params;
  }
}

配置nginx.

Php7.2

在文件夹/ etc / nginx / sites下创建一个名为WordPress的新配置文件

sudo nano /etc/nginx/sites-available/wordpress



然后将下面的内容复制并粘贴到文件中并保存。代替example.com使用您自己的域名。您可能还希望在切换到域之前将WordPress网站的公共IP添加到ServerName列表中。

server {
    listen 80;
    listen [::]:80;
    root /var/www/html/wordpress;
    index  index.php index.html index.htm;
    server_name  54.32.104.91 51sec.org www.51sec.org;

     client_max_body_size 100M;

    location / {
        try_files $uri $uri/ /index.php?$args;        
    }

    location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass             unix:/var/run/php/php7.2-fpm.sock;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}

Php7.1

sudo vi /etc/nginx/conf.d/wordpress.conf.

server {
    listen   80;
    server_name  140.238.157.42 www.51sec.org 51sec.org;

    # note that these lines are originally from the "location /" block
    root   /var/www/html/wordpress;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }
    error_page 404 /404.html;
    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
        root /usr/share/nginx/html;
    }

    location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

安装WordPress

yum安装wget.
cd /tmp && wget //wordpress.org/latest.tar.gz
tar -zxvf notes.tar.gz.

sudo mv wordpress / var / www / html / wordpress

sudo chown -r nginx:/ var / www / html / wordpress
sudo chmod -r 755 / var / www / html / wordpress /
sudo mv /var/www/html/wordpress/wp-config-sample.php /var/www/html/wordpress/wp-config.php

配置WordPress

更改配置以连接到本地新的MariaDB服务器:

sudo nano /var/www/html/wordpress/wp-config.php


// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpressuser');

/** MySQL database password */
define('DB_PASSWORD', 'password1234');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

References

ByJonny

Leave a Reply