网络运营

LNMP+HDWIKI简单部署

准备环境

系统版本6.5
PHP版本5.6.2(因为mysql5.1以上的版本,需要php5.0以上才能支持)
mysql版本5.1
nginx版本1.10

部署环境

1.安装开发包
yum -y groupinstall “Development Tools” 
yum -y install libxml2* curl curl-devellibjpeg* libpng* libmcrypt*  freetype-devel
2.安装mysql
yum -y install mysqlmysql-server mysql-devel
3.安装php

  • 下载php

wget http://cn2.php.net/distributions/php-5.6.2.tar.gz
tar -xvf php-5.6.2.ta.rgz
cd php-5.6.2

  • 编译安装php

./configure –prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc –enable-fpm –with-fpm-user=php-fpm –with-fpm-group=php-fpm –with-mysql–with-mysql-sock=/tmp/mysql.sock –with-pdo-mysql –with-libxml-dir –with-gd –with-jpeg-dir –with-png-dir –with-freetype-dir –with-iconv-dir –with-zlib-dir –with-mcrypt –enable-soap –enable-gd-native-ttf –enable-ftp –enable-mbstring –enable-exif –disable-ipv6 –with-pear –with-curl –with-openssl –enable-bcmath –enable-sockets
make&& make install

  • 修改php配置文件

cp php.ini-production /usr/local/php/etc/php.ini 
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp php-5.6.2/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
————————————————————-
这里列出一些常见的错误:
1. 编译完成后,若报错如下
configure: error: freetype-config not found.

安装freetype* 包
[root@vagrant-centos65 php-5.6.2]# yum -y install freetype*

完成后,再继续编译一次
2.若报错如下:缺少libcurl
configure: error: Please reinstall the libcurl distribution – easy.h should be in <curl-dir>/include/curl/

安装libcurl* 包
[root@bogon php-5.6.2]# yum -y install libcurl*

再重新编译一次
3.若报错如下:缺少 libxml2
configure: error: xml2-config not found. Please check your libxml2 installation. [root@vagrant-centos65 ~]# yum -y install libxml2*

4.错误如下:缺少jpeglib.h
configure: error: jpeglib.h not found. [root@vagrant-centos65 ~]# yum -y install curl* libjpeg* libpng* libmcrypt*

5.若缺少libmcrypt* 包, 暂时没有解决的办法,重新安装吧
正确的操作:安装完mysql后,先不要启动mysql,编译php完后再安装mysql,否则缺少libmcrypt,暂时没有解决的办法,只能开启一台新机器,重新安装。
总之编译的时候,缺什么包就再重新安装什么包,直到编译成功才能执行下一步 make 安装
完成后,再安装
4.安装nginx
yum -y install nginx
修改nginx配置文件
vim /etc/nginx/nginx.conf
 
user  nginxnginx;
 
worker_processes 16;
 
#error_log  /data/logs/nginx_error.log  crit;
error_log /var/log/nginx_error.log crit;
#pid        /usr/local/services/nginx/nginx.pid;
pid /var/run/nginx.pid;
 
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 65535;
 
events
{
useepoll;
worker_connections 65535;
}
 
http
{
includemime.types;
default_type  application/octet-stream;
 
  #charset  gb2312;
 
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 8m;
 
sendfile on;
tcp_nopush     on;
 
keepalive_timeout 60;
 
tcp_nodelay on;
 
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
 
gzip on;
gzip_min_length  1k;
gzip_buffers     4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types       text/plain application/x-javascript text/css application/xml;
gzip_vary on;
 
  #limit_zone  crawler  $binary_remote_addr  10m;
log_format  www  ‘$remote_addr – $remote_user [$time_local] “$request” ‘
              ‘$status $body_bytes_sent “$http_referer” ‘
              ‘”$http_user_agent” $http_x_forwarded_for’;
 
server
  {
listen       80;
server_name  vagrant-centos65.vagrantup.com;
indexstart.php index.htm index.html index.phppengyou.phpweibo.phpqzone.php;
root  /usr/share/nginx/html;
 
    #limit_conncrawler  20;
 
location ~ .*\.(php|php5)?$
    {
      #fastcgi_passunix:/tmp/php-cgi.sock;
fastcgi_pass  127.0.0.1:9000;
fastcgi_indexstart.php;
#      include fcgi.conf;
includefastcgi.conf;
    }
location ~ .*.(svn|git|cvs)
    {
deny all;
    }
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
expires      30d;
    }
 
location ~ .*\.(js|css)?$
    {
expires      1h;
    }
 
      }
 
 
}

  • 启动php

修改php的配置文件
vim /usr/local/php/etc/php-fpm

在文件的第 148 行,修改文件内容如下:
148 user = php-fpm
149 group = php-fpm
修改为
148 user = nginx
149 group = nginx

/etc/init.d/php-fpm start

  • 写一个php的测试页面

vim /usr/shara/nginx/html/cc.php

<?php
phpinfo();
?>

  • 启动nginx

/etc/init.d/nginx start

 

  • 访问php页面,测试nginx能否识别php文件

5. HDWiKi安装部署
·

下载HDWiKi

·

http://kaiyuan.hoodong.com/ 这里用windows下载就行了

·

·

使用rz或者xshell之类的工具把HDWiKi传到CentOS中

·

·

将项目安装包HDWiKi放在 /usr/share/nginx/html/

·

[root@vagrant-centos65 html]# cp /opt/HDWiki-v6.0UTF8-20170209.zip ./
[root@vagrant-centos65 html]# unzip HDWiki-v6.0UTF8-20170209.zip
[root@vagrant-centos65 html]# mvhdwiki/* ./
可以先把这些文件授权,否则后面在网页安装HDWili时,会出现这几个文件权限不够
[root@vagrant-centos65 html]# chmod 777 uploads/
[root@vagrant-centos65 html]# chmod 777 data/
[root@vagrant-centos65 html]# chmod 777 plugins/
[root@vagrant-centos65 html]# chmod 777 config.php
[root@vagrant-centos65 html]# chmod 777 style/default/logo.gif
登录mysql数据库
mysql -uroot
创建一个wiki库
createdatabase wiki charset utf8;grant all on wiki.* towiki@’localhost’identifiedby’wiki’;
到此LNMP + HDWiKi的环境已经部署完成
可以根据自己的路径去访问HDWiKi了,然后进行相关的管理员预设!这部分都是在web页面上面操作的。操作时候注意细节即可。(语言可以选中文的)

Be the First to comment.

Leave a Comment

电子邮件地址不会被公开。 必填项已用*标注

77 views