LNMP搭建wordprees

一.關閉防火牆和SElinuxphp

systemctl stop firewalld.service 
setenforce 0

二.建立/data/server用於存放解析後的文件:html

mkdir /data/server

LNMP搭建wordprees

三.源碼安裝nginx
下載NGINX並解壓:mysql

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

LNMP搭建wordprees
下載依賴包:linux

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

LNMP搭建wordprees
進到目錄下:nginx

cd /usr/local/src/nginx-1.16.0

編譯安裝:c++

./configure  --prefix=/data/server/nginx   #(編譯安裝的路徑,將服務都放在/data/server下)

make && nake install

LNMP搭建wordprees
LNMP搭建wordprees
進到編譯好的NGINX下,啓動NGINXgit

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

LNMP搭建wordprees
查看本身IPsql

ifconfig

在瀏覽器中輸入查到的IP
LNMP搭建wordprees
NGINX編譯完成數據庫

四.源碼安裝mysql
下載源碼包
LNMP搭建wordprees
解壓vim

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

相關文章
相關標籤/搜索