CentOS配置Lamp

1.安装Apache
自带Apache
centos6.4本身自带Apache,默认没有开启

[root@ceshi Desktop]# rpm -q httpd
httpd-2.2.15-26.el6.centos.i686

[root@ceshi Desktop]# rpm -qa | grep httpd
httpd-tools-2.2.15-26.el6.centos.i686
httpd-2.2.15-26.el6.centos.i686
用不用安装扩展呢?

[root@ceshi Desktop]# yum search all httpd
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile

  • base: mirrors.yun-idc.com

  • extras: mirrors.yun-idc.com

  • updates: mirrors.tuna.tsinghua.edu.cn
    ============================================================================ Matched: httpd ============================================================================
    libmicrohttpd-doc.noarch : Documentation for libmicrohttpd
    httpd-devel.i686 : Development interfaces for the Apache HTTP server
    httpd-manual.noarch : Documentation for the Apache HTTP server
    httpd-tools.i686 : Tools for use with the Apache HTTP Server
    libmicrohttpd.i686 : Lightweight library for embedding a webserver in applications
    libmicrohttpd-devel.i686 : Development files for libmicrohttpd
    httpd.i686 : Apache HTTP Server
    mod_dav_svn.i686 : Apache httpd module for Subversion server
    mod_dnssd.i686 : An Apache HTTPD module which adds Zeroconf support
    mod_auth_mellon.i686 : A SAML 2.0 authentication module for the Apache Httpd Server
    mod_lookup_identity.i686 : Apache module to retrieve additional information about the authenticated user
    mod_ssl.i686 : SSL/TLS module for the Apache HTTP Server

    开启Apache服务

    参考http://blog.sina.com.cn/s/blog_70ac6bec01018mqs.html
    如果apache安装成为linux的服务的话,可以用以下命令操作:
    service httpd start 启动
    service httpd restart 重新启动
    service httpd stop 停止服务

    设置Apache服务为开机启动

    参考http://www.cnblogs.com/Anker/p/3551508.html
    http://www.jb51.net/article/74603.htm

    chkconfig --list | grep httpd
    chkcongfig httpd on 设置httpd每次开机自己启动,但并不现在就启动。运行级别2345都为on
    service httpd start 现在启动httpd服务,但是下次开机不会自动启动

    此时只能虚拟机本机访问80端口,因为iptables中没有开放80端口
    此时iptables的运行级别2345都是on
    关闭iptables
    关闭命令: service iptables stop
    永久关闭防火墙:chkconfig iptables off
    查看iptables状态 :service iptables status

    查看当前iptables状态
    iptables -L -n
    service iptables status
    此时在物理机用nmap扫描只能扫面到一个22端口

    iptables中添加80端口
    参考
    http://blog.csdn.net/youcharming/article/details/41986709
    http://www.2cto.com/os/201304/201164.html

    /sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
    /etc/rc.d/init.d/iptables save 或者 service iptables save #保存配置
    /etc/rc.d/init.d/iptables restart 或者 service iptables restart #重启服务

    重装Apache
    直接yum install httpd 会对本身安装的Apache进行升级。现在只有2.2版本的
    要想安装2.4版本的可以下载安装包自己安装
    2.安装mysql
    用户名 root
    密码 root
    参考
    http://www.cnblogs.com/xiaoluo501395377/archive/2013/04/07/3003278.html
    http://www.cnblogs.com/zgaspnet/p/3967002.html
    http://jingyan.baidu.com/article/acf728fd10c3d6f8e510a3ef.html
    http://jingyan.baidu.com/article/c74d600079be530f6a595dc3.html
    有内容可借鉴
    自带mysql
    本虚拟机的mysql是通过rpm 安装的不是原版自带的
    查看安装的mysql
    rpm -qa | grep mysql
    yum search all mysql

[root@ceshi Desktop]# rpm -qa | grep mysql
mysql-5.1.73-3.el6_5.i686
mysql-server-5.1.73-3.el6_5.i686
mysql-libs-5.1.73-3.el6_5.i686
本centos默认没有安装mysql-devel

