wordpress博客搭建过程

        准备需要得安装包,也可以直接下载安装,存放路径这里统一放在/server/tools,没有目录就创建一个

nginx-1.16.0.tar.gz 、   mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz 、   php-7.3.5.tar.gz   、  libiconv-1.16.tar.gz、    wordpress-5.1.1.zip

nginx安装

1、安装

yum install nginx -y

2、查看版本信息

[root@web01 ~]# rpm -qa nginx

nginx-1.16.0-1.el7.ngx.x86_64

3、开启开机自启

[root@web01 ~]# systemctl start nginx

[root@web01 ~]# systemctl enable nginx

[root@web01 ~]# systemctl status nginx

[root@web01 ~]# netstat -lntup|grep nginx     ##  这个是查看端口

4、配置官方yum源

[root@web ~]# vim /etc/yum.repos.d/nginx.repo

[nginx]

name=nginx repo

baseurl=http://nginx.org/packages/centos/7/$basearch/

gpgcheck=0

enabled=1

5、创建安装包存放路径

mkdir -p /server/tools

cd /server/tools

6、下载nginx包,有的可以不用

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

7、安装依赖包

yum install pcre pcre-devel -y

yum install openssl openssl-devel -y  #https加密用他。

8、解压nginx包,创建用户

tar xf nginx-1.16.0.tar.gz

cd nginx-1.16.0/

useradd -s /sbin/nologin nginx -M  -u 1111

id www

9、编译安装

./configure --user=www --group=www --prefix=/application/nginx-1.16.0/ --with-http_stub_status_module --with-http_ssl_module --with-pcre

10、编译安装&&编译软件

make && make install

11、创建软链接

ln -s /application/nginx-1.16.0/ /application/nginx

12、执行

/application/nginx/sbin/nginx

13、简化配置文件

[root@web02 ~]# cd /application/nginx/conf/

[root@web02 /application/nginx/conf]# egrep -v "^$|#" nginx.conf.default >nginx.conf

