阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 6.2下以源代码方式安装LAMP

129次阅读
没有评论

共计 8618 个字符,预计需要花费 22 分钟才能阅读完成。

目的

以源代码方式安装 LAMP。

主要软件版本信息

Linux: CentOS 6.2 32

Apache: 2.2.29

MySQL:5.6.22

PHP: 5.2.17

使用说明

所有的源代码包和一键自动化安装脚本我已经打包好并上传到我的云盘。

所有的源代码包都是从官网或者官方建议的网站下载的。

相关附件 百度云盘 下载:http://pan.baidu.com/s/12JCku

或者

—————————————— 分割线 ——————————————

FTP 地址:ftp://ftp1.linuxidc.com

用户名:ftp1.linuxidc.com

密码:www.linuxidc.com

在 2015 年 LinuxIDC.com\1 月 \CentOS 6.2 下以源代码方式安装 LAMP

下载方法见 http://www.linuxidc.com/Linux/2013-10/91140.htm

—————————————— 分割线 ——————————————

下载好后将其上传至 Linux 系统的 /tmp 目录下并解压。

执行下面的命令,安装的过程比较久。

sh /tmp/lamp/lamp.sh

安装完之后最好执行一下 source /etc/profile,将 mysql 的 bin 目录添加到环境变量。

默认的 htdocs 目录位于 /usr/local/apache 目录。

默认的 httpd.conf 文件位于 /usr/local/apache/conf 目录。

默认的 php.ini 文件位于 /usr/local/php/lib 目录。

默认的 my.cnf 文件位于 /etc 目录。

安装完毕后可以用 netstat -nltp 来检查 httpd 和 mysqld 是否启动。

你可以在 /usr/local/apache/htdocs 目录下创建一个 phpinfo.php 文件来检查 PHP 是否正常工作,phpinfo.php 的内容如下:

<?php

phpinfo();

?>

如果你在你的 phpinfo.php 页面中见到如下截图的信息,说明 ZendOptimizer 已经正常工作了。

CentOS 6.2 下以源代码方式安装 LAMP

你可以通过 http:// 服务器 IP/phpMyAdmin 来访问数据库。

为了验证 PHP 是否正常运作,你可以去下一个实际的项目来运行,比如 ECSHOP。

下载好后将整个站点上传到 /usr/local/apache/htdocs 目录下,并执行下面的命令。

chown -R apache:apache /usr/local/apache/htdocs/*

脚本

#!/bin/bash
# Script Name: One-key Automatic Install LAMP Server
# Author: yestreenstars
# Create Time: 2015-01-08
# Update Time: 2015-01-08
 
DOMAIN_NAME=’www.example.com’ # You can change this.
MYSQL_ROOT_PASSWORD=’mypassword’ # You can change this.
MYSQL_BASEDIR=’/usr/local/mysql’ # You can change this.
MYSQL_DATADIR=’/data’ # You can change this.
 
echo -n ‘–Stopping iptables and SELinux…’
(
service iptables stop
chkconfig iptables off
setenforce 0
[-f /etc/selinux/config] && sed -i ‘/^SELINUX=/s/=.*/=disabled/’ /etc/selinux/config
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing related software…’
(
yum -y install gcc gcc-c++ make cmake openssl-devel bison ncurses-devel perl Python-devel freetype-devel wget patch libtool-ltdl-devel
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing apr…’
(
tar xjf /tmp/lamp/apr-1.5.1.tar.bz2 -C /usr/local/src/
cd /usr/local/src/apr-1.5.1/
./configure
make && make install
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing apr-util…’
(
tar xjf /tmp/lamp/apr-util-1.5.4.tar.bz2 -C /usr/local/src/
cd /usr/local/src/apr-util-1.5.4/
./configure –with-apr=/usr/local/apr/ –with-crypto
make && make install
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing pcre…’
(
tar xjf /tmp/lamp/pcre-8.36.tar.bz2 -C /usr/local/src/
cd /usr/local/src/pcre-8.36/
./configure –prefix=/usr/local/pcre
make && make install
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing zlib…’
(
tar xzf /tmp/lamp/zlib-1.2.8.tar.gz -C /usr/local/src/
cd /usr/local/src/zlib-1.2.8/
./configure –prefix=/usr/local/zlib
make && make install
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing apache…’
(
useradd -M -s /sbin/nologin apache
tar xjf /tmp/lamp/httpd-2.2.29.tar.bz2 -C /usr/local/src/
cd /usr/local/src/httpd-2.2.29/
./configure \
–prefix=/usr/local/apache \
–with-z=/usr/local/zlib \
–enable-so –enable-static-support \
–enable-deflate=shared \
–enable-expires=shared \
–enable-rewrite=shared
make && make install
sed -i ‘69,70s/daemon/apache/;101s/.*/ServerName ‘$DOMAIN_NAME’:80/;170s/$/ index.php/;312a\    AddType application/x-httpd-php .php’ /usr/local/apache/conf/httpd.conf
/bin/cp -f /tmp/lamp/httpd /etc/init.d/
chmod 755 /etc/init.d/httpd
chkconfig –add httpd
chkconfig httpd on
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing mysql…’
(
useradd -M -s /sbin/nologin mysql
mkdir -p $MYSQL_DATADIR
chown -R mysql:mysql $MYSQL_DATADIR
tar xzf /tmp/lamp/mysql-5.6.22.tar.gz -C /usr/local/src/
cd /usr/local/src/mysql-5.6.22/
cmake \
-DMYSQL_BASEDIR=$MYSQL_BASEDIR \
-DMYSQL_DATADIR=$MYSQL_DATADIR \
-DDEFAULT_CHARSET=’utf8′ \
-DDEFAULT_COLLATION=’utf8_general_ci’
make && make install
cd /usr/local/mysql/
./scripts/mysql_install_db –user=mysql –basedir=$MYSQL_BASEDIR –datadir=$MYSQL_DATADIR
/bin/cp -f $PWD/support-files/mysql.server /etc/init.d/mysqld
/bin/cp -f $PWD/support-files/my-default.cnf /etc/my.cnf
echo “PATH=$MYSQL_BASEDIR/bin/:$PATH” >> /etc/profile
chkconfig –add mysqld
chkconfig mysqld on
service mysqld start
$MYSQL_BASEDIR/bin/mysqladmin -uroot password $MYSQL_ROOT_PASSWORD
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing re2c…’
(
tar xzf /tmp/lamp/re2c-0.13.7.5.tar.gz -C /usr/local/src/
cd /usr/local/src/re2c-0.13.7.5/
./configure
make && make install
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing libxml2…’
(
tar xzf /tmp/lamp/libxml2-2.9.2.tar.gz -C /usr/local/src/
cd /usr/local/src/libxml2-2.9.2/
./configure –prefix=/usr/local/libxml2
make && make install
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing libpng…’
(
tar xzf /tmp/lamp/libpng-1.6.16.tar.gz -C /usr/local/src/
cd /usr/local/src/libpng-1.6.16/
./configure –prefix=/usr/local/libpng
make && make install
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing jpeg…’
(
mkdir /usr/local/jpeg
mkdir /usr/local/jpeg/bin
mkdir /usr/local/jpeg/lib
mkdir /usr/local/jpeg/include
mkdir -p /usr/local/jpeg/man/man1
tar xzf /tmp/lamp/jpegsrc.v9a.tar.gz -C /usr/local/src/
cd /usr/local/src/jpeg-9a/
./configure –prefix=/usr/local/jpeg –enable-shared –enable-static
make && make install
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing freetype…’
(
tar xjf /tmp/lamp/freetype-2.5.5.tar.bz2 -C /usr/local/src/
cd /usr/local/src/freetype-2.5.5/
./configure –prefix=/usr/local/freetype
make && make install
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing libmcrypt…’
(
tar xzf /tmp/lamp/libmcrypt-2.5.7.tar.gz -C /usr/local/src/
cd /usr/local/src/libmcrypt-2.5.7/
./configure –prefix=/usr/local/libmcrypt
make && make install
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing libgd…’
(
tar xzf /tmp/lamp/libgd-2.1.0.tar.gz -C /usr/local/src/
cd /usr/local/src/libgd-2.1.0/
./configure –prefix=/usr/local/libgd –with-zlib=/usr/local/zlib/ –with-jpeg=/usr/local/jpeg/ –with-png=/usr/local/libpng/ –with-freetype=/usr/local/freetype/
make && make install
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing libiconv…’
(
tar xzf /tmp/lamp/libiconv-1.14.tar.gz -C /usr/local/src/
cd /usr/local/src/libiconv-1.14/
./configure –prefix=/usr/local/
make && make install
ln -s /usr/local/lib/libiconv.so.2 /usr/lib/
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing bzip2…’
(
tar xzf /tmp/lamp/bzip2-1.0.6.tar.gz -C /usr/local/src/
cd /usr/local/src/bzip2-1.0.6/
make install PREFIX=/usr/local/bzip2
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing php…’
(
tar xzf /tmp/lamp/php-5.2.17.tar.gz -C /usr/local/src/
cd /usr/local/src/php-5.2.17/
wget https://mail.gnome.org/archives/xml/2012-August/txtbgxGXAvz4N.txt
patch -p0 -b < txtbgxGXAvz4N.txt
./configure \
–prefix=/usr/local/php \
–with-apxs2=/usr/local/apache/bin/apxs \
–with-libxml-dir=/usr/local/libxml2 \
–with-gd \
–with-jpeg-dir=/usr/local/jpeg \
–with-png-dir=/usr/local/libpng \
–with-zlib-dir=/usr/local/zlib \
–with-freetype-dir=/usr/local/freetype \
–with-mcrypt=/usr/local/libmcrypt \
–with-mysql=/usr/local/mysql \
–with-mysqli=/usr/local/mysql/bin/mysql_config \
–enable-soap \
–enable-mbstring \
–enable-sockets
make ZEND_EXTRA_LIBS=’-liconv’
make install
cp /usr/local/src/php-5.2.17/php.ini-dist /usr/local/php/lib/php.ini
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing ZendOptimizer…’
(
tar xzf /tmp/lamp/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz -C /usr/local/src/
mv /usr/local/src/ZendOptimizer-3.3.9-linux-glibc23-i386 /usr/local/ZendOptimizer
echo -e ‘\n[ZendOptimizer]\nzend_extension = /usr/local/ZendOptimizer/data/5_2_x_comp/ZendOptimizer.so’ >> /usr/local/php/lib/php.ini
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Installing phpMyAdmin…’
(
tar xjf /tmp/lamp/phpMyAdmin-4.0.10.7-all-languages.tar.bz2 -C /usr/local/src/
mv /usr/local/src/phpMyAdmin-4.0.10.7-all-languages /usr/local/apache/htdocs/phpMyAdmin
cd /usr/local/apache/htdocs/phpMyAdmin
/usr/local/mysql/bin/mysql -uroot -p$MYSQL_ROOT_PASSWORD < examples/create_tables.sql
cp config.sample.inc.php config.inc.php
sed -i ‘48,60s#// ##’ config.inc.php
) &> /dev/null && echo ‘Completed!’ || exit
 
echo -n ‘–Starting apache…’
(
service httpd start
) &> /dev/null && echo ‘Completed!’ || exit
 
echo ‘Completed!’

———————————— 分割线 ————————————

CentOS 6.5 系统安装配置 LAMP(Apache+PHP5+MySQL)服务器环境 http://www.linuxidc.com/Linux/2014-12/111030.htm

Ubuntu 14.04 配置 LAMP+phpMyAdmin PHP(5.5.9)开发环境  http://www.linuxidc.com/Linux/2014-10/107924.htm

Windows 7 下硬盘安装 Ubuntu 14.10 图文教程 http://www.linuxidc.com/Linux/2014-10/108430.htm

U 盘安装 Ubuntu 14.10 http://www.linuxidc.com/Linux/2014-10/108402.htm

Ubuntu 14.10 正式发布下载 http://www.linuxidc.com/Linux/2014-10/108363.htm

Ubuntu 14.04 LTS 如何升级到 Ubuntu 14.10  http://www.linuxidc.com/Linux/2014-10/108381.htm

Ubuntu 14.10 下安装 LAMP 服务图文详解  http://www.linuxidc.com/Linux/2014-12/110082.htm

更多 CentOS 相关信息见CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14

———————————— 分割线 ————————————

作者:昨夜星辰

博客:http://yestreenstars.blog.51cto.com/

———————————— 分割线 ————————————

正文完
星哥说事-微信公众号
post-qrcode
 
星锅
版权声明:本站原创文章,由 星锅 2022-01-20发表,共计8618字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中