注:安装mysql只是安装了数据库,只有安装mysql-server才相当于安装了客户端。
	查看安装的数据库信息
	
	rpm -qi mysql
	rpm -qi mysql-server
	
	开启mysql服务
	service mysqld start
	添加mysql服务到开机启动
	chkconfig mysqld on
	查看是否添加成功。运行级别2345变为on则陈功
	chkconfig --list | grep mysqld
	
	查看端口:netstat -tnlp,显示3306 已经开启
	查看iptables开放端口:service iptables status
	iptables中添加3306端口
		/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
		/etc/rc.d/init.d/iptables save  或者 service iptables save #保存配置 
		/etc/rc.d/init.d/iptables restart 或者 service iptables restart #重启服务
	
	参考
	http://www.fedora.hk/linux/fuwu/show_18.html

	设置初始密码
		yum 安装的mysql初始密码为空

mysql -u root root空密码登陆
select user,host,password from mysql.user; 查看用户信息
show databases;

设置root用户的密码
set password for root@localhost=password ('在这里填入root密码');
set password for root@127.0.0.1=password ('在这里填入root密码');
set password for root@localhost.localdomain=password ('在这里填入root密码'); 绿色的是主机名

此时匿名账号是可以登陆的,但是为什么只显示2个数据库呢?
mysql -u -p
mysql> show databases;
+----------------------------------+
| Database |
+----------------------------------+
| information_schema |
| test |
+----------------------------------+

删除匿名登录账号
delete from mysql.user where user='';
刷新
flush privileges;

	允许远程连接

CREATE USER 'root'@'%' IDENTIFIED BY '您的密码'; ← 增加root用户指定可以任意IP登录,如果想限制只能让指定IP登录请把%替换成IP地址

GRANT ALL PRIVILEGES ON * . * TO 'root'@'%' IDENTIFIED BY '你的密码' WITH GRANT OPTION MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; ← 给新添加的root增加权限

刷新
flush privileges;

重装mysql
	直接yum 会显示升级
	可以下载安装包自己安装

3.安装php

参考
http://www.cnblogs.com/liulun/p/3535346.html

yum方式安装
查看是否安装
rpm -qi php
本centos6.4 默认没有安装

安装php
yum install php 
(没有安装php-devel)

重启apache使php生效	/etc/init.d/httpd restart

此时可以在目录:/var/www/html/下建立一个PHP文件
代码:<?php phpinfo(); ?>
访问此文件成功

安装php扩展

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

(yum search all php 搜索所有扩张)
安装包安装

4.安装phpmyadmin
yum方式安装
参考
http://blog.csdn.net/rachel_luo/article/details/8692744
http://www.cnblogs.com/shenliang123/p/3829044.html
http://blog.csdn.net/rachel_luo/article/details/8692744
http://blog.csdn.net/licongcong_0224/article/details/15041939

yum install phpMyAdmin
无法找到这个包
测试过的解决办法
yum -y update 不行
yum clean all 不行
应该是yum 源中没有

本虚拟机一直使用的是国内的源,没有使用国外源
安装包方式安装
直接把phpMyAdmin复制到html下
访问http://192.168.1.203/phpMyAdmin/ 即可登陆成功,
config.sample.inc.php 没修改能登陆成功,修改了反而登陆不成功
会提示错误Wrong permissions on configuration file, should not be world writable!
网上给出的解决方法	http://www.zoneself.org/2013/02/25/content_2057.html  完全没关系啊

(win2003下config.sample.inc.php修改与否都可登陆成功)
http://192.168.1.203/phpMyAdmin/setup/

访问问题
WIN2003	 下文件夹为phpMyAdmin
	http://192.168.1.200/phpMyAdmin/
	http://192.168.1.200/phpmyadmin/ 都可以访问成功
centos 下 文件夹为phpMyAdmin
	http://192.168.1.200/phpMyAdmin/ 只有此才能访问成功
但是提示错误
缺少 mcrypt 扩展。请检查 PHP 配置。



怎么修改成国外的源呢?
http://www.cnblogs.com/mchina/archive/2013/01/04/2842275.html

http://os.51cto.com/art/201306/398238.htm

两个重要目录
/etc/yum.repos.d
/var/cache/yum/i386  及其3个文件夹下的timehosts.txt
posted @ 2019-07-05 16:28  lnxcode  阅读(203)  评论(0编辑  收藏  举报