[root@web02 /application/nginx/conf]# cat -n nginx.conf

     worker_processes  1;

      user  nginx nginx;

     events {

     worker_connections  1024;

     }

     http {

         include      mime.types;

         default_type  application/octet-stream;

         sendfile        on;

         keepalive_timeout  65;

         server {

             listen      80;

             server_name  www.etiantian.org;

             location / {

                 root  html/www;

                 index  index.html index.htm;        

             }

            location ~ .*\.(php|php5)?$ {

            root html/www;

            fastcgi_pass  127.0.0.1:9000;

            fastcgi_index index.php;

            include fastcgi.conf;

         }


14、把自己得IP+域名 添加到 /etc/hosts 文件中

echo "10.0.0.51 www.etiantian.org" >>/etc/hosts

15、配置环境变量,测试本地域名

[root@web02 /application/nginx/conf]# echo 'PATH="/application/nginx/sbin:$PATH"' >>/etc/profile

[root@web02 /application/nginx/conf]# . /etc/profile

[root@web02 /application/nginx/conf]# echo $PATH

[root@web02 /application/nginx/conf]# nginx -t

[root@web02 /application/nginx/conf]# nginx -s reload

[root@web02 /application/nginx/conf]# curl www.etiantian.org

安装MySQL

1、创建用户

[root@web02 ~]# useradd mysql -s /sbin/nologin -M

[root@web02 ~]# id mysql

2、解压mysql安装包

[root@web02 ~]# cd /server/tools/

[root@web02 /server/tools]# tar xf mysql-5.7.26-linux-glibc2.12-x86_64.tar.gz

3、把解压好得转一下目录,在创建软链接

[root@web02 /server/tools]# mv mysql-5.7.26-linux-glibc2.12-x86_64 /application/mysql-5.7.26

[root@web02 /server/tools]# ln -s /application/mysql-5.7.26/  /application/mysql

4、配置/etc/my.cnf

[root@web02 ~]# cat /etc/my.cnf

[mysqld]

basedir = /application/mysql/

datadir = /application/mysql/data

socket = /tmp/mysql.sock

server_id = 1

port = 3306

log_error = /application/mysql/data/oldboy_mysql.err

[mysql]

socket = /tmp/mysql.sock

prompt = oldboy [\\d]>

5、卸载依赖包

rpm -e --nodeps mariadb-libs

6、安装libaio-devel包

yum install libaio-devel -y

7、创建目录,指定用户

[root@web02 /server/tools]# mkdir -p /application/mysql/data

[root@web02 /server/tools]# chown -R mysql.mysql /application/mysql/

8、编译目录

/application/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/application/mysql/ --datadir=/application/mysql/data

9、配置启动服务

[root@web02 /application/mysql/support-files]# cat /etc/systemd/system/mysqld.service

[Unit]

Description=MySQL Server by oldboy

Documentation=man:mysqld(8)

Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html

After=network.target

After=syslog.target

[Install]

WantedBy=multi-user.target

[Service]

User=mysql

Group=mysql

ExecStart=/application/mysql/bin/mysqld --defaults-file=/etc/my.cnf

LimitNOFILE = 5000

10、启动服务

systemctl start mysqld

systemctl enable mysqld

systemctl status mysqld

11、查看进程

[root@web02 /application/mysql/support-files]# netstat -lntup|grep mysql

12、配置环境变量登陆

[root@web02 /application/mysql/support-files]# echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile

[root@web02 /application/mysql/support-files]# tail -1 /etc/profile

[root@web02 /application/mysql/support-files]# . /etc/profile

[root@web02 /application/mysql/support-files]# echo $PATH

13、登陆数据库

[root@web02 /application/mysql/support-files]# mysql

Welcome to the MySQL monitor.  Commands end with ; or \g.

Your MySQL connection id is 2

Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

oldboy [(none)]>

成功登录。

oldboy [(none)]>quit

Bye

14、修改密码及登陆方式

[root@web02 ~]# mysqladmin -u root password '自定义'  ###设定密码

[root@web02 ~]# mysql -uroot -p     ####登陆

Enter password:  输入密码

安装PHP

1、安装PHP调用的库

yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel -y

yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y

2、解压

cd /server/tools/

tar zxf libiconv-1.16.tar.gz

tar xf php-7.3.5.tar.gz

cd libiconv-1.16

3、编译

./configure --prefix=/application/libiconv

make && make install

4、安装依赖包

yum install libmcrypt-devel -y

yum install mhash -y

yum install mcrypt -y

5、进行编译安装

cd /server/tools/php-7.3.5/

./configure \

--prefix=/application/php-7.3.5 \

--enable-mysqlnd  \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-iconv-dir=/application/libiconv \

--with-freetype-dir \

--with-jpeg-dir \

--with-png-dir \

--with-zlib \

--with-libxml-dir=/usr \

--enable-xml \

--disable-rpath \

--enable-bcmath \

--enable-shmop \

--enable-sysvsem \

--enable-inline-optimization \

--with-curl \

--enable-mbregex \

--enable-fpm \

--enable-mbstring \

--with-gd \

--with-openssl \

--with-mhash \

--enable-pcntl \

--enable-sockets \

--with-xmlrpc \

--enable-soap \

--enable-short-tags \

--enable-static \

--with-xsl \

--with-fpm-user=nginx \

--with-fpm-group=nginx \

--enable-ftp \

--enable-opcache=no

make && make install

7、将nginx的用户和PHP的用户统一:nginx

[root@web02 /server/tools/php-7.3.5]# vim /application/nginx/conf/nginx.conf

worker_processes  1;

user  nginx nginx;   ####添加这一行信息

8、给php-7.3.5创建软链接

[root@web02 ~]# ln -s /application/php-7.3.5/ /application/php

[root@web02 ~]# ls /application/php/

9、配置php.ini(PHP解析器配置文件)

root@web02 /application/php]# cd /server/tools/php-7.3.5/

[root@web02 /server/tools/php-7.3.5]# ls php.ini-*

[root@web02 /server/tools/php-7.3.5]# cp php.ini-development /application/php/lib/php.ini

[root@web02 /server/tools/php-7.3.5]# ls -l /application/php/lib/php.ini

10、配置PHP FPM

[root@web02 /server/tools/php-7.3.5]# cd /application/php/etc/

[root@web02 /application/php/etc]# cp php-fpm.conf.default php-fpm.conf

[root@web02 /application/php/etc]# cd php-fpm.d/

[root@web02 /application/php/etc/php-fpm.d]# ls

www.conf.default

[root@web02 /application/php/etc/php-fpm.d]# cp www.conf.default www.conf

11、启动PHP服务

[root@web02 /application/php/etc/php-fpm.d]# /application/php/sbin/php-fpm

[root@web02 /application/php/etc/php-fpm.d]# netstat -lntup|grep php-fpm    ###查进程

12、开机自启

[root@web02 /application/php/etc/php-fpm.d]# tail -2 /etc/rc.local

/application/nginx/sbin/nginx

/application/php/sbin/php-fpm

13、配置nginx转发PHP请求

location ~ .*\.(php|php5)?$ {

            root html/blog;

            fastcgi_pass  127.0.0.1:9000;

            fastcgi_index index.php;

            include fastcgi.conf;

        }

以上内容已添加到nginx.conf中

14、测试nginx链接 PHP

[root@web02 /application/nginx/conf]# echo "" > ../html/blog/test_info.php

15、启动文件

[root@web02 /application/nginx/conf]# /application/php/bin/php  /application/nginx/html/blog/test_info.php

安装BLOG

1、确认环境

[root@web02 ~]# netstat -lntup|egrep "80|3306|9000"

2、解压

[root@web02 ~]# cd /server/tools/

[root@web02 /server/tools]# unzip wordpress-5.1.1.zip

3、移动目录,并指定属组

[root@web02 /server/tools]# mv wordpress/* /application/nginx/html/blog/

[root@web02 /server/tools]# chown -R nginx.nginx /application/nginx/html/blog/ (暂时性)

[root@web02 /server/tools]# ls -ld /application/nginx/html/blog/

你可能感兴趣的:(wordpress博客搭建过程)