LNMP搭建wordprees

一.关闭防火墙和SElinux

systemctl stop firewalld.service 
setenforce 0 

二.创建/data/server用于存放解析后的文件:

mkdir /data/server

LNMP搭建wordprees

三.源码安装nginx
下载NGINX并解压:

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

LNMP搭建wordprees
下载依赖包:

yum install openssl openssl-devel zlib zlib-devel pcre pcre-devel gcc gcc-c++ -y

LNMP搭建wordprees
进到目录下:

cd /usr/local/src/nginx-1.16.0

编译安装:

./configure  --prefix=/data/server/nginx   #(编译安装的路径,将服务都放在/data/server下)

make && nake install

LNMP搭建wordprees
LNMP搭建wordprees
进到编译好的NGINX下,启动NGINX

cd /data/server/nginx/sbin
./nginx

LNMP搭建wordprees
查看自己IP

ifconfig

在浏览器中输入查到的IP
LNMP搭建wordprees
NGINX编译完成

四.源码安装mysql
下载源码包
LNMP搭建wordprees
解压

unzip AliSQL-AliSQL-5.6.32-9.zip

LNMP搭建wordprees
下载依赖环境包:

yum -y install cmake bison git ncurses-devel gcc gcc-c++

LNMP搭建wordprees
添加用户:
groupadd mysql
useradd -g mysql mysql
安装perl然后解压:

wget http://repo.openfusion.net/centos7-x86_64//perl-Data-Dumper-2.154-1.of.el7.x86_64.rpm
rpm -ivh http://repo.openfusion.net/centos7-x86_64//perl-Data-Dumper-2.154-1.of.el7.x86_64.rpm

LNMP搭建wordprees
进到解压好的目录中

cd AliSQL-AliSQL-5.6.32-9/

然后进行编译安装:

cmake -DCMAKE_INSTALL_PREFIX=/data/server/mysql -DMYSQL_UNIX_ADDR=/data/server/mysql/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/data/server/mysql/data -DMYSQL_TCP_PORT=3306 -DMYSQL_USER=mysql -DENABLE_DOWNLOADS=1
make && make install 

LNMP搭建wordprees
修改目录主权限:

chown -R mysql:mysql /data/server/mysql

复制文件给权限:

cd /data/server/mysql  
cp support-files/my-default.cnf  ./my.cnf 
chown -R  mysql:mysql my.cnf

配置文件

vim my.cnf 
    basedir = /data/server/mysql
    datadir = /data/server/mysql/data
    socket = /data/server/mysql/mysql.sock
    log-error= /data/server/mysql/data/error.log
    pid-file = /data/server/mysql/data/mysql.pid
    user = mysql
    tmpdir = /tmp

LNMP搭建wordprees

数据库初始化

scripts/mysql_install_db  --defaults-file=./my.cnf --user=mysql 

LNMP搭建wordprees
启动数据库

support-files/mysql.server   start  

LNMP搭建wordprees

启动数据库报错PID解决办法:

    rm -rf /etc/my.cnf
    rm -rf my.conf
    cd data
    rm -rf *
    cd ..
    scripts/mysql_install_db  --defaults-file=./my.cnf --user=mysql 
    cd support-files/
    ./mysql.server start
    cd ..
    cd bin

重新启动数据库:

./mysql -uroot -p 

LNMP搭建wordprees
创建数据库:

    >create database wordpress;
    >grant all on wordpress.* to wordpress@'localhost' identified by'123456';
    >flush privileges;
    >exit

LNMP搭建wordprees

mysql安装完毕。
五.源码安装PHP:
添加用户:

groupadd www
useradd -g www -s /sbin/nologin -M www

LNMP搭建wordprees
安装依赖的程序包:
yum install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel openssl openssl-devel libxslt-devel -y
LNMP搭建wordprees
安装 libiconv,解压:

wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz
tar zxf libiconv-1.15.tar.gz

LNMP搭建wordprees
进入到libiconf文件下

cd libiconv-1.15

编译libiconv

./configure --prefix=/data/server/libiconv
make && make install

LNMP搭建wordprees
LNMP搭建wordprees

下载并解压PHP:

tar -zxvf php-5.6.32.tar.gz

LNMP搭建wordprees

进到php-5.6.30文件下

cd /data/server/php-5.6.30

编译

./configure \
--prefix=/data/server/php \
--enable-fpm \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-openssl \
--with-zlib \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-iconv=/data/server/libiconv \
--enable-short-tags \
--enable-sockets \
--enable-zend-multibyte \
--enable-soap \
--enable-mbstring \
--enable-static \
--with-curl \
--enable-ftp \
--with-libxml-dir
make && make install 

LNMP搭建wordprees
LNMP搭建wordprees
php.ini配置

cp php.ini-development /data/server/php/lib/php.ini

php-fpm配置:

cp -R ./sapi/fpm/php-fpm.conf /data/server/php/etc/php-fpm.conf

将php给我们准备好的init.d.php-fpm备份

cp ./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

将php-fpm服务添加到chkconfig列表

chkconfig --add php-fpm

设置开机自启动

chkconfig php-fpm on

启动服务

service php-fpm start

在这里会报错:Permission Denied

vim /etc/profile    #(在末尾加)
PATH=$PATH:$HOME/bin:/data/server/php56/bin

LNMP搭建wordprees

source /etc/profile     #(使环境生效)

设置开机自启动

chkconfig --add php-fpm

加权限

chkconfig php-fpm on

启动php-fpm

service php-fpm start

LNMP搭建wordprees
更改配置文件:

vim /data/server/nginx/conf/nginx.conf
将user 前面注释去掉  并将nobady改成www www

LNMP搭建wordprees
在server/location模块下的index栏下 加一个 index.php

![](https://s1.51cto.com/images/blog/201908/09/314bd443ebe1d4f5cd2d670458248004.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
 将location ~ \.php$ 模块注释去掉 并/scripts改成$document_root

LNMP搭建wordprees
去到html目录下
cd /data/server/nginx/html
添加test.php文件
vim test.php
<?php phpinfo() ; ?

LNMP搭建wordprees
进到nginx运行目录
cd /data/server/nginx/sbin
重读nginx
./nginx -s reload
在浏览器里输入 ip/test.php

LNMP搭建wordprees
PHP搭建完毕
六.搭建 wordpress
下载wordpress并解压
wget https://cn.wordpress.org/wordpress-4.9.4-zh_CN.tar.gz
tar -zxvf wordpress-4.9.4-zh_CN.tar.gz
LNMP搭建wordprees
将wordpress文件复制到网页目录下
cp -r wordpress /data/server/nginx/html
修改Wordpress配置文件
cd /data/server/nginx/html/wordpress
拷贝配置文件
cp -r wp-config-sample.php wp-config.php
修改wp-config.php
vim wp-config.php
在其中修改
数据库名字、账号、密码(这里修改的是mysql中创建的数据库名字、用户、密码)
再将主机改成127.0.0.1(设置自己可以访问)
LNMP搭建wordprees
LNMP搭建wordprees
LNMP搭建wordprees
LNMP搭建wordprees

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值