LNMP环境快速搭建 + Wiki部署

一、安装msyql+PHP

1、系统centos6.5

2、安装 开发软件包

步骤1:安装开发工具
yum -y groupinstall "Development Tools"

yum groupinsall group1 安装程序组group1
步骤2:安装相关工具

yum -y install libxml2* curl curl-devel libjpeg* libpng* libmcrypt* freetype-devel

  • Libxml2:是个C语言的XML程式库,能简单方便的提供对XML文件的各种操作,并且支持XPATH查询,及部分的支持XSLT转换等功能

  • curl:是利用URL语法在命令行方式下工作的开源文件传输工具

  • libjpeg库是专门用于jpeg图片格式解压和压缩的库

  • libpng库是专门用于png图片格式解压和压缩的库

  • libmcrypt:This is a modular version of libmcrypt, that uses dynamic loading. It is usefull where adding/removing of algorithms at run-time is necessary.

如果Linux没有修改成163的源可以直接安装 如果已经改成了163的源需要执行下面的代码
echo $?检查是否有报错

官网不自带 libmcrypt  libmcrypt-devel
wget http://www.atomicorp.com/installers/atomic  下载这个yum源
执行 sh ./atomic 
yum -y install libmcrypt libmcrypt-devel
步骤3:安装mysql:
 yum -y install mysql mysql-server mysql-devel
步骤4:下载PHP-5.6.2 wget
wget http://cn2.php.net/distributions/php-5.6.2.tar.gz

解压 tar -xvf php-5.6.2.ta.rgz  
1. cd php-5.6.2  
2. 编译安装php  
步骤5:./configure
二种情况 

 1. mysql的rpm包用这种方式编译
./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=mysqlnd --with-mysql-sock=/tmp/mysql.sock --with-pdo-mysql=/usr/local/services/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  

2. 你使用yum来安装mysql
 ./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

configure注释:

configure,这一步一般用来生成 Makefile,为下一步的编译做准备,你可以通过在 configure 后加上参数来对安装进行控制,比如代码:./configure –prefix=/usr 意思是将该软件安装在 /usr 下面,执行文件就会安装在 /usr/bin (而不是默认的 /usr/local/bin),资源文件就会安装在 /usr/share(而不是默认的/usr/local/share)。同时一些软件的配置文件你可以通过指定 –sys-config= 参数进行设定。有一些软件还可以加上 –with、–enable、–without、–disable 等等参数对编译加以控制,你可以通过允许 ./configure –help 察看详细的说明帮助。
步骤6:make && make install
运行 make && make install

makemake install是两个命令,在你./configuration生成了Makefile之后执行编译安装;
与&&一起的还有||,不过意思不一样,&&是与,||是或;
make && make install的意思就是执行make如果没有发生错误就执行make install
步骤7:修改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 /opt/php-5.6.2/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm  

对文件php-fpm进行权限修改
chmod +x /etc/init.d/php-fpm 

–注意–

如果出现未安装的错误一般使用yum安装即可 记得别忘记libcurl*  
1. 出现找不到文件路径的情况下 用 find / -name 'name'去查找一下  
2. 出现warning的謦欬下大多是因为版本以及默认安装了,可以去掉该行  
3. 启动php 等安装完nginx后才启动  

3、安装nginx

yum -y install nginx  
修改 vim /etc/nginx/nginx.conf
user  nginx nginx;

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
{
  use epoll;
  worker_connections 65535;
}

http
{
  include       mime.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;
    index start.php index.htm index.html index.php pengyou.php weibo.php qzone.php;
    root  /usr/share/nginx/html;

    #limit_conn   crawler  20;

    location ~ .*\.(php|php5)?$
    {
      #fastcgi_pass  unix:/tmp/php-cgi.sock;
      fastcgi_pass  127.0.0.1:9000;
      fastcgi_index start.php;
#     include fcgi.conf;
      include fastcgi.conf;
    }
    location ~ .*.(svn|git|cvs)
    {
      deny all;
    }
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {
      expires      30d;
    }

    location ~ .*\.(js|css)?$
    {
      expires      1h;
    }
      }
}
步骤8:启动服务
1、启动php-fpm  
    #修改user和group
    vim /usr/local/php/etc/php-fpm 
    user=nginx 
    group=nginx  

2、启动php-fpm
    /etc/init.d/php-fpm start  

3、启动nginx 
    /etc/init.d/nginx start  

4、编写php文件测试,服务是否正常
    vim /usr/share/nginx/html/cc.php  
    <?php  
    phpinfo();  
    ?>  
虚拟机IP/cc.php   例如:192.168.1.115/cc.php

LNMP安装完成


二、wiki安装部署

1、首先登录进入mysql数据库

#进入到数据库的命令行模式
mysql -uroot  

2、创建一个wiki库

#创建wiki数据库
create database wiki charset utf8;  

#对数据库进行权限赋予
grant all on wiki.* to wiki@'localhost' identified by 'wiki';  

#刷新MySQL的系统权限相关表
flush privileges;  
下载wiki软件
http://kaiyuan.hudong.com/  

#创建hdwiki的文件夹
touch hdwiki

#下载HDWiki UTF的压缩包,上传后解压缩
unzip HDWiki-v6.0UTF8-20170209.zip  

#将文件夹内解压缩的文件移到我们的环境下
mv hdwiki/* /usr/share/nginx/html/

浏览器http://192.168.1.115/hdwiki直接进行配置就可以了

三、需要的相关技术

1、vim

Vim是一个类似于Vi的著名的功能强大、高度可定制的文本编辑器,在Vi的基础上改进和增加了很多特性。[1]  VIM是自由软件。
安装 yum -y install vim

2、上传下载功能

安装 yum -y install lrzsz

使用方法:

sz命令发送文件到本地:
# sz filename

rz命令本地上传文件到服务器:
# rz
执行该命令后,在弹出框中选择要上传的文件即可。

3、mysql相关命令

设置初始密码或修改密码

1、mysql -uroot
2、use mysql;
3、update user set password=password("123456") where user="root";
4、flush privileges;
5、exit

4、修改文件权限

success

语法:

chmod [who] [+ | - | =] [mode] 文件名

命令中各选项的含义为

u 表示“用户(user)”,即文件或目录的所有者。
g 表示“同组(group)用户”,即与文件属主有相同组ID的所有用户。
o 表示“其他(others)用户”。
a 表示“所有(all)用户”。它是系统默认值。

操作符号可以是:

+ 添加某个权限。
- 取消某个权限。
= 赋予给定权限并取消其他所有权限(如果有的话)。

设置mode所表示的权限可用下述字母的任意组合:

r 可读。
w 可写。
x 可执行。

X 只有目标文件对某些用户是可执行的或该目标文件是目录时才追加x 属性。

s 在文件执行时把进程的属主或组ID置为该文件的文件属主。方式“u+s”设置文件的用户ID位,“g+s”设置组ID位。
t 保存程序的文本到交换设备上。
u 与文件属主拥有一样的权限。
g 与和文件属主同组的用户拥有一样的权限。
o 与其他用户拥有一样的权限。

实例

修改文件可读写属性的方法:

#把index.html 文件修改为可写可读可执行:
chmod 777 index.html

#把目录 /images/xiao 修改为可写可读可执行
chmod 777 /images/xiao

#修改目录下所有的文件夹属性
chmod 777 *

#要修改目录下所有文件属性可写可读可执行:
chmod 777 *.*
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值