linux下LAMP环境搭建
<
创新互联公司专注于赫章网站建设服务及定制,我们拥有丰富的企业做网站经验。 热诚为您提供赫章营销型网站建设,赫章网站制作、赫章网页设计、赫章网站官网定制、成都小程序开发服务,打造赫章网络公司原创品牌,更为您提供赫章网站排名全网营销落地服务。div>++++++++++++++++++++++++++++++++++++++++++++++linux下LAMP环境搭建
++++++++++++++++++++++++++++++++++++++++++++++
操作系统 : [CentOS6.0]
服务器 : [httpd-2.2.9]
PHP : [php-5.2.6]
数据库 : [mysql-5.1.59]
++++++++++++++++++++++++++++++++++++++++++++++
准备安装软件(download)
1> [httpd-2.2.9]
http://sunsite.bilkent.edu.tr/pub/apache/httpd/httpd-2.2.9.tar.gz
2> [php-5.2.6]
http://museum.php.net/php5/php-5.2.6.tar.gz
3> [mysql-5.1.59]
http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.59.tar.gz
4> [libxml2-2.6.30]
http://download.chinaunix.net/down.php?id=28491&ResourceID=6095&site=1
5> [libmcrypt-2.5.8]
http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
6> [zlib-1.2.3]
http://sourceforge.net/projects/libpng/files/zlib/1.2.3/zlib-1.2.3.tar.gz/download
7.>[libpng-1.2.31]
http://files.directadmin.com/services/custombuild/libpng-1.2.31.tar.gz
8.>[jpegsrc.v6b]
http://download.chinaunix.net/down.php?id=10021&ResourceID=5095&site=1
9.>[freetype-2.3.5]
http://nongnu.askapache.com/freetype/freetype-2.3.5.tar.gz
10.>[autoconf-2.61]
http://ftp.gnu.org/gnu/autoconf/autoconf-2.61.tar.gz
11.>[gd-2.0.35]
http://code.google.com/p/google-desktop-for-linux-mirror/downloads/detail?name=gd-2.0.35.tar.gz&can=2&q=
12.>[ncurses-5.6]
http://ftp.gnu.org/gnu/ncurses/ncurses-5.6.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++
1>【卸载系统自带的apache】
[html] view plaincopy
#查看apache是否己安装
rpm -qa httpd
#卸载
rpm -e httpd --nodeps
2>【安装gcc, gcc-c++】
[html] view plaincopy
yum install gcc
yum install gcc-c++
3>【开放80、3306、22端口】
[html] view plaincopy
#关闭防火墙
service iptables stop
vi /etc/sysconfig/iptables
#添加
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
#重启防火墙
service iptables restart
4>【建立lamp/src目录, 将源码包上传】
5>【安装libxml2】
[html] view plaincopy
tar -zxvf libxml2-2.6.30.tar.gz
cd libxml2-2.6.30
./configure --prefix=/usr/local/libxml2/
make
make install
6>【安装libmcrypt】
[html] view plaincopy
tar -zxvf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure --enable-ltdl-install
make
make install
7>【安装zlib】
[html] view plaincopy
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure
make
make install
8>【安装libpng】
[html] view plaincopy
tar -zxvf libpng-1.2.31.tar.gz
cd libpng-1.2.31
./configure --prefix=/usr/local/libpng/
make
make install
9>【安装jpegsrc.v6b】
[html] view plaincopy
mkdir /usr/local/jpeg6
mkdir /usr/local/jpeg6/bin
mkdir /usr/local/jpeg6/lib
mkdir /usr/local/jpeg6/include
mkdir -p /usr/local/jpeg6/man/man1
tar -zxvf jpegsrc.v6b.tar.gz
cd jpeg-6b
./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-static
make
make install
10>【安装freetype】
[html] view plaincopy
tar -zxvf freetype-2.3.5.tar.gz
cd freetype-2.3.5
./configure --prefix=/usr/local/freetype/
make
make install
11>【安装autoconf】
[html] view plaincopy
tar -zxvf autoconf-2.61.tar.gz
cd autoconf-2.61
./configure
make
make install
12>【安装gd】
[html] view plaincopy
tar -zxvf gd-2.0.35.tar.gz
cd gd-2.0.35
./configure --prefix=/usr/local/gd2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype/
make
make install
13>【安装apache】
[html] view plaincopy
tar -zxvf httpd-2.2.9.tar.gz
cd httpd-2.2.9
./configure --prefix=/usr/local/apache2/ --sysconfdir=/etc/httpd/ --with-included-apr --disable-userdir --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --enable-static-support
make
make install
#启动apache
/usr/local/apache2/bin/apachectl start
#如果出现下面的错误,
#httpd: Could not reliably determine the server\'s fully qualified domain name, using ::1 for ServerName
#修改配置文件
vi /etc/httpd/httpd.conf
#查找ServerName,将注释去掉
ServerName www.example.com:80
#添加到自启动
echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.sysinit
#将apache添加到系统服务中
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd
vi /etc/rc.d/init.d/httpd
#在#!/bin/sh后添加下面两行(包含"#")
# chkconfig:2345 85 15
# description:Apache
#添加执行权限
chmod 755 /etc/init.d/httpd
#添加到系统服务中
chkconfig --add httpd
#开启apache
service httpd start
14>【安装ncurses】
[html] view plaincopy
tar -zxvf ncurses-5.6.tar.gz
cd ncurses-5.6
./configure --with-shared --without-debug --without-ada --enable-overwrite
make
make install
15>【安装mysql】
[html] view plaincopy
groupadd mysql
useradd -g mysql mysql
tar -zxvf mysql-5.1.59.tar.gz
cd mysql-5.1.59
./configure --prefix=/usr/local/mysql/ --with-extra-charsets=all
make
make install
[html] view plaincopy
cp support-files/my-medium.cnf /etc/my.cnf
/usr/local/mysql/bin/mysql_install_db --user=mysql
chown -R root /usr/local/mysql
chown -R mysql /usr/local/mysql/var
chgrp -R mysql /usr/local/mysql
/usr/local/mysql/bin/mysqld_safe --user=mysql &
cp /lamp/src/mysql-5.1.59/support-files/mysql.server /etc/rc.d/init.d/mysqld
chown root.root /etc/rc.d/init.d/mysqld
chmod 755 /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
chkconfig --levels 245 mysqld off
[html] view plaincopy
#配置mysql
cd /usr/local/mysql
bin/mysqladmin version //简单的测试
bin/mysqladmin Variables //查看所有mysql参数
bin/mysql -uroot //没有密码可以直接登录本机服务器
DELETE FROM mysql.user WHERE Host=\'localhost\' AND User=\'\';
FLUSH PRIVILEGES;
#设置root密码为123456
SET PASSWORD FOR \'root\'@\'localhost\' = PASSWORD(\'123456\');
#配置可远程连接mysql
use mysql
SELECT user,password,host FROM user;
DELETE FROM user WHERE host=\'localhsot.localdomain\'
DELETE FROM user WHERE host=\'127.0.0.1\';
UPDATE user SET host=\'%\' WHERE user=\'root\';
#重启mysql
service mysqld restart
16>【安装php】
[html] view plaincopy
tar -zxvf php-5.2.6.tar.gz
cd php-5.2.6
./configure --prefix=/usr/local/php/ --with-config-file-path=/usr/local/php/etc/ --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql/ --with-libxml-dir=/usr/local/libxml2/ --with-jpeg-dir=/usr/local/jpeg6/ --with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd2/ --with-mcrypt=/usr/local/libmcrypt/ --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-mbstring=all --enable-sockets
make
make install
cp php.ini-dist /usr/local/php/etc/php.ini
17>【apache配置】
[html] view plaincopy
#建立工作目录
mkdir -p /var/www/html
#修改httpd.conf
vi /etc/httpd/httpd.conf
#功能: 设置工作目录
#说明: 搜索DocumentRoot, 修改为
DocumentRoot "/var/www/html"
#功能: 设置目录选项
#说明: 搜索
#功能: 设置默认文档
#说明: 搜索
DirectoryIndex index.html index.php
#功能: 增加php类型
#说明: 搜索 AddType application/x-gzip .gz .tgz在后面添加
AddType application/x-httpd-php .html .php
功能: 不允许访问目录
说明: 搜索Options Indexes FollowSymLinks项并注释
#Options Indexes FollowSymLinks
#注意: 修改配置文件后, 重启apache才能生效
#重启apache
service httpd restart
18>【添加PDO_MYSQL扩展】
[html] view plaincopy
cd /lamp/src/php-5.2.6/ext/pdo_mysql
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --with-pdo-mysql=/usr/local/mysql
make
make install
[html] view plaincopy
#执行完make install后会生成
#Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/
#修改php.ini
vi /usr/local/php/etc/php.ini
#查找extension_dir,修改为
extension_dir = "/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"
#添加pdo_mysql
extension = pdo_mysql.so
#重启apache
service httpd restart
19>【apache虚拟主机配置】
[html] view plaincopy
#建立dev目录
mkdir -p /var/www/html/dev
cd /var/www/html/dev
vi index.php
#添加
phpinfo();
?>
#保存,退出
#打开httpd.conf
vi /etc/httpd/httpd.conf
#查找Include /etc/httpd//extra/httpd-vhosts.conf并取消注释
Include /etc/httpd//extra/httpd-vhosts.conf
#打开httpd-vhosts.conf
vi /etc/httpd//extra/httpd-vhosts.conf
#将下面几行注释
#
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot "/usr/local/apache2//docs/dummy-host.example.com"
# ServerName dummy-host.example.com
# ServerAlias www.dummy-host.example.com
# ErrorLog "logs/dummy-host.example.com-error_log"
# CustomLog "logs/dummy-host.example.com-access_log" common
#
#
# ServerAdmin webmaster@dummy-host2.example.com
# DocumentRoot "/usr/local/apache2//docs/dummy-host2.example.com"
# ServerName dummy-host2.example.com
# ErrorLog "logs/dummy-host2.example.com-error_log"
# CustomLog "logs/dummy-host2.example.com-access_log" common
#
#添加
ServerName dev.dev
DocumentRoot "/var/www/html/dev"
AllowOverride All
#保存, 退出
#重启apache
service httpd restart
#修改hosts文件
vi /etc/hosts
#添加
127.0.0.1 dev.dev localhost
#保存, 退出
#在浏览器输入http://dev.dev访问,查看能否输出php信息
原文地址:http://blog.csdn.net/ihelloworld/article/details/7003394
新闻标题:linux下LAMP环境搭建
标题路径:http://ybzwz.com/article/cjpsos.html