zoukankan      html  css  js  c++  java
  • CentOS5.3下搭建LAMP(php运行环境:CentOS5.3+Apache2.2+mysql+php)附centos5.3镜像

    LAMP即Linux+Apache+MySQL+PHP

    centos5.3 64位镜像

    下载链接: http://pan.baidu.com/s/11QxVw 密码: 5zq6

    第一步:安装Apache2

    1.切换到root用户, 输入yum install httpd, 选择yes, 自动安装,

    2.版本:httpd-2.2.3-82.el5.centos.x86_64.rpm

    3.启动:/etc/init.d/httpd start

    4.重启:/etc/init.d/httpd restart

    5.停止:/etc/init.d/httpd stop

    6.查看运行状态:/etc/init.d/httpd status

    关于apache的一些配置文件

    1./etc/httpd/conf/httpd.conf:最主要的配置文件;
    2./etc/httpd/conf.d/*.conf:这个是 CentOS 的特色, 如果你不想修改原始配置文件 httpd.conf 的话, 其他配置的在此独立配置, 启动 apache 时, 这个文件就会被读入到主要配置文件;
    3./usr/lib/httpd/modules:apache 支持很多的模块, 您想要使用的模块默认都放置在此目录;
    4./var/www/html:这里是 CentOS 默认的"首页"目录;

    5./var/www/error:默认的系统错误信息, 主机设置错误或浏览器端要求的数据错误, 在浏览器上出现的错误提示就以这里的信息为主;
    6./var/www/icons:提供 apache 的一些小图标;
    7./var/www/cgi-bin:默认一些可执行的 CGI 程序放置的目录;
    8./var/log/httpd:日志文件目录, 这里的文件很容易变的很大, 需要提供足够的空间;
    9./usr/sbin/apachectl:这是 Apache 的主要执行文件, 这个执行文件其实是 shell script, 它可以主动检测系统上的一些设置值, 好让您启动 Apache 时更简单;
    10./usr/sbin/httpd:这是主要的 apache 的二进制文件;
    11./usr/bin/htpasswd:当您想登陆某些网页时, 需要输入账号与密码. 那么Apache本身就提供一个最基本的密码保护方式, 该密码的产生就是通过这个命令实现的.

    第二步:安装MySQL

    1.安装命令:yum install mysql mysql-server

    2.版本: mysql.i386 0:5.0.95-5.el5_9

                mysql.x86_64 0:5.0.95-5.el5_9

                mysql-server.x86_64 0:5.0.95-5.el5_9

    3.启动服务:/etc/init.d/mysqld start

    4.查看状态:/etc/init.d/mysqld status

    5.设置root用户密码:mysqladmin -u root -p password 123456

       Enter password:一般初始密码为空, 直接回车即可, 如果不是新用户则输入原密码

    6.如果初始密码不为空, 或者忘记密码, 可通过以下方式重置root密码:

       先停止mysql服务:/etc/init.d/mysqld stop

       开启mysql安全模式:mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

       开启新终端, 先切到root用户, 进入mysql, 

    [root@localhost /]# mysql -u root mysql
    mysql> update user set password=password('leaf') where user='root';
    Query OK, 3 rows affected (0.01 sec)
    Rows matched: 3  Changed: 3  Warnings: 0
    mysql> FLUSH PRIVILEGES;
    Query OK, 0 rows affected (0.00 sec)
    mysql> quit;
    Bye

      停止安全模式:/etc/init.d/mysqld stop

      重新启动:/etc/init.d/mysqld start

    7.登陆mysql:mysql -u root -p
       Enter password:密码

    8./etc/my.cnf:这是Mysql的配置文件, 包括mysql 数据库的优化;
       /usr/lib/mysql:这个目录是 MySQL 数据库放置的位置, 务必在备份时将此目录完整的备份下来

    第三步:安装php5

    1.命令:yum install php, 自行安装, 选yes, 安装过程很简单.

    2.重启apache:/etc/init.d/httpd restart

    3.测试. 在/var/www/html/ 下新建一个文件test.php

    <html>
    <body>
    <?php
    phpinfo();
    ?>
    </body>
    </html>

    在浏览器中打开http://localhost/test.php , 会看到很多php的信息, 到此已经成功一大半了

    第四步:使php支持mysql

    1.安装所需要的支持包,

    命令:yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc

            yum install php-mysql

    2.重启apache:/etc/init.d/httpd restart

    3.在浏览器中打开http://localhost/test.php , 会看到mysql的信息

    第五步:配置apache和mysql开机启动

    1.如系统中没有chkconfig, 需先安装chkconfig. 命令为:yum install chkconfig

    2.在切换到root用户时, 要使用 su -, 没有-是不行的.
    [root@localhost ~]# chkconfig --levels 3 httpd on
    [root@localhost ~]# chkconfig --list httpd
    httpd           0:off   1:off   2:off   3:on    4:off   5:off   6:off
    [root@localhost ~]# chkconfig --levels 3 mysqld on
    [root@localhost ~]# chkconfig --list mysqld
    mysqld          0:off   1:off   2:off   3:on    4:off   5:off   6:off

    关于chkconfig的详细用法后续会介绍

    到此LAMP搭建完成

  • 相关阅读:
    docker compose 配置 redis cluster jenkins
    Spring Core
    Java Case Interview two
    pytest 生成 allure报告(含4要素的对应版本,兼容)
    python中requests库的post请求 4种类型参数
    接口测试流程
    Docker学习篇 搭建jenkins
    Pytest入门 实例
    python selenium css定位6种
    python selenium select标签的下拉框和非select标签的下拉框
  • 原文地址:https://www.cnblogs.com/leaf1117/p/3368980.html
Copyright © 2011-2022 走看看