Chinaunix首页 | 论坛 | 博客
  • 博客访问: 270851
  • 博文数量: 36
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 411
  • 用 户 组: 普通用户
  • 注册时间: 2015-05-04 22:05
个人简介

追求永无止境

文章分类
文章存档

2016年(3)

2015年(33)

分类: 系统运维

2015-06-11 08:21:30

环境:

Windows7旗舰版下装的virtualbox

虚拟机使用的是:centos7.0

第一步:准备:

安装编译工具cmakeyum install cmake

网络查看工具:netstatyum install net-tools

第二步:安装mysql

版本:mysql-5.5.42.tar.gz

         解压:tar –zxvf mysql-5.5.42.tar.gz

         移动解压后的文件到/usr/local目录下:mv /mysql-5.5.42 /usr/local/

         cd /usr/local/mysql-5.5.42

         groupadd –r mysql

         useradd –r –g mysql mysql –s /sbin/nologin

         chown –R mysql:mysql

         mkdir –p /usr/local/mysql

         mkdir –p /data/mysql

        

         cmake –DCMAKE_INSTALL_PREFIX=/usr/local/mysql\

         -DSYSCONFDIR=/etc\

         -DMYSQL_UNIX_ADDR=/tmp/mysql.sock\

         -DDEFAULT_CHARSET=utf8\

         -DDEFAULT_COLLATION=utf8_general_ci

         -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk\

         -DWITH_MYISAM_STORAGE_ENGINE=1\

         -DWITH_INNOBASE_STOTAGE_ENGINE=1\

         -DWITH_READLINE=1\

         -DMYSQL_DATADIR=/data/mysql

出现这种错误时:

先删除当前目录下的CmakeCache.txt文件,然后安装ncurses-develyum install ncurses-devel,最后重新cmake

Cmake完成后没有错误即可进行下一步。


接下来就是make

最后make install


安装完成。

配置mysql

添加mysql环境变量

         Vim /etc/profile 添加:/PATH=$PATH:/usr/local/mysql/bin

         重读环境变量: source /etc/profile

添加mysql的库文件:

         Vim /etc/ld.so.conf.d/mysql.cnf添加:/usr/local/mysql/lib

         重新加载库文件:ldconfig –v

初始化mysql。设置启动mysqlmysql的配置文件

         /usr/local/mysql/scripts/mysql_install_db –basedir=/usr/local/mysql –datadir=/data/mysql/ --user=mysql

         Ln –sv /usr/local/mysql/include /usr/include/mysql

         Mkdir –p /data/mysql/data/

         Mkdir –p /data/mysql/binlog/

         Mkdir –p /data/mysql/relaylog/

         Chown –R mysql:mysql /data/mysql/

         Cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf

         Cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

         Chmod +x /etc/init.d/mysqld

         Chkconfig –add mysqld

         Service mysqld start


查看运行状态:netstat –aupln | grep mysql

设置数据库密码:启动数据库后:mysqladmin –u root password ‘123’

第三步:安装libevent-2.0.16-stable.tar.gz

 解压:tar –zxvf libevent-2.0.16-stable.tar.gz

 移动到 /usr/local 目录下:mv libevent-2.0.16-stable /usr/local/

 生成配置文件:mkdir –p /usr/local/libevent

cd /usr/local/libevent-2.0.16-stable

                   ./configure  -–prefix=/usr/local/libevent

 编译:make

 安装:make install

 配置libevent:

         加入函数库:vim /etc/ld.so.conf.d/libevent.conf

                   加入代码:/usr/local/libevent/lib

         重新加载配置文件:ldconfig

         查看配置结果:ldconfig –pv | grep libevent

做软链接连接到安装目录:ln –s /usr/local/libevent/include /usr/include/libevent

第四步:安装pcre-8.37.tar.bz2

解压:tar –jxvf pcre-8.37.tar.bz2

移动到/usr/local目录下:mv pcre-8.37 /usr/local/

生成配置文件:mkdir –p /usr/local/pcre

                   Cd /usr/local/pcre-8.37

                   ./configure –prefix=/usr/local/pcre

编译:make

安装:make install

第五部:安装nginx-1.8.0.tar.gz

 解压:tar –zxvf nginx-1.8.0.tar.gz

移动到/usr/local目录:mv nginx-1.8.0 /usr/local

添加用户和租:groupadd –r nginx

                                   Useradd –r –g nginx –s /sbin/nologin nginx

生成配置文件:mkdir –p /usr/local/nginx

                Cd /usr/local/nginx-1.8.0

                ./configure

--conf-path=/etc/nginx/nginx.conf

--conf-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/lock/nginx.lock

--user=nginx

--group=nginx

--with-http_ssl_module

--with-http_flv_module

--with-http_stub_status_module

