LAMP是一个缩写Linux+Apache+MySql+PHP,它指一组通常一起使用来运行动态网站或者服务器的自由软件: * Linux,操作系统; 今天介绍一下Linux下LAMP(Apache+PHP+MySql)环境配置: 1、下载软件 MySql:wget http://down1.chinaunix.net/distfiles/mysql-5.0.56.tar.gz Apache:wget http://apache.freelamp.com/httpd/httpd-2.2.13.tar.gz 2、安装MySql 安装步骤: shell> groupadd mysql shell> useradd -g mysql mysql shell> gunzip < mysql-VERSION.tar.gz | tar -xvf – 或 tar -zxvf mysql-5.0.56.tar.gz(解压mysql源码包) shell> cd mysql-VERSION(进入mysql源码文件夹) shell> ./configure –prefix=/usr/local/mysql shell> make shell> make install shell> cp support-files/my-medium.cnf /etc/my.cnf shell> cd /usr/local/mysql shell> bin/mysql_install_db –user=mysql shell> chown -R root . shell> chown -R mysql var shell> chgrp -R mysql . shell> bin/mysqld_safe –user=mysql & 修改mysql root 密码 3、安装Apache tar zvxf httpd-2.2.13.tar.gz #define HARD_SERVER_LIMIT 256 改成 #define HARD_SERVER_LIMIT 2560 保存退出编译apache #这里我们通过enable-module参数告诉设置脚本,我们需要启动so和rewrite模块,so模块是用来提DSO支持的apache核 心模块,而rewrite模块则是用意实现地址重写的模块,由于rewrite模块需要DBM支持,如果在初次安装时没有编译进apache,以后需要用 到时需要重新编译整个apache才可以实现。为此除非你可以确定以后不会用到rewrite模块,否则还是建议你在第一次编译的时候把rewrite模 块编译好。 enable-shared=max 这个参数的作用时编译apache时,把除了so以外的所有apache的标准模块都编译成DSO模块。而不是编译进apache核心内。 好了安装apache很简单的哦,启动apache看看 /usr/local/apache/bin/apachectl start apache设为linux服务 cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd 在在#!/bin/sh后面加入下面两行 然后 4、安装PHP (1)tar zvxf php-5.2.10.tar.bz2 (3)./configure -prefix=/usr/local/php –with-config-file-path=/usr/local/php/etc -with-mysql=/usr/local/mysql –with-mysqli=/usr/local/mysql/bin/mysql_config –with-iconv-dir=/usr/local –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-libxml-dir=/usr –enable-xml –disable-rpath –enable-discard-path –enable-safe-mode –enable-bcmath –enable-shmop –enable-sysvsem –enable-inline-optimization –with-curl –with-curlwrappers –enable-mbregex –enable-fastcgi –enable-fpm –enable-force-cgi-redirect –enable-mbstring –with-mcrypt –with-gd –enable-gd-native-ttf –with-openssl –with-mhash –enable-pcntl –enable-sockets –with-ldap –with-ldap-sasl –-with-apxs2=/usr/local/apache/bin/apxs (4)make (5)make install 最后一步重新启动apache报如下错误: 原因:是Linux有一个SELinux保护模式引起的。 解决办法: 1关闭SELINUX的方法: 2不关闭SELINUX的方法:
依次执行如下命令
# setenforce 0
# chcon -c -v -R -u system_u -r object_r -t textrel_shlib_t /usr/local/apache/modules/libphp5.so
# service httpd restart vi /usr/local/apache/conf/httpd.conf 查找 在此范围添加 AddType application/x-httpd-php .php 然CPOPY PHP的配置文件 cp ../php-5.2.10/php.ini.dist /usr/local/php/lib/php.ini 修改php.ini文件 ok!重新启动一下apache服务器 然后写个php测试页info.php:内容如下 <?php |