目录

Lamp Linux+apache+mysql+php

系统及软件版本:linux 6.5_x64 apache2.2.31 php5.3.28 mysql5.1.73

Mysql安装-请参考文档:Mysql5.1二进制免编译安装

Apache安装

1
2
3
4
5
6
7
8
9
[root@lamp mysql]# cd /usr/local/src/
[root@lamp src]# wget http://mirrors.sohu.com/apache/httpd-2.2.31.tar.gz
[root@lamp src]# tar zxvf httpd-2.2.31.tar.gz
[root@lamp httpd-2.2.31]# yum install -y gcc pcre pcre-devel apr apr-devel zlib-devel
[root@lamp httpd-2.2.31]# ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre
[root@lamp httpd-2.2.31]# /usr/local/apache2/bin/apachectl start
[root@lamp httpd-2.2.31]# ps aux | grep httpd
[root@lamp httpd-2.2.31]# netstat -lnp | grep 80
[root@lamp httpd-2.2.31]# /usr/local/apache2/bin/apachectl graceful #重新加载服务

安装php

[root@lamp src]# wget http://cn2.php.net/distributions/php-5.3.28.tar.gz [root@lamp src]# tar zxvf php-5.3.28.tar.gz [root@lamp php-5.3.28]# yum install -y epel-release [root@lamp php-5.3.28]# yum install -y perl libjpeg-devel libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel libmcrypt-devel [root@lamp php-5.3.28]# ./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-config-file-path=/usr/local/php/etc –with-mysql=/usr/local/mysql –with-libxml-dir –with-gd –with-jpeg-dir –with-png-dir –with-freetype-dir –with-iconv-dir –with-zlib-dir –with-bz2 –with-openssl –with-mcrypt –enable-soap –enable-gd-native-ttf –enable-mbstring –enable-sockets –enable-exif –disable-ipv6 [root@lamp php-5.3.28]# make && make install [root@lamp php-5.3.28]# cp php.ini-production /usr/local/php/etc/php.ini [root@lamp php-5.3.28]# ls /usr/local/apache2/modules/libphp5.so

1
2

## php结合apache配置

[root@lamp php-5.3.28]# vi /usr/local/apache2/conf/httpd.conf

Options FollowSymLinks AllowOverride None Order deny,allow Deny from all 改为: Options FollowSymLinks AllowOverride None Order deny,allow Allow from all

找到:AddType application/x-gzip .gz .tgz在该行下面添加:AddType application/x-httpd-php .php

找到: DirectoryIndex index.html 将该行改为: DirectoryIndex index.html index.htm index.php 找到:#ServerName www.example.com:80修改为:ServerName localhost:80 [root@lamp php-5.3.28]# /usr/local/apache2/bin/apachectl -t [root@lamp php-5.3.28]# /usr/local/apache2/bin/apachectl restart [root@lamp php-5.3.28]# cat /usr/local/apache2/htdocs/info.php

[root@lamp php-5.3.28]# curl 192.168.216.135/info.php

1
2
3