--with-http_gzip_static_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/fcgi

--with-pcre=/usr/local/pcre-8.37

编译:make

安装:make install

创建需要的目录:mkdir –pv /var/tmp/nginx/client

启动nginx

查看运行情况:netstat –tupln | grep 80

                Ps –aux | grep 80

加入启动路径:PATH=$PATH:/usr/local/nginx/sbin

编写nginx的初始化文件:

  路径:/etc/init.d

Vim nginx

#!/bin/bash

#chkconfig:2345 88 77

#description:the nginx web server

Prog=/usr/local/nginx/sbin/nginx

Pidfile=/var/run/nginx/nginx.pid

Lockfile=/var/lock/nginx.lock

Start(){

       [ -e $lockfile ] && echo “nginx is started” && exit

       Echo  -n  “nginx is startinf …”

       Sleep 1

$prog && touch $lockfile && echo “ok” || echo “fail”

}

 

Stop(){

       [ ! –f $lockfile ] && echo “nginx is stoped ” && exit

       Echo –n “nginx is stopping ….”

       Sleep 1

       $prog –s stop && echo “the nginx server is running…. Pid is `cat $pidfile`” || echo “the nginx server is stopped”

}

Case “$1” in

Start)

       Start

       ;;

Stop)

       Stop

       ;;

Restart)

       Stop

       start

       ;;

Status)

       Status

       ;;

*)

       Echo “USAGE:start|stop|status|restart”

       ;;

Esac

 

第六步:安装php-5.6.8.tar.bz2

准备工作:

安装libxml2-develyum install libxml2-devel

解压PHPtar –jxvf php-5.6.8.tar.bz2

移动到/usr/local目录:mv php-5.6.8 /usr/local/

配置:mkdir /usr/local/php

                Cd /usr/local/php-5.6.8

                ./configure

--prefix=/usr/local/php

--enable-fpm

--enable-sockets

--with-mysql=/usr/local/mysql

--with-mysqli=/usr/local/mysql/bin/mysql_config

--enable-mbstring

--enable-xml

--with-png-dir

--with-jpeg-dir

--with-zlib

--with-freetype-dir

--with-config-file-path=/etc/php

--with-config-file-scan-dir=/etc/php5.d

编译:make

安装:make install

添加到系统路径中:vim /etc/profile

       添加内容:   :/usr/local/php/bin

刷新目录:.  /etc/profile

查看路径信息:echo $PATH

Cd /usr/local/php-5.6.8

Mkdir /etc/php /etc/php5.d

Cp php.ini-production /etc/etc/php/php.ini

Cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

Chmod a+x /etc/init.d/php-fpm

Cd /usr/local/php/etc/

Cp php-fpm.conf.default  php-fpm.conf

Service php-fpm start

Chkconfig –add php-fpm

更改网站目录:

Vim /etc/nginx/nginx.conf

Service nginx restart

Service php-fpm restart

进入网站文件目录编辑网页内容:

Cd /usr/local/nginx/html/

Mv index.html index.php

第七步:测试

测试代码:

$link=mysql_connect(‘127.0.0.1’,’root’.’123’);

If ($link)

Echo “ok”

Else

Echo “sorry failed to connect!”

?>

写在最后:

.so为系统动态库

         .a 为静态库

         --devel 共享库

         Include文件为头文件库

         Lib文件为 库文件夹

         Support-files或者etc为配置文件夹

一些常见的错误:

1configure: error: Please reinstall the mysql distribution

 

这个表示没有找到 mysql 安装的那个 config 文件

 

其实是不需要在本机 安装mysql的,只需要找 这个 mysql的配置文件,可能是 mysql的配置文件 路径有问题

 

 /usr/bin/mysql_config 一般 找到 mysql_config 这个配置文件就可以了

 ./configure     --with-mysqli=/usr/local/mysql/bin/mysql_config

(2)cmake是报错:

-- Could NOT find Curses (missing:  CURSES_LIBRARY CURSES_INCLUDE_PATH)

CMake Error at cmake/readline.cmake:82 (MESSAGE):

  Curses library not found.  Please install appropriate package,

删除CmakeCache.txt

安装ncurses-devel :yum install ncurses-devel

再次:cmake

源码装完了该告诉你一些常识吧:

Mysql安装大多数用的二进制安装,而很少手动编译!

         Mysql使用的glibc进行开发的,glibc库是一个底层api,所以只要是linux,都会有glibc、这也就是为什么大多数教程都是二进制安装 这其中包括相当多的培训也是这样。在相同的环境下直接将编译好的二进制代码复制到另外一台机器上是可以正常运行的。

阅读(2292) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

sxauzx2015-07-01 21:54:45

安装nginx之前安装两个依赖包:yum install -y openssl openssl-devel