系统环境 :CentOS 5.4
软件版本:httpd-2.2.17.tar.bz2 mysql-5.1.53.tar.gz php-5.2.17.tar.bz2
环境:yum install make gcc gcc-c++ libxml2 libxml2-devel libmcrypt libmcrypt-devel libtool-ltdl apr apr-* ncurses ncurses-*
安装mysql:
#tar -zxvf mysql-5.1.53.tar.gz
#cd mysql-5.1.53
#/usr/sbin/groupadd mysql
#/usr/sbin/useradd mysql -g mysql
#./configure --prefix=/opt/mysql --localstatedir=/opt/mysql/data/ --with-server-suffix=-enterprise-gpl --without-debug --with-big-tables --with-extra-charsets=gb2312,utf8,GBK --with-extra-charsets=all --with-pthread --enable-thread-safe-client --enable-static --with-client-ldflags=-all-static --with-mysqld-ldflags=-all-static --enable-assembler --without-innodb --without-ndb-debug --without-isam
#make(时间会很长、优化的比较多)
#make install
#mkdir -p /opt/mysql/data
#cd /opt/mysql
#bin/mysql_install_db --user=mysql
注:Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/opt/mysql/bin/mysqladmin -u root password \'new-password\'
/opt/mysql/bin/mysqladmin -u root -h xsl228 password \'new-password\'
Alternatively you can run:
/opt/mysql/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd /opt/mysql ; /opt/mysql/bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /opt/mysql/mysql-test ; perl mysql-test-run.pl
Please report any problems with the /opt/mysql/bin/mysqlbug script!
#chown -R mysql.mysql .
#chown -R mysql.mysql /opt/mysql/data
#cp share/mysql/my-medium.cnf /etc/my.cnf
#cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
#chmod 755 /etc/rc.d/init.d/mysqld
#/opt/mysql/bin/mysqld_safe -user=mysql &
如果mysql不成功,查看下mysql的错误日志
apache安装:
#tar -jxvf httpd-2.2.17.tar.bz2
#cd httpd-2.2.17
#./configure --prefix=/opt/bokee/apache2 --enable-so --enable-rewrite --enable-mods-shared=all --enable-vhost-alias=shared --enable-cache=shared --enable-file-cache=shared --enable-disk-cache=shared --enable-mem-cache=shared --enable-proxy=shared --enable-proxy-http=shared --enable-proxy-connect=shared --disable-proxy-ftp --disable-userdir --disable-asis --enable-ssl
#make
#make install
#/opt/bokee/apache2/bin/apachectl start
启动apache会报错,但是还是可以启动
编辑下/opt/bokee/apache2/conf/httpd.conf
ServerName 127.0.0.1
重启apache服务就可以正常启动了
php安装:
yum install libxml2* libpng* libjpeg* freetype* gd gd-* libxslt* zlib* libtool* php-pear php-pdo
#tar -jxvf php-5.2.17.tar.bz2
#cd php-5.2.17
#./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-apxs2=/opt/bokee/apache2/bin/apxs --with-mysql=/opt/bokee/mysql --with-mysqli=/opt/bokee/mysql/bin/mysql_config --with-gd --enable-gd-native-ttf --with-jpeg-dir --with-png-dir --with-zlib --with-freetype-dir --with-libxml-dir --with-xsl --enable-sqlite-utf8 --with-iconv --enable-mbstring=all --disable-debug --with-pear ---enable-sockets
注:+--------------------------------------------------------------------+
| License: |
| This software is subject to the PHP License, available in this |
| distribution in the file LICENSE. By continuing this installation |
| process, you are bound by the terms of this license agreement. |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point. |
+--------------------------------------------------------------------+
Thank you for using PHP.
#make
注:Build complete.
Don\'t forget to run \'make test\'.
#make install
注:Installing PHP SAPI module: apache2handler
/opt/bokee/apache2/build/instdso.sh SH_LIBTOOL=\'/usr/lib/apr-1/build/libtool\' libphp5.la /opt/bokee/apache2/modules
/usr/lib/apr-1/build/libtool --mode=install cp libphp5.la /opt/bokee/apache2/modules/
cp .libs/libphp5.so /opt/bokee/apache2/modules/libphp5.so
cp .libs/libphp5.lai /opt/bokee/apache2/modules/libphp5.la
libtool: install: warning: remember to run `libtool --finish /home/weijunping/php-5.2.17/libs\'
chmod 755 /opt/bokee/apache2/modules/libphp5.so
[activating module `php5\' in /opt/bokee/apache2/conf/httpd.conf]
Installing PHP CLI binary: /usr/local/php5/bin/
Installing PHP CLI man page: /usr/local/php5/man/man1/
Installing build environment: /usr/local/php5/lib/php/build/
Installing header files: /usr/local/php5/include/php/
Installing helper programs: /usr/local/php5/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php5/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php5/lib/php/
[PEAR] Archive_Tar - installed: 1.3.7
[PEAR] Console_Getopt - installed: 1.2.3
[PEAR] Structures_Graph- installed: 1.0.3
[PEAR] XML_Util - installed: 1.2.1
[PEAR] PEAR - installed: 1.9.1
Wrote PEAR system config file at: /usr/local/php5/etc/pear.conf
You may want to add: /usr/local/php5/lib/php to your php.ini include_path
Installing PDO headers: /usr/local/php5/include/php/ext/pdo/
#cp php.ini-dist /usr/local/php5/etc/php.ini
#vi /usr/local/php5/etc/php.ini
将register_globals = Off改为register_globals = On
整合apache 与php
1、
#vi /opt/apache2.2.17/conf/httpd.conf 些模块简单的修改
在配置文件中添加如下:
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
2、
查找:(设置 WEB 默认文件)
DirectoryIndex index.html
替换为:
DirectoryIndex index.php index.html index.htm //在 WEB 目录不到默认文件,httpd 就会执行 /var/www/error/noindex.html
3、
找到这一段:
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride none
更改为AllowOverride all
允许apache rewrite
●测试服务器
1、测试PHP
进入Apache默认主目录DocumentRoot "/opt/bokee/apache2/htdocs",在该目录下建一个test.php文件
#vi test.php 写入以一内容
<?phpinfo();?>
然后在浏览器中看
http://ip/test.php
以上为LAMP环境的搭建