>php教程 >php手册 >Linux下php+mysql+nginx编译搭建(二)

Linux下php+mysql+nginx编译搭建(二)

WBOY
WBOY원래의
2016-06-06 19:58:301235검색

之前一直都是一键搭建的web服务器,但是一键搭建的环境相对来说都是比较老的。如果要用比较新的环境,特别是正式服务器,就必须自己手动编译搭建了(以下搭建基于linux centos6.5 32位服务器)。 二、安装mysql 进入安装目录: Cd / opt 下载并解压: wget h

之前一直都是一键搭建的web服务器,但是一键搭建的环境相对来说都是比较老的。如果要用比较新的环境,特别是正式服务器,就必须自己手动编译搭建了(以下搭建基于linux centos6.5 32位服务器)。

二、安装mysql
进入安装目录:

<ol><li>
<span>Cd</span><span>/</span><span>opt</span>
</li></ol>

下载并解压:

<ol>
<li>
<span>wget http</span><span>:</span><span>//downloads.mysql.com/archives/mysql-5.0/mysql-5.5.30.tar.gz</span>
</li>
<li>
<span>tar </span><span>-</span><span>zxf mysql</span><span>-</span><span>5.5</span><span>.</span><span>30.tar</span><span>.</span><span>gz</span>
</li>
</ol>

编译安装:

<ol>
<li><span>cmake \</span></li>
<li>
<span>-</span><span>DCMAKE_INSTALL_PREFIX</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>mysql \</span>
</li>
<li>
<span>-</span><span>DMYSQL_DATADIR</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>mysql</span><span>/</span><span>data \</span>
</li>
<li>
<span>-</span><span>DSYSCONFDIR</span><span>=/</span><span>etc \</span>
</li>
<li>
<span>-</span><span>DWITH_MYISAM_STORAGE_ENGINE</span><span>=</span><span>1</span><span> \</span>
</li>
<li>
<span>-</span><span>DWITH_INNOBASE_STORAGE_ENGINE</span><span>=</span><span>1</span><span> \</span>
</li>
<li>
<span>-</span><span>DWITH_MEMORY_STORAGE_ENGINE</span><span>=</span><span>1</span><span> \</span>
</li>
<li>
<span>-</span><span>DWITH_READLINE</span><span>=</span><span>1</span><span> \</span>
</li>
<li>
<span>-</span><span>DMYSQL_UNIX_ADDR</span><span>=</span><span>/var/</span><span>lib</span><span>/</span><span>mysql</span><span>/</span><span>mysql</span><span>.</span><span>sock \</span>
</li>
<li>
<span>-</span><span>DMYSQL_TCP_PORT</span><span>=</span><span>3306</span><span> \</span>
</li>
<li>
<span>-</span><span>DENABLED_LOCAL_INFILE</span><span>=</span><span>1</span><span> \</span>
</li>
<li>
<span>-</span><span>DWITH_PARTITION_STORAGE_ENGINE</span><span>=</span><span>1</span><span> \</span>
</li>
<li>
<span>-</span><span>DEXTRA_CHARSETS</span><span>=</span><span>all \</span>
</li>
<li>
<span>-</span><span>DDEFAULT_CHARSET</span><span>=</span><span>utf8 \</span>
</li>
<li>
<span>-</span><span>DDEFAULT_COLLATION</span><span>=</span><span>utf8_general_ci</span>
</li>
<li><span> </span></li>
<li>
<span>make </span><span>&&</span><span> make install</span>
</li>
</ol>

添加用户并修改权限:

<ol>
<li><span>groupadd mysql</span></li>
<li>
<span>useradd </span><span>-</span><span>g mysql mysql</span>
</li>
<li>
<span>chown </span><span>-</span><span>R mysql</span><span>:</span><span>mysql </span><span>/</span><span>usr</span><span>/</span><span>local</span><span>/</span><span>mysql</span>
</li>
</ol>

进入安装路径并执行初始化配置脚本,创建系统自带的数据库和表

<ol>
<li>
<span>cd </span><span>/</span><span>usr</span><span>/</span><span>local</span><span>/</span><span>mysql</span>
</li>
<li>
<span>scripts</span><span>/</span><span>mysql_install_db </span><span>--</span><span>basedir</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>mysql </span><span>--</span><span>datadir</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>mysql</span><span>/</span><span>data </span><span>--</span><span>user</span><span>=</span><span>mysql</span>
</li>
</ol>

添加服务,拷贝服务脚本到init.d目录,并设置开机启动:

<ol>
<li>
<span>cp support</span><span>-</span><span>files</span><span>/</span><span>mysql</span><span>.</span><span>server </span><span>/</span><span>etc</span><span>/</span><span>init</span><span>.</span><span>d</span><span>/</span><span>mysql</span>
</li>
<li><span>chkconfig mysql on</span></li>
<li>
<span>service mysql start  </span><span>--启动</span><span>MySQL</span>
</li>
</ol>

设置PATH,支持直接调用mysql(修改/etc/profile文件,在文件末尾添加):

<ol>
<li>
<span>PATH</span><span>=</span><span>/usr/</span><span>local</span><span>/</span><span>mysql</span><span>/</span><span>bin</span><span>:</span><span>$PATH</span>
</li>
<li>
<span>export</span><span> PATH</span>
</li>
</ol>

关闭文件,运行下面的命令,让配置立即生效

<ol><li>
<span>source </span><span>/</span><span>etc</span><span>/</span><span>profile</span>
</li></ol>

另:mysql5.5开始支持cmake。至于两者的差别:
./configure就是执行你当前目录下一个名叫configure的脚本,由它生成Makefile,有了Makefile之后,一般来说就可以通过make进行编译,make install进行安装.
cmake就是一个与make同级别的编译工具,只不过它依靠的不是Makefile作为编译规则,而是根据CMakeLists.txt来编译的。
Cmake 对照:http://dev.mysql.com/doc/refman/5.5/en/source-configuration-options.html

其中有参考:http://www.cnblogs.com/xiongpq/p/3384681.html


更多:http://www.webyang.net/Html/web/article_128.html

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.