LNMP内网部署wiki

今天参考网上资料,我们学习一下内网搭建wiki

nginx+php:外网IP:192.168.1.132,内网IP:10.0.0.7

MySQL:内网IP10.0.0.8

LNMP内网部署wiki_第1张图片

软件包:

        HDWiki-v5.1UTF8-20141205.zip

        nginx-1.8.0.tar.gz 

        xcache-3.2.0.tar.gz

        mysql-5.5.46-linux2.6-x86_64.tar.gz 

        php-5.3.27.tar.bz2

1、配置双网卡环境

分别在两台虚拟机添加一张网卡vmnet2,分别配置eth1的网络IP为10.0.0.7和10.0.0.8

2、安装Nginx

2.1.同步两台主机的时间:ntpdate 202.120.2.101

2.2.安装依赖文件

yum -y install gcc gcc-c++

yum -y  install  pcre pcre-devel

yum -y install zlib zlib-devel

yum -y install openssl openssl-devel

2.3.解压Nginx文件并进行安装

tar xf nginx-VERSION.tar

cd  nginx-VERSION

groupadd -r nginx

useradd -r nginx -g nginx

./configure --prefix=/usr/local/nginx

--conf-path=/usr/local/nginx/conf/nginx/nginx.conf 

--user=nginx --group=nginx

--error-log-path=/var/log/nginx/error.log -

-http-log-path=/var/log/nginx/access.log

--pid-path=/var/run/nginx/nginx.pid

--lock-path=/var/log/nginx.lock

--with-http_ssl_module --with-http_stub_status_module

--with-http_gzip_static_module --with-http_flv_module

--with-http_mp4_module --http-client-body-temp-path=/var/tmp/nginx/client

--http-proxy-temp-path=/var/tmp/nginx/proxy --http-fastcgi-temp-path=/var/tmp/nginx/fastcgi

--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi

make -j 4 && make install

mkdir -pv /var/tmp/nginx/{client,proxy,fastcgi,uwsgi}

2.4.配置配置文件
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  wiki.edelweiss0.com;
        location / {
            root   html/wiki/;
            index  index.html index.htm index.php;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
        location ~ \.php$ {
            root           html/wiki;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            include        fastcgi.conf;
        }
    
   }
}
3.安装PHP

3.1设置epel

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm

或者:

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

wget -O /etc/yum.repos.d/CentOS-Base.repohttp://mirrors.aliyum.com/repo/CentOS-6.repo

yum clean all

yum makecache

3.2解决依赖关系

yum install zlib libxml libjpeg freetype libpng gd  curl  zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel openssl-devel libxslt-devel -y

wget http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make install

3.3编译安装PHP

tar -xf php-5.3.27.tar.bz2
cd php-5.3.27
./configure \
--prefix=/usr/local/php \
--enable-fpm \
--with-mysql=mysqlnd  \
--with-pdo-mysql=mysqlnd  \
--with-mysqli=mysqlnd  \
--with-xmlrpc \
--with-openssl \
--with-zlib \
--with-freetype-dir \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--with-iconv=/usr/local/libiconv \
--enable-short-tags \
--enable-sockets \
--enable-soap \
--enable-mbstring \
--enable-static \
--enable-gd-native-ttf \
--with-curl \
--with-xsl \
--enable-ftp \
--with-libxml-dir \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--with-config-file-path=/etc \
--with-config-file-scan-dir=/etc/php.d

make && make install

3.4为PHP提供配置文件。以fastcgi方式监听在9000端口

cp php.ini-production /etc/php.ini

cd /usr/local/php/

cp etc/php-fpm.conf.default  etc/php-fpm.conf

3.5安装和配置Xcache加速器

tar xf xcache-3.2.0.tar.gz

cd xcache-3.2.0

/usr/local/php/bin/phpize

./configure  --enable-xcache --with-php-config=/usr/local/php/bin/php-config

make && make install

mkdir /etc/php.d

cp xcache.ini  /etc/php.d/

vim /etc/php.d/xcache.ini

  extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/xcache.so

4.在另一台主机安装MySQL

4.1准备

mkdir  /data

cd tar -xf mysql-5.5.46-linux2.6-x86_64.tar.gz -C /usr/local

ln -sv /usr/local/mysql-5.5.46-linux2.6-x86_64 /usr/local/mysql

groupadd -g mysql mysql

cd /usr/local/mysql

4.2初始化数据库

chown -R mysql.mysql .

scripts/mysql_install_db  --user=mysql --datadir=/data/  --basedir=/user/lcoal/mysql

4.3提供配置文件和服务脚本

cp support-files/my-large.cnf /etc/my.cnf

vim /etc/my.cnf

      datadir=/data

  log-error=/data/mysql-err

cp support-files/mysql.server /etc/init.d/mysqld

service myslq start

ss -tnl | grep 3306

echo "PATH=/usr/local/mysql/bin:$PATH" > /etc/profile/mysql.sh

source /etc/profile/myslq.sh

4.4为站点提供数据库和用户

执行一下安全安装

bin/mysql_secure_installation

mysql> grant all on wiki.* to 'wiki'@'10.0.0.%'  identified by '123456';

mysql> flush privileges;


5.整合Nginx,PHP,MySQL

sbin/nginx -t

sbin/nginx

/usr/local/php/sbin/php-fpm


5.1测试Nginx和PHP

mkdir /usr/local/nginx/html/wiki

vim  /usr/local/nginx/html/wiki/index.php

       phpinfo();

?>

在浏览器登录192.168.1.132/index.php

5.2测试PHP和MySQL

vim /usr/local/nginx/html/wiki/index.php

       $link=mysql_connect('10.0.0.8','wiki','123456');

       if($link){

               echo "success";

       }else{

              echo "failure";

       }

?>

在浏览器登录192.168.1.132/index.php

5.4建站

unzip HDWiki-v5.1UTF8-20141205.zip

mv  HDWiki-v5.1UTF8-20121105/* /usr/local/nginx/html/wiki/

chown nginx.nginx -R /usr/local/nginx/

在浏览器登录192.168.1.132/hdwiki/install/install.php

完成后,在浏览器输入192.168.1.132/hdwiki/就可以登录主页


LNMP搭建成功。可以在此基础做扩展。








你可能感兴趣的:(Linux,LNMP实现内网Wiki)