rhel下,使用yum搭建lamp

 1. 首先安装bzip2-devel  zlib-devel;这两个包是压缩库,让LAMP支持压缩的一些功能。

           libjpeg-devel  libpng-devel  libtiff-devel;这几个是LAMP图片的调用和处理图片要调用的一些开发库的信息,GD库要依赖于这些包;
           openssl-devel;主要提供https的加密传输,和一些加密功能;
 
2. 通过YUM安装apache,yum install httpd;设置开机自启动:chkconfig httpd on;启动apache:service httpd start;
 
3. 安装mysql-devel;在lamp平台上安装的一些程序如果需要调用mysql信息,并且我们的mysql是通过rpm安装的,那么这个包就必须得装。
 
4. 安装GD库,支持验证码和验证码图片: gd-devel;
 
5. 通过YUM安装mysql-server,yum install mysql-server;设置开机自启动:chkconfig mysql on;启动mysql:service mysqld start;
 
启动,设置,测试mysql的管理员和管理员密码:
 
[root@localhost ~]# service mysqld start           #启动mysql;
初始化 MySQL 数据库: 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 localhost.localdomain 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
                                                           [确定]
启动 MySQL:                                               [确定]
 
[root@localhost ~]# mysqladmin -u root password 123456        ##设置mysql管理员及密码;
 
[root@localhost ~]# mysql -u root -p                          ###用账户root登陆mysql;
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10 to server version: 5.0.22
 
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
 
mysql> show databases;         ####显示现有数据库;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| test               |
+--------------------+
3 rows in set (0.00 sec)
 
mysql> use mysql                #####使用数据库;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
 
Database changed
mysql> show tables;             ######显示数据库中的表;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| func                      |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| proc                      |
| procs_priv                |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
17 rows in set (0.00 sec)
 
mysql> \h                      #####查看帮助文件;
 
For information about MySQL products and services, visit:
   http://www.mysql.com/
For developer information, including the MySQL Reference Manual, visit:
   http://dev.mysql.com/
To buy MySQL Network Support, training, or other products, visit:
   https://shop.mysql.com/
 
List of all MySQL commands:
Note that all text commands must be first on line and end with ';'
?         (\?) Synonym for `help'.
clear     (\c) Clear command.
connect   (\r) Reconnect to the server. Optional arguments are db and host.
delimiter (\d) Set statement delimiter. NOTE: Takes the rest of the line as new delimiter.
edit      (\e) Edit command with $EDITOR.
ego       (\G) Send command to mysql server, display result vertically.
exit      (\q) Exit mysql. Same as quit.
go        (\g) Send command to mysql server.
help      (\h) Display this help.
nopager   (\n) Disable pager, print to stdout.
notee     (\t) Don't write into outfile.
pager     (\P) Set PAGER [to_pager]. Print the query results via PAGER.
print     (\p) Print current command.
prompt    (\R) Change your mysql prompt.
quit      (\q) Quit mysql.
rehash    (\#) Rebuild completion hash.
source    (\.) Execute an SQL script file. Takes a file name as an argument.
status    (\s) Get status information from the server.
system    (\!) Execute a system shell command.
tee       (\T) Set outfile [to_outfile]. Append everything into given outfile.
use       (\u) Use another database. Takes database name as argument.
charset   (\C) Switch to another charset. Might be needed for processing binlog with multi-byte charsets.
warnings  (\W) Show warnings after every statement.
nowarning (\w) Don't show warnings after every statement.
 
For server side help, type 'help contents'
 
mysql> quit        #退出;
Bye
[root@localhost ~]#
 
mysql工作正常,完成。
 
6. 安装php
 
   php安装php5.2.1以上的版本。我使用的是RHEL5.1,默认php是5.1.6.需要另找php的安装包。
    免费是王道,我的做法是使用centos的php5.2的rpm包。经过测试,所有php的包都应该是统一版本的rpm包。将下载到的php包添加到本地的yum库中,重新建立索引文件。即可通过yum安装该php的rpm包,并自动解决依赖关系。
    yum安装时若出现:“Package ************.rpm is not signed”的错误,使用rpm -ivh *********.rpm 命令安装即可解决。
 
    测试php安装效果:
 
    编辑apache的配置文件,在DirectoryIndex index.html index.html.var 后添加index.php;
    在apache的默认目录下创建index.php文件测试php;
    index.php为简单的php脚本:
    
    <?php
      phpinfo();
     ?>    
    通过浏览器打开本机ip,显示php的信息,则php安装没有问题。
 
   可以根据需要选择安装php的扩展包。
 
    我使用的是:
    php52-dba-5.2.14-1.YMCc5.1
    php52-mcrypt-5.2.14-1.YMCc5.1
    php52-pdo-5.2.14-1.YMCc5.1
    php52-common-5.2.14-1.YMCc5.1
    php52-mysql-5.2.14-1.YMCc5.1
    php52-gd-5.2.14-1.YMCc5.1 
    php52-cli-5.2.14-1.YMCc5.1
    php52-devel-5.2.14-1.YMCc5.1
    php52-xml-5.2.14-1.YMCc5.1
    php52-5.2.14-1.YMCc5.1
    php52-soap-5.2.14-1.YMCc5.1
    php52-ldap-5.2.14-1.YMCc5.1
 
    其中安装php52-mcrypt是一个比较费劲的事情,它依赖两个包,其中一个依赖包很费劲。安装时会提示需要libltdl.so.3和libmcrypt.so.4。
    通过google找到这个问题的解决办法,综合测试修改后如下:
    库文件也在yum库中,也是安装rpm包;通过google找到libltdl.so.3的安装包为libtool-lib,libmcrypt.so.4的安装包libmcrypt,建议将devel开发包也装上。libtool-ltdl的rpm包光盘中有,直接安装即可;libmcrypt的rpm包光盘中没有,需要网上下载。经过不断的反复的测试,libmcrypt-2.5.7-4.el4.centos.i386.rpm和libmcrypt-devel-2.5.7-4.el4.centos.i386.rpm适合我的安装环境。
    
    安装完成后,重启apache服务,使用另外一台电脑的浏览器访问,显示正确。
 

你可能感兴趣的:(职场,lamp,yum,RHEL,休闲)