LAMP就是Linux+Apache+MySql+PHP搭建的动态网站环境,是目前互联网上非常流行的一个网页服务组合。
网上有很多教程搭建LAMP环境,基本上都是编译安装的,其实对新手来说只需要了解LAMP环境的一些特性,RMP安装相对来说容易上手点,只需要安装几个光盘上的安装包就可以顺利完成LAMP的搭建。
安装Apache
[root@linux-a ~]# rpm -ivh /media/Server/httpd-2.2.3-6.el5.i386.rpm
warning: /media/Server/httpd-2.2.3-6.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
libapr-1.so.0 is needed by httpd-2.2.3-6.el5.i386
libaprutil-1.so.0 is needed by httpd-2.2.3-6.el5.i386
[root@linux-a ~]#
提示需要libapr-1.so.0和libaprutil-1.so.0的支持
安装libapr-1.so.0
[root@linux-a ~]# rpm -ivh /media/Server/apr-1.2.7-11.i386.rpm
warning: /media/Server/apr-1.2.7-11.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:apr ########################################### [100%]
apr-util-1.2.7-6.i386.rpm 需要postgresql-libs的支持
安装libpq.so.4
[root@linux-a ~]# rpm -ivh /media/Server/postgresql-libs-8.1.4-1.1.i386.rpm
warning: /media/Server/postgresql-libs-8.1.4-1.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:postgresql-libs ########################################### [100%]
[root@linux-a ~]#
安装libaprutil-1.so.0
[root@linux-a ~]# rpm -ivh /media/Server/apr-util-1.2.7-6.i386.rpm
warning: /media/Server/apr-util-1.2.7-6.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:apr-util ########################################### [100%]
[root@linux-a ~]#
安装Apache
[root@linux-a ~]# rpm -ivh /media/Server/httpd-2.2.3-6.el5.i386.rpm
warning: /media/Server/httpd-2.2.3-6.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:httpd ########################################### [100%]
[root@linux-a ~]#
安装MySql
mysql需要perl(DBI)和perl-DBD-MySQL的支持,因此先安装perl-DBI及perl-DBD-MySQL
perl-DBI安装
[root@linux-a ~]# rpm -ivh /media/Server/perl-DBI-1.52-1.fc6.i386.rpm
warning: /media/Server/perl-DBI-1.52-1.fc6.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:perl-DBI ########################################### [100%]
[root@linux-a ~]#
perl-DBD-MySQL安装
[root@linux-a ~]# rpm -ivh /media/Server/perl-DBD-MySQL-3.0007-1.fc6.i386.rpm
warning: /media/Server/perl-DBD-MySQL-3.0007-1.fc6.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:perl-DBD-MySQL ########################################### [100%]
[root@linux-a ~]#
开始安装mysql
[root@linux-a ~]# rpm -ivh /media/Server/mysql-5.0.22-2.1.i386.rpm
warning: /media/Server/mysql-5.0.22-2.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:mysql ########################################### [100%]
[root@linux-a ~]#
安装mysql server
[root@linux-a ~]# rpm -ivh /media/Server/mysql-server-5.0.22-2.1.i386.rpm
warning: /media/Server/mysql-server-5.0.22-2.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:mysql-server ########################################### [100%]
[root@linux-a ~]#
初始化MySql数据库
[root@linux-a ~]# mysql_install_db
Installing all prepared tables
Fill help tables
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:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h linux-a.test.com password 'new-password'
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &
You can test the MySQL daemon with the benchmarks in the 'sql-bench' directory:
cd sql-bench ; perl run-all-tests
Please report any problems with the /usr/bin/mysqlbug script!
The latest information about MySQL is available on the web at
http://www.mysql.com
Support MySQL by buying support/licenses at http://shop.mysql.com
[root@linux-a ~]#
修改mysql配置文件
[root@linux-a ~]# cp /usr/share/doc/mysql-server-5.0.22/my-medium.cnf /etc/my.cnf
更多设置请参考 [Redhat Linux下MySql数据库的安装配置及简单操作]
安装php
PHP需要libgmp.so.3、php-cli、php-common的支持
[root@linux-a ~]# rpm -ivh /media/Server/php-5.1.6-5.el5.i386.rpm
warning: /media/Server/php-5.1.6-5.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
error: Failed dependencies:
libgmp.so.3 is needed by php-5.1.6-5.el5.i386
php-cli = 5.1.6-5.el5 is needed by php-5.1.6-5.el5.i386
php-common = 5.1.6-5.el5 is needed by php-5.1.6-5.el5.i386
libgmp.so.3安装
[root@linux-a ~]# rpm -ivh /media/Server/gmp-4.1.4-10.el5.i386.rpm
warning: /media/Server/gmp-4.1.4-10.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:gmp ########################################### [100%]
安装php-common
[root@linux-a ~]# rpm -ivh /media/Server/php-common-5.1.6-5.el5.i386.rpm
warning: /media/Server/php-common-5.1.6-5.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:php-common ########################################### [100%]
[root@linux-a ~]#
安装php-cli
[root@linux-a ~]# rpm -ivh /media/Server/php-cli-5.1.6-5.el5.i386.rpm
warning: /media/Server/php-cli-5.1.6-5.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:php-cli ########################################### [100%]
[root@linux-a ~]#
安装PHP
[root@linux-a ~]# rpm -ivh /media/Server/php-5.1.6-5.el5.i386.rpm
warning: /media/Server/php-5.1.6-5.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:php ########################################### [100%]
[root@linux-a ~]#
另外还需要安装PHP-MySql,PHP-MySql需要php-pdo的支持
安装php-pdo
[root@linux-a ~]# rpm -ivh /media/Server/php-pdo-5.1.6-5.el5.i386.rpm
warning: /media/Server/php-pdo-5.1.6-5.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:php-pdo ########################################### [100%]
[root@linux-a ~]#
安装PHP-MySql
[root@linux-a ~]# rpm -ivh /media/Server/php-mysql-5.1.6-5.el5.i386.rpm
warning: /media/Server/php-mysql-5.1.6-5.el5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
Preparing... ########################################### [100%]
1:php-mysql ########################################### [100%]
[root@linux-a ~]#
测试配置:
安装好之后Apache的配置文件在/etc/httpd/conf/httpd.conf 基本不需要修改,详细设置参数可以参考[Apache2配置文件httpd.conf中文版 (转)]
编译安装php之后都需要手动修改Apache的配置文件,这里不需要修改,安装PHP时会生成一个/etc/httpd/conf.d/php.conf 文件,Apache配置文件可以直接饮用这个配置
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
LoadModule php5_module modules/libphp5.so
#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps
如果是编译安装的话只需要将上面红色的文字加到/etc/httpd/conf.d/php.conf 配置文档中就可以了。
php的配置文件在/etc/php.ini ,也不需要修改,除非你需要配置一些高级功能。
MySql的配置文件在/etc/my.cnf。
启动Apache和MySql服务
在网页目录下建立一个php测试文件,如果能出现正确的php环境信息说明安装已经成功。
[root@linux-a ~]# vim /var/www/html/index.php
<?
phpinfo();
?>
上传一个WordPress程序到/var/www/html/目录下,将其目录的权限修改为777,进行WordPress安装测试,这样一个LAMP环境就搭建起来了。
|