首页 > 代码库 > lamp
lamp
安装环境实在centos6.7 64位
apache2.2.31 + PHP5.3.27 + mysql5.5
#更换阿里云的源,国内的快
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
安装apache2.2.31:
mkdir /home/oldboy/mkdir/tools -p
cd /home/oldboy/mkdir/tools
wget http://mirrors.sohu.com/apache/httpd-2.2.31.tar.gz
#解压并安装依耐包
tar xf httpd-2.2.31.tar.gz
cd httpd-2.2.31
yum install zlib zlib-devel -y
#配置,必须要切到文件下配置,否则的话会出错
./configure \
--prefix=/application/apache2.2.31 \
--enable-deflate \
--enable-expires \
--enable-headers \
--enable-modules=most \
--enable-so \
--with-mpm=worker \
--enable-rewrite
#编译 安装
make
make install
建立软链接
ln -s /application/apache2.2.31/ /application/apache
ls /application/apache
#安装apache
cd /application/apache/htdocs
mkdir www blog bbs
#修改conf/httpd.conf文件,
cd /application/apache/conf/
cp httpd.conf httpd.conf.ori
vim /application/apache/conf/httpd.conf
#httpd.conf文件第98行修改为:ServerName 127.0.0.1:80
#httpd.conf文件在145行前加"#"。注释掉本行,无默认首页时,取消显示目录的功能。
#httpd.conf文件去掉396行前的"#"
#修改/application/apache/conf/extra/httpd-vhosts.conf文件内容
cp extra/httpd-vhosts.conf extra/httpd-vhosts.conf.ori
echo ‘NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin 294017705-@qq.com
DocumentRoot "/application/apache2.2.31/htdocs/www"
ServerName www.etiantian.org
ServerAlias etiantian.org
ErrorLog "logs/www-error_log"
CustomLog "logs/www-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin 294017705-@qq.com
DocumentRoot "/application/apache2.2.31/htdocs/bbs"
ServerName bbs.etiantian.org
ErrorLog "logs/bbs-error_log"
CustomLog "logs/bbs-access_log" common
</VirtualHost>‘ >/application/apache/conf/extra/httpd-vhosts.conf
#检查apache语法:
/application/apache/bin/apachectl -t
#启动Apache
/application/apache/bin/apachectl start
#优雅重启Apache
/application/apache/bin/apachectl graceful
#检查Apache状态
netstat -lntup| grep httpd
2、安装PHP5.3.27:
#yum安装各种依赖包
yum install zlib-devel libxml2-devel openssl-devel libjpeg-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libmcrypt-devel mhash mcrypt -y
#检查安装包(共12个rpm)
rpm -qa zlib-devel libxml2-devel openssl-devel libjpeg-devel libjpeg-turbo-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libmcrypt-devel mhash mcrypt
#下载并安装libiconv
cd /home/oldboy/tools/
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxvf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make install
cd /home/oldboy/tools/
wget http://mirrors.sohu.com/php/php-5.3.27.tar.gz
tar xf php-5.3.27.tar.gz
cd php-5.3.27
#编译安装PHP
./configure \
--prefix=/application/php5.3.27 \
--with-apxs2=/application/apache/bin/apxs \
--with-mysql=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--enable-ftp
make
make install
ln -s /application/php5.3.27/ /application/php
ls /application/php
ls /application/apache/modules/
查看模板文件(位于解压目录/home/oldboy/tools/php-5.5.35)
cd /home/oldboy/tools/php-5.3.27
ll php.ini*
-rw-r--r-- 1 1000 1000 68881 Apr 29 02:12 php.ini-development
-rw-r--r-- 1 1000 1000 68913 Apr 29 02:12 php.ini-production
#拷贝模板文件为php.ini
cp php.ini-production /application/php/lib/php.ini
增加用户并对目录授权
useradd www -s /sbin/nologin -M
chown -R www.www /application/apache/htdocs/
#配置Apache支持php
#修改conf/httpd.conf文件,
cd /application/apache/conf/
cp httpd.conf httpd.conf.bak_1
vim /application/apache/conf/httpd.conf
#httpd.conf文件第168行修改为: DirectoryIndex index.php index.html
#httpd.conf文件在311行后增加两行:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
#httpd.conf文件把67-68行修改为:
User www
Group www
#检查apache语法:
/application/apache/bin/apachectl -t
#优雅重启Apache
/application/apache/bin/apachectl graceful
#停止Apache
/application/apache/bin/apachectl stop
#启动Apache
/application/apache/bin/apachectl start
#检查Apache状态
netstat -lntup| grep httpd
#创建index.php测试文件
echo "<?php
phpinfo();
?>" > /application/apache2.2.31/htdocs/www/index.php
3、mysql安装(略)
创建mysql.php测试文件
echo "<?php
$link=mysql_connect(‘172.16.1.51‘,‘wordpress‘,‘123456‘) or mysql_error();
if ($link) {
echo ‘Connected mysql successfully!‘;
}
else {
echo mysql_error();
}
?>" > /application/apache2.2.31/htdocs/www/mysql.php
成功后会有php界面
本文出自 “7177651” 博客,请务必保留此出处http://7187651.blog.51cto.com/7177651/1844353
lamp