LNMP內網部署wiki

今天參考網上資料,我們學習一下內網搭建wiki

nginx+php:外網IP:192.168.1.132,內網IP:10.0.0.7

MySQL:內網IP10.0.0.8


軟件包:

        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.配置配置文件
<span style="display: none; width: 0px; height: 0px;" id="transmark"></span>worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        <span style="color:#FF0000;">server_name  wiki.edelweiss0.com;</span>
        location / {
            <span style="color:#FF0000;">root   html/wiki/</span>;
            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;
            <span style="color:#FF0000;">fastcgi_pass   127.0.0.1:9000;</span>
            <span style="color:#FF0000;">fastcgi_index  index.php;</span>
            include        fastcgi.conf;
        }
    
   }
}</span>
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

<?php

       phpinfo();

?>

在瀏覽器登錄192.168.1.132/index.php

5.2測試PHP和MySQL

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

<?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搭建成功。可以在此基礎做擴展。








發佈了53 篇原創文章 · 獲贊 19 · 訪問量 7萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章