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

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

WBOY
Freigeben: 2016-06-06 19:58:30
Original
1247 Leute haben es durchsucht

之前一直都是一键搭建的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>
Nach dem Login kopieren

下载并解压:

<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>
Nach dem Login kopieren

编译安装:

<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>
Nach dem Login kopieren

添加用户并修改权限:

<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>
Nach dem Login kopieren

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

<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>
Nach dem Login kopieren

添加服务,拷贝服务脚本到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>
Nach dem Login kopieren

设置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>
Nach dem Login kopieren

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

<ol><li>
<span>source </span><span>/</span><span>etc</span><span>/</span><span>profile</span>
</li></ol>
Nach dem Login kopieren

另: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

Verwandte Etiketten:
Quelle:php.cn
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Beliebte Empfehlungen
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage