Redhat Linux通过RPM安装搭建LAMP环境
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環境就搭建起來了。
轉載于:https://blog.51cto.com/itafei/1834665
總結
以上是生活随笔為你收集整理的Redhat Linux通过RPM安装搭建LAMP环境的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 自定义获取html元素对象的7种方法。
- 下一篇: FreeMarker 自动转义和格式化H