LAMP简易安装
看,老鸟绕道–LAMP简易安装
| 导读 | LAMP是企业中最常用的服务,也是非常稳定的网站架构平台。其中L-指的是Linux,A-指的是Apache,m-指的是mysql或者marriDB,p-php。相信大家对这些都已经非常熟悉了,但是对于刚接触Linux的新手来说,可能还不是太明白,要装什么包啊,什么模块啊。其实LAMP并不难,下面用最简单的方法安装LAMP。 |
系统环境:centos 6.8 x86_64
[root@localhost ~]# uname -a Linux localhost.localdomain 2.6.32-642.el6.x86_64 #1 SMP Tue May 10 17:27:01 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux [root@localhost ~]# cat /etc/redhat-release CentOS release 6.8 (Final) [root@localhost ~]#
LAMP相关包是否安装:
默认httpd已经安装,在这里我们说明下:本次实验我们采用的是yum的方式来进行安装,httpd就是Apache软件在RPM中的软件包名
[root@localhost ~]# rpm -qa httpd httpd-2.2.15-53.el6.centos.x86_64 [root@localhost ~]# rpm -qa mysql* [root@localhost ~]# rpm -qa php* [root@localhost ~]#
LAMP的安装其实非常简单,一条命令搞定。个人认为对于初学着没有必要搞那么多这个插件,那个插件;到了深入了解了LAMP后在根据自己实际的需求来进行模块的安装,由易道难,循序渐进的学习。
[root@localhost ~]# yum repolist \\查看yum仓库的情况 Loaded plugins: fastestmirror, refresh-packagekit, security Loading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.aliyun.com base | 3.7 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 repo id repo name status base CentOS-6 - Base 6,696 extras CentOS-6 - Extras 62 updates CentOS-6 - Updates 482 repolist: 7,240
我们使用的是centos默认的网络yum仓库,当然如果默认yum仓库比较慢的话,可以使用epel的软件包。
[root@localhost ~]# yum -y install httpd mysql mysql-server mysql-devel php* Loaded plugins: fastestmirror, refresh-packagekit, security Setting up Install Process Loading mirror speeds from cached hostfile * base: mirrors.cn99.com * extras: mirrors.cn99.com * updates: mirrors.aliyun.com Resolving Dependencies --> Running transaction check ---> Package httpd.x86_64 0:2.2.15-53.el6.centos will be updated ---> Package httpd.x86_64 0:2.2.15-54.el6.centos will be an update --> Processing Dependency: httpd-tools = 2.2.15-54.el6.centos for package: httpd-2.2.15-54.el6.centos.x86_64 ---> Package mysql.x86_64 0:5.1.73-7.el6 will be installed .......................... Installed: mysql.x86_64 0:5.1.73-7.el6 mysql-devel.x86_64 0:5.1.73-7.el6 mysql-server.x86_64 0:5.1.73-7.el6 php.x86_64 0:5.3.3-48.el6_8 php-bcmath.x86_64 0:5.3.3-48.el6_8 php-cli.x86_64 0:5.3.3-48.el6_8 ......... Updated: httpd.x86_64 0:2.2.15-54.el6.centos Dependency Updated: httpd-tools.x86_64 0:2.2.15-54.el6.centos net-snmp-libs.x86_64 1:5.5-57.el6_8.1 openssl.x86_64 0:1.0.1e-48.el6_8.1 Complete!
我们yum命令安装httpd ,安装mysql mysql-server 和mysql-devel开发包,在php的安装包上面我们选择了php* 的命令匹配搜有php相关的包。注意,注意的操作是为了让入门童鞋们先了解LAMP的方案,在深入了解后,还是要跟进实际的情况安装搜需要的包。
安装完成LAMP后,我们需要对LAMP进行初始化,其实也就是启动服务,开机自起和必要的配置。
[root@localhost ~]# service httpd start \\启动httpd服务;注意httpd和apache的关系 Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName [ OK ] [root@localhost ~]# chkconfig httpd on \\设置httpd开启自器
[root@localhost ~]# service mysqld start \\开启mysql服务,会提示需要初始化,很详细 Initializing MySQL database: Installing MySQL system tables... OK Filling help tables... OK 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' Alternatively you can run: /usr/bin/mysql_secure_installation which will also give you the option of removing the test databases and anonymous user created by default. This is strongly recommended for production servers. 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 mysql-test-run.pl cd /usr/mysql-test ; perl mysql-test-run.pl Please report any problems with the /usr/bin/mysqlbug script! [ OK ] Starting mysqld: [ OK ] [root@localhost ~]# chkconfig mysqld on \\设置mysql开机自启动 [root@localhost ~]# mysqladmin -u root password linuxprobe.com \\初始化mysql,在这里需要设置mysql的root的密码;命令:mysqladmin -u 用户 password 密码 [root@localhost ~]# mysql -u root -p \\登录mysql查看是否能够登录 Enter password: Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> \\ok登录成功
注意:在yum安装lamp的时候,其实php只是apache的一个集成的组件,不需要添加模块的应用,只要在配置文件中启用就可以了。
[root@localhost ~]# ps -aux |grep httpd \\查看httpd的进程 Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ root 2930 0.0 2.9 487660 14664 ? Ss 10:46 0:00 /usr/sbin/httpd apache 2933 0.0 1.9 487660 9400 ? S 10:46 0:00 /usr/sbin/httpd apache 2934 0.0 1.8 487660 9112 ? S 10:46 0:00 /usr/sbin/httpd apache 2935 0.0 1.9 487660 9400 ? S 10:46 0:00 /usr/sbin/httpd apache 2936 0.0 1.9 487660 9392 ? S 10:46 0:00 /usr/sbin/httpd apache 2937 0.0 1.8 487660 9116 ? S 10:46 0:00 /usr/sbin/httpd apache 2938 0.0 1.8 487660 9136 ? S 10:46 0:00 /usr/sbin/httpd apache 2939 0.0 1.8 487660 9112 ? S 10:46 0:00 /usr/sbin/httpd apache 2940 0.0 2.3 487844 11840 ? S 10:46 0:00 /usr/sbin/httpd root 10163 0.0 0.1 103316 868 pts/3 S+ 12:23 0:00 grep httpd [root@localhost ~]# ps -aux |grep mysql \\查看mysql的相关进程 Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ root 3035 0.0 0.2 108216 1452 pts/1 S 10:47 0:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --socket=/var/lib/mysql/mysql.sock --pid-file=/var/run/mysqld/mysqld.pid --basedir=/usr --user=mysql mysql 3137 0.0 4.3 367512 21444 pts/1 Sl 10:47 0:02 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --user=mysql --log-error=/var/log/mysqld.log --pid-file=/var/run/mysqld/mysqld.pid --socket=/var/lib/mysql/mysql.sock root 10165 0.0 0.1 103316 868 pts/3 S+ 12:23 0:00 grep mysql [root@localhost ~]# netstat -tanulp |grep 80 \\查看httpd 的端口对外监听 tcp 0 0 192.168.1.108:50878 63.80.4.177:80 ESTABLISHED 2629/clock-applet tcp 0 0 :::80 :::* LISTEN 2930/httpd [root@localhost ~]# netstat -tanulp |grep 3306 \\查看mysql的端口对外监听 tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 3137/mysqld
[root@localhost ~]# iptables -L \\查看iptables的规则 Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT icmp -- anywhere anywhere ACCEPT all -- anywhere anywhere ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) target prot opt source destination [root@localhost ~]# iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT \\添加iptables INPUT的链的第一条规则允许tcp协议的80端口 \\关于iptables 的更多设置,请参考《linux就该这样学》相关内容 [root@localhost ~]# service iptables save \\将我们的添加的规则保存在配置文件 iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ] [root@localhost ~]# iptables -L \\查看保存情况 Chain INPUT (policy ACCEPT) target prot opt source destination ACCEPT tcp -- anywhere anywhere tcp dpt:http ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED ACCEPT icmp -- anywhere anywhere ACCEPT all -- anywhere anywhere ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain FORWARD (policy ACCEPT) target prot opt source destination REJECT all -- anywhere anywhere reject-with icmp-host-prohibited Chain OUTPUT (policy ACCEPT) target prot opt source destination
添加一个测试的静态index.html页面,或者使用默认的页面进行测试。关于添加网站页面的更多问题,请参考《linux就该这样学》的相关内容
[root@localhost ~]# echo "hello word" > /var/www/html/index.html
测试用ie浏览器测试静态页面:
ok,测试成功。
[root@localhost ~]# ls /etc/httpd/ \\配置文件目录,相关配置模块 conf/ conf.d/ logs/ modules/ run/ [root@localhost ~]# vi /etc/httpd/conf/ httpd.conf magic [root@localhost ~]# vi /etc/httpd/conf/httpd.conf \\主配文件 [root@localhost ~]# wc -l /etc/httpd/conf/httpd.conf 1009 /etc/httpd/conf/httpd.conf \\ 主配文件共有1009行,其中有好多都是注释的.养成好习惯,备份默认配置文件 [root@localhost ~]# tail /etc/httpd/conf/httpd.conf \\更多配置建议参考《linux就该这样学》相关内容 # The first VirtualHost section is used for requests without a known # server name. # # \\配置文件中添加虚拟主机的语句 # ServerAdmin webmaster@dummy-host.example.com # DocumentRoot /www/docs/dummy-host.example.com # ServerName dummy-host.example.com # ErrorLog logs/dummy-host.example.com-error_log # CustomLog logs/dummy-host.example.com-access_log common #
LAMP是一个稳定的动态的网站架构方案,在这里我们需要添加php的支持,测试动态网站。
[root@localhost ~]# vi /etc/httpd/conf/httpd.conf[root@localhost ~]# cat /etc/httpd/conf/httpd.conf |grep DirectoryIndex \\在配置文件402行添加对php页面的支持 # DirectoryIndex: sets the file that Apache will serve if a directory
[root@localhost ~]# vi /var/www/html/index.php [root@localhost ~]# cat /var/www/html/index.php \\添加php信息的测试页面 [root@localhost ~]# vi /var/www/html/test.php [root@localhost ~]# cat /var/www/html/test.php \\添加php页面测试 test this php test
测试:
LAMP简易安装的更多相关文章
- 新手必看,老鸟绕道–LAMP简易安装
导读 LAMP是企业中最常用的服务,也是非常稳定的网站架构平台.其中L-指的是Linux,A-指的是Apache,m-指的是mysql或者marriDB,p-php.相信大家对这些都已经非常熟悉了,但 ...
- VMware Tools的简易安装---解决Ubuntu 14.10不能满屏显示问题
由于使用的VMware WorkStation是中文破解版,安装时又是简易安装,因此VMware Tools并没有安装上,导致Ubuntu 14.10在VMware中装上之后,并不能满屏显示,如图1所 ...
- 简易安装python统计包
PythonCharm简易安装python统计包及 本文介绍使用pythonCharm IDE 来安装Python统计包或一些packages的简单过程,基本无任何技术难度,顺便提一提笔者在安装过程中 ...
- HBase介绍及简易安装(转)
HBase介绍及简易安装(转) HBase简介 HBase是Apache Hadoop的数据库,能够对大型数据提供随机.实时的读写访问,是Google的BigTable的开源实现.HBase的目标是存 ...
- 【转载】干货来袭!Linux小白最佳实践:《超容易的Linux系统管理入门书》(连载七)LAMP集成安装
学Linux做程序开发也好,做系统管理也好,做网络管理员也好,做系统运维也好,不会LAMP和LNMP,那就等于连皮毛都不会!本篇是文字版的LAMP集成安装,下次连载我们要介绍LNMP的文字版安装.有喜 ...
- LAMP的安装
一,LAMP的安装流程:mysql.apache.php或者apache.mysql.php.php放到最后的原因是,php在编译安装的时候是依赖于前2者的. 二,Mysql的安装: 1.下载mysq ...
- VMware 非简易安装centos6(静态ip配置)
1.选择新建虚拟机 在弹出框中我选择推荐安装 然后点击下一步 2.选择稍后安装操作系统(不然会默认简易安装) 接着一直下一步就可以了,最后到这个页面 4.如下图选择事先下载好的安装文件 5.配置桥接模 ...
- lamp环境安装
每天学习一点点 编程PDF电子书免费下载: http://www.shitanlife.com/code lamp环境安装 1.查看mysql是否安装 service mysql status 2.查 ...
- 编译安装LAMP之安装Apache+php与管理(十五)
[教程主题]:编译安装LAMP之安装Apache+php与管理 [课程录制]: 创E [主要内容] [1]编译安装Apache+PHP 1.安装程序依赖库和开发环境 为了省事把所需要的库文件全都安装上 ...
随机推荐
- img图片下面出现莫名的下边距解决办法
图片底部的空隙实际上涉及行内元素的布局模型,图片默认的垂直对齐方式是基线,而基线的位置是与字体相关的.所以在某些时候,图片底部的空隙可能是 2px,而有时可能是 4px 或更多.不同的 font-si ...
- 写入标题使用依赖注入Title的setTitle方法
1. 声明 Generator的声明方式类似一般的函数声明,只是多了个*号,并且一般可以在函数内看到yield关键字 function* showWords() { yield 'one'; yiel ...
- Graphics2D字符串根据文本框缩小字体自动换行
/** * *描述: 长字符串缩小字体自动换行 *@param g *@param text 字符串 *@param lineWidth 单元格宽度 *@param cellHeight 单元格高度 ...
- 在MyEclipse显示struts2源码和doc文档及自动完成功能
分类: struts2 2010-01-07 16:34 1498人阅读 评论(1) 收藏 举报 myeclipsestruts文档xmlfileurl 在MyEclipse显示struts2源码和d ...
- hive问题整理(待续)
本人对hadoop生态系统的环境搭建.配置相关再熟悉不过了,周末刚测试过oozie相关的 今早使用hive,报错: Exception in thread "main" java. ...
- sql返回两个日期之间的日期_函数实现
-- Description:返回两段日期之间的所有日期 <Description,,>-- ============================================ ...
- C++ 基础算法之二分查找
前提: 有序数组! int binary_search(int* a, int len, int goal) { ; ; while(low <= high) { ; if(a[middle] ...
- 自定义 Material Design风格的提示框
关闭 自定义 Material Design风格的提示框 2016-04-24 10:55 152人阅读 评论(0) 收藏 举报 版权声明:本文为博主原创文章,未经博主允许不得转载. 其实在14年谷歌 ...
- 《1---关于解决MySQL在控制台插入中文乱码问题》
说明:以下所有操作都是基于我个人的电脑及示例,读者可以参考我这个解决过程,去解决自己的问题,如有其它疑问,欢迎留言交流. 首先来看看我遇到的问题: [1]查看数据库: [2]使用test数据库: [3 ...
- 第一章 Android系统移植与驱动开发概述
本书第一章首先简单概要地介绍了关于Android系统移植和驱动开发的相关内容. 所谓“移植”是指为特定的自己的设备,如手机定制Android的过程.自己开发一些程序(移植)装载在设备上,使得Andro ...