在RHEL或CentOS下简单的搭建LAMP环境的方法~

Install Apache, MySQL 5.5.30 & PHP 5.4.12 on RHEL 6.4/6.3/6.2/6.1/6.0/5.9/5.8/5.6,CentOS 6.4/6.3/6.2/6.1/6.0/5.9/5.8/5.6 and Fedora 12,13,14,15,16,17,18
第一步: 安装配置Remi源

Remi 源是包含最新版本 PHP 和 MySQL 包的 Linux 源,由 Remi 提供维护。有个这个源之后,使用 YUM 安装或更新 PHP、MySQL、phpMyAdmin 等服务器相关程序的时候就非常方便了。


Remi 也提供了自动安装源的 rpm 包,安装和使用都很简单。




  1. ## Install Remi Repository on Fedora 18, 17, 16, 15 ##
  2. rpm -Uvh http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm 
  3. rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm

  4. ## Fedora 18 ##
  5. # rpm -Uvh http://rpms.famillecollet.com/remi-release-18.rpm

  6. ## Fedora 17 ##
  7. # rpm -Uvh http://rpms.famillecollet.com/remi-release-17.rpm

  8. ## Fedora 16 ##
  9. # rpm -Uvh http://rpms.famillecollet.com/remi-release-16.rpm

  10. ## Fedora 15 ##
  11. # rpm -Uvh http://rpms.famillecollet.com/remi-release-15.rpm

  12. ## Fedora 14 ##
  13. # rpm -Uvh http://rpms.famillecollet.com/remi-release-14.rpm

  14. ## Fedora 13 ##
  15. # rpm -Uvh http://rpms.famillecollet.com/remi-release-13.rpm

  16. ## Fedora 12 ##
  17. # rpm -Uvh http://rpms.famillecollet.com/remi-release-12.rpm

  18. ## Install Remi & Epel Repository on RHEL/CentOS 6.4-6.0 - 32 Bit ##
  19. rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
  20. rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm 

  21. ## Install Remi & Epel Repository on RHEL/CentOS 6.4-6.0 - 64 Bit ##
  22. rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
  23. rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm 

  24. ## Install Remi Repository on RHEL/CentOS 5.9-5.0 - 32 Bit ##
  25. rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
  26. rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm

  27. ## Install Remi Repository on RHEL/CentOS 5.9-5.0 - 64 Bit ##
  28. rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
  29. rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
复制代码
第二步: 安装Apache, MySQL 5.5.30 & PHP 5.4.12
  1. ## Installing on Fedora 12, 13, 14, 15, 16, 17, 18 ##
  2. # yum --enablerepo=remi install httpd mysql mysql-server php php-common

  3. ## Installing on RHEL/CentOS 5-6 ##
  4. # yum --enablerepo=remi,remi-test install httpd mysql mysql-server php php-common
复制代码
第三步: 安装PHP 5.4.12 模块
  1. ## Installing on Fedora 12, 13, 14, 15, 16, 17, 18 ##
  2. # yum --enablerepo=remi install php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdo

  3. ## Installing on RHEL/CentOS 5-6 ##
  4. # yum --enablerepo=remi,remi-test install php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdo
复制代码
第四步: 启动Apache & MySQL 5.5.30服务
  1. ## Enable Apache and MySQL on Run-Levels ##
  2. # chkconfig --levels 235 httpd on
  3. # chkconfig --levels 235 mysqld on

  4. ## Apache Commands ## 
  5. # /etc/init.d/httpd start
  6. # /etc/init.d/httpd stop
  7. # /etc/init.d/httpd status

  8. ## MySQL Commands ## 
  9. # /etc/init.d/mysqld start
  10. # /etc/init.d/mysqld stop
  11. # /etc/init.d/mysqld status
复制代码
第五步: 验证Apache, MySQL 5.5.30 和 PHP 5.4.12的安装情况
1. 创建一个 phpinfo.php 的页面文件在apache的访问目录文件下,即 (/var/www/html/phpinfo.php).文件内容如下:
  1. <?php
  2.      phpinfo ();
  3. ?>
复制代码
2. 然后打开浏览器访问 http://localhost/phpinfo.php. 你会看到如下页面:
01.png 


02.jpg



如果显示正常,说明你的LAMP环境基本搭建完成,接着就是在/etc下面做具体的配置工作喽!~

【欢迎各位访问远景Linux论坛版块哦,地址:http://bbs.pcbeta.com/forum-509-1.html】

你可能感兴趣的:(linux,PHP,lamp,搭建)