CentOS6.5安装MySql、Apache、PHP

WBOY
Lepaskan: 2016-06-23 13:56:39
asal
1029 orang telah melayarinya

一、安装MySql


1、卸载CentOS自带的MySql


获取root权限先,卸载CentOS自带的MySql

yum remove mysql
Salin selepas log masuk


2、安装cmake

下载cmake

wget http://www.cmake.org/files/v2.8/cmake-2.8.5.tar.gz
Salin selepas log masuk


安装

cd cmake-2.8.5./configure  --prefix=/usr/local/cmakemakemake install
Salin selepas log masuk


3、安装MySql

下载mysql.tar.gz包,这里用的是mysql-5.6.17.tar.gz


所以在这里我们要建一个msyql的用户和组

/usr/sbin/groupadd mysql/usr/sbin/useradd -g mysql mysql
Salin selepas log masuk


创建目录

mkdir /usr/local/mysql   mkdir /usr/local/mysql/data 
Salin selepas log masuk

解压 mysql-5.6.17.tar.gz并进行安装

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysqlmakemake install
Salin selepas log masuk

加权限

chmod +w /usr/local/mysqlchown -R mysql:mysql /usr/local/mysql
Salin selepas log masuk

进入/usr/local/mysql目录

scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql  //初始化MySql数据库cp support-files/my-medium.cnf /usr/local/mysql/my.cnf     //copy配置文件
Salin selepas log masuk


修改配置文件/usr/local/mysql/my.cnf

[mysqld]   basedir = /usr/local/mysql   datadir = /usr/local/mysql/data    port = 3306user = mysql 
Salin selepas log masuk


启动MySql

cd /usr/local/mysql/support-files/cp ./mysql.server /etc/init.d/mysqld/etc/init.d/mysqld start
Salin selepas log masuk


关闭MySql

/etc/init.d/mysqld stop
Salin selepas log masuk


二、安装apache server


1、卸载系统自带的httpd

rpm -qa|grep httpdrpm -e  xxx
Salin selepas log masuk


2、下载apache-server

在安装之前还得先安装APR、APR-util(两者下载地址http://apr.apache.org/download.cgi)、以及pcre(http://ftp.exim.llorien.org/pcre/)

1)安装apr,否则./configure httpd时,会发生error: APR not found. 

mkdir /usr/local/aprtar -zxf apr-1.5.1.tar.gz./configure --prefix=/usr/local/aprmakemake install
Salin selepas log masuk

2)安装apr-util, 否则./configure httpd时,会发生 error: APR-util not found.  

mkdir /usr/local/aprtar -zxf apr-util-1.5.3.tar.gz./configure --prefix=/usr/local/apr-utilmakemake install
Salin selepas log masuk

3)安装pcre,否则./configure httpd时,会发生error:pcre-config for libpcre not found.

mkdir /usr/local/pcreunzip -o pcre-8.35.zipcd pcre-8.35/configure --prefix=/usr/local/pcremakemake install
Salin selepas log masuk


4)最后安装httpd

mkdir /usr/local/apachetar zxvf httpd-2.4.9.tar.gzcd httpd-2.4.9./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre/makemake install
Salin selepas log masuk

5)启动

/usr/local/apache/bin/apachectl start
Salin selepas log masuk

浏览器返回http://localhost

显示It works!,OK apache server配置好了



三、安装PHP


1、下载php,这里用的是php-5.5.12.tar.gz


2、准备工作

yum install libxml2yum install libxml2-devel -y
Salin selepas log masuk
错过这一步,会报待会./configure php时候,会报xml2-config not found.

详情可以参考这里http://www.jsjtt.com/xitongyingyong/linux/17.html


yum install libjpeg-devel
Salin selepas log masuk
错过这一步,待会./configure php时候,会报error: jpeglib.h not found.


要是在下文./configure php时候发生错误,可以参考这里解决方案http://www.cnlvzi.com/index.php/Index/article/id/143


3、安装PHP

1)安装

tar zxvf php-5.5.12.tar.gzcd php-5.5.12./configure --with-apxs2=/usr/local/apache/bin/apxs --with-zlib-dir --with-libxml-dir --with-jpeg-dir --with-png-dir --with-gd --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-mbstring make make install
Salin selepas log masuk


2)配置php.ini文件 ,操作位于解压目录下

cp php.ini-development /usr/local/php/lib/php.ini 
Salin selepas log masuk


3)配置apache支持php

修改vi  /usr/lcoal/apache/conf/httpd.conf

通过“/”来查找到AddType application/x-gzip .tgz,这里需要注意的是,不是带有的注意标记的#,在找到AddType application/x-gzip .tgz的后面添加:

AddType application/x-httpd-php .php .phtmlAddType application/x-httpd-php-source .phps
Salin selepas log masuk
表示apache服务中可以解析php格式文件 

重启apache

/usr/local/apache/bin/apachectrl start
Salin selepas log masuk









Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan