您的位置:首页 > 运维架构 > Linux

Centos6.5 源码安装LAMP

2015-07-27 00:00 585 查看
z开始安装之前卸载预装的httpd、MySQL、php。
root账户下执行rpm -qa|grep http rpm -qa|grep mysql rpm -qa|grep php,检查是否有预装的httpd、mysql、php。

执行rpm -e --nodeps 命令,卸载预装的软件。

准备工作:

yum install wget gcc gcc-c++ make re2c curl curl-devel libxml2 libxml2-devel libjpeg libjpeg-devel libpng libpng-devel libmcrypt libmcrypt-devel zlib zlib-devel openssl openssl-devel freetype freetype-devel gd gd-devel perl perl-devel ncurses ncurses-devel bison bison-devel libtool gettext gettext-devel cmake bzip2 bzip2-devel pcre pcre-devel

tar zxvf apr-1.5.2.tar.gz

tar zxvf apr-util-1.5.4.tar.gz

tar zxvf httpd-2.4.12.tar.gz

移动Apr、Apr-util到httpd的srclib文件夹下mv apr-1.5.2 httpd-2.4.12/srclib/apr mv apr-util-1.5.4 httpd-2.4.12/srclib/apr-util

进入httpd的目录

cd httpd-2.4.7

./configure--prefix=/usr/local/apache--sysconfdir=/etc/httpd--with-z--with-included-apr--enable-so--enable-deflate=shared--enable-expires=shared--enable-rewrite=shared--enable-static-support--enable-authn-dbm=shared--enable-cache--enable-file-cache--enable-mem-cache--enable-disk-cache--enable-mods-shared=all--enable-ssl--enable-cgi

make && make instal

5. 添加环境变量

PATH=/usr/local/apache/bin:$PATH

export PATH

source /etc/profile

6. 重启Apache

service httpd start

添加开机启动 chkconfig httpd on

7. 安装MySQL

解压mysql-5.6.16.tar.gz,并进入mysql-t.6.16目录

执行cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_DATADIR=/data/mysql_data-DMYSQL_UNIX_ADDR=/usr/local/mysql/mysql.sock-DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci

编译并安装 make && make install

添加mysql用户

useradd -s /sbin/nologin mysql

赋予权限

chown
-
R mysql
:
mysql
/
usr
/
local
/
mysql mysql的安装目录

chown
-
R mysql
:
mysql
/usr/local/mysql/data 数据库目录

3.进入安装目录

cd /usr/local/mysql/scripts/

数据库初始化:

./mysql_install_db--basedir=/usr/local/mysql--datadir=/usr/local/mysql/data--user=mysql

4、放置已存在的my.cnf影响数据库的安装

mv /etc/my.cnf/etc/my.cnf.old

cp /usr/local/mysql/my.cnf/etc/

5、赋值启动脚本

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

6、环境变量

PATH=/usr/local/mysql/bin:$PATH

export PATH

7、mysql初始化

mysql_secure_installation

8、安装php

tar zxvf php-5.5.6.tar.gz

cd php-5.5.6

./configure --prefix=/opt/php --with-config-file-path=/etc --enable-opcache --enable-fpm --with-fpm-user=kcsoft --with-fpm-group=kcsoft --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-curl --enable-mbstring=all --with-iconv --with-mhash --with-mcrypt --with-gd --with-openssl --enable-sockets --with-gettext --with-zlib --enable-zip --enable-soap --with-apxs2=/opt/apache/bin/apxs --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir --enable-ftp --with-xmlrpc

make && make install

环境变量

PATH=/opt/php/bin:$PATH

export PATH

cp php-5.5.6/php.ini-production /etc/php.ini

vi etc/httpd/httpd.conf

找到

AddType application/x-gzip.gz.tgz

添加AddType application/x-httpd-php.php

在DirectoryIndex index.html后面添加index.php

写phpinfo页面,进行测试。

版权声明:本文为博主原创文章,未经博主允许不得转载。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息