centos下利用yum安装LAMP(Linux+Apache+MySQL+PHP)及配置
先说下我的实践配置,centos6.5(64位),联网
安装前准备:关闭防火墙 service iptables stop
- 安装MySQL
打开终端,root用户
1
|
yum install mysql mysql-server |
安装完毕,设置MySQL自启动
1
2
|
chkconfig --levels 235 mysqld on /etc/init.d/mysqld start //或者service mysqld start |
设置MySQL root账户的密码(我没有新建MySQL用户,就用root账户了),输入以下
1
|
mysql_secure_installation |
出现以下提示时
Enter current paaword for root
因为我们root密码为空,所以直接回车
之后按照提示,输入新密码,确认,最后会有四个确认,直接回车就行
- 安装Apache
1
|
yum install httpd |
配置自启动
1
|
chkconfig --levels 235 httpd on <br>service httpd start |
此时启动可能会出现以下错误
正在启动httpd:httpd:could not reliably determine the server's fully qualif domain name,
using::1 for servername
解决方法:
我们要修改/etc/httpd/conf/httpd.conf文件
进入vi修改状态,找到#ServerName www.example.com:80
取消#,并修改为ServerName 域名:80(如果没有域名的话,就设为localhost)
wq!保存退出
1
|
service httpd start或restart |
重启httpd,此时你就可以访问你的服务器了,输入localhost,出现一个Apache test page powered by centos的测试页面
- 安装PHP
同样输入命令
1
|
yum install php |
直接一路安装,安装完成之后我们需要再次重启httpd服务
重启之后我们进行测试PHP相关信息,我们新建一个PHP界面进行测试
1
|
vi / var /www/html/info.php<br>按 i 进行编辑,输入:<br><?php<br>phpinfo();<br>?> |
编辑完毕,保存退出
此时我们访问这个页面,输入localhost/info.php,就会出现一个现实PHP信息的网页,说明你的PHP安装成功了
- 将PHP模块和MySQL模块关联起来
在这个步骤中,我们要安装相关模块
首先搜索模块
1
|
yum search php(在网上看到的步骤,并不知道有什么卵用) |
之后安装相关模块
1
|
yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc |
网上也有以下安装包的,我当时选择的是上面的,应该是都可以的
1
2
|
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt 本篇文章来源于 Linux公社网站(www.linuxidc.com) 原文链接:http: //www.linuxidc.com/Linux/2014-12/111030.htm |
安装完成,重启mysqld,重启httpd
再次访问刚才的info.php,我们发现已经多了MySQL的相关信息(不贴图了)
- LAMP配置
Apache配置
vi /etc/httpd/conf/httpd.conf #编辑文件
ServerTokens OS 修改为:ServerTokens Prod (在出现错误页的时候不显示服务器操作系统的名称)
ServerSignature On 修改为:ServerSignature Off (在错误页中不显示Apache的版本)
Options Indexes FollowSymLinks 修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录)
#AddHandler cgi-script .cgi 修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)
AllowOverride None 修改为:AllowOverride All (允许.htaccess)
AddDefaultCharset UTF-8 修改为:AddDefaultCharset GB2312 (添加GB2312为默认编码)
Options Indexes MultiViews FollowSymLinks 修改为 Options MultiViews FollowSymLinks(不在浏览器上显示树状目录结构)
DirectoryIndex index.html index.html.var 修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php Default.php index.html.var (设置默认首页文件,增加index.php)
KeepAlive Off 修改为:KeepAlive On (允许程序性联机)
MaxKeepAliveRequests 100 修改为:MaxKeepAliveRequests 1000 (增加同时连接数)
:wq! #保存退出
/etc/init.d/httpd restart#重启
PHP配置
vi /etc/php.ini #编辑
date.timezone = PRC #在946行 把前面的分号去掉,改为date.timezone = PRC
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,
popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,
posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#在386行 列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
expose_php = Off #在432行 禁止显示php版本的信息
magic_quotes_gpc = On #在745行 打开magic_quotes_gpc来防止SQL注入
short_open_tag = ON #在229行支持php短标签
open_basedir = .:/tmp/ #在380行 设置表示允许访问当前目录(即PHP脚本文件所在之目录)和/tmp/目录,可以防止php木马跨站
,如果改了之后安装程序有问题,可以注销此行,或者直接写上程序的目录/data/域名/:/tmp/
:wq! #保存退出
/etc/init.d/mysqld restart #重启MySql
/etc/init.d/httpd restart #重启Apche
- 配置让Apache可以解析php
1
|
vi /etc/httpd/conf/httpd.conf<br>添加<br>Addtype application/x-httpd-php .php .phtml<br>Addtype application/x-httpd-php-source .phps |
centos下利用yum安装LAMP(Linux+Apache+MySQL+PHP)及配置的更多相关文章
- CentOS 6.3下源码安装LAMP(Linux+Apache+Mysql+Php)环境【转载】
本文转载自 园友David_Tang的博客,如有侵权请联系本人及时删除,原文地址: http://www.cnblogs.com/mchina/archive/2012/11/28/2778779.h ...
- 【转】CentOS环境下yum安装LAMP(Linux+Apache+Mysql+php)
此种方法很简单.每次都用源码编译,浪费好多时间啊! 同样的网站程序在Linux下运行要比在windows下快出不少,所以决定使用Linux的发行版CentOS ,本文主要讲解在CentOS下使用yum ...
- CentOS环境下yum安装LAMP(Linux+Apache+Mysql+php)
CentOS下使用yum命令 安装LAMP详细过程.我们使用的软件是CentOS的最新版本CentOS 6.3,其他版本的也基本类似. 第一步:更新系统内核(如果不想更新可以跳过本步). 首先更新系统 ...
- CentOS 6.3下源码安装LAMP(Linux+Apache+Mysql+Php)环境
一.简介 什么是LAMP LAMP是一种Web网络应用和开发环境,是Linux, Apache, MySQL, Php/Perl的缩写,每一个字母代表了一个组件,每个组件就其本身而言都是在它所代 ...
- CentOS 6.5下源码安装LAMP(Linux+Apache+Mysql+Php)环境
---恢复内容开始--- 一.系统环境 系统平台:CentOS 6.5 (Final) Apache版本:httpd-2.2.31.tar.gz(最新版本2015-07-16) Mysql 版本:my ...
- 转:CentOS/Debian/Ubuntu一键安装LAMP(Apache/MySQL/PHP)环境
CentOS/Debian/Ubuntu一键安装LAMP(Apache/MySQL/PHP) 今天遇到一个网友提到需要在Linux VPS服务器中安装LAMP(Apache/MySQL/PHP)网站环 ...
- CentOS 6.3 源码安装LAMP(Linux+Apache+Mysql+Php)环境
一.简介 什么是LAMP LAMP是一种Web网络应用和开发环境,是Linux, Apache, MySQL, Php/Perl的缩写,每一个字母代表了一个组件,每个组件就其本身而>言都是在它所 ...
- Centos下安装配置LAMP(Linux+Apache+MySQL+PHP)
Centos下安装配置LAMP(Linux+Apache+MySQL+PHP) 关于LAMP的各种知识,还请大家自行百度谷歌,在这里就不详细的介绍了,今天主要是介绍一下在Centos下安装,搭建一 ...
- CentOS下使用yum安装Apache极为方便,只需要在终端键入以下命令即可
CentOS下使用yum安装Apache极为方便,只需要在终端键入以下命令即可 1.安装Apache yum install httpd 2.设置服务器开机自动启动Apache systemctl e ...
随机推荐
- Python hash() 函数
Python hash() 函数 Python 内置函数 描述 hash() 用于获取取一个对象(字符串或者数值等)的哈希值. 语法 hash 语法: hash(object) 参数说明: obje ...
- 最小生成树 prime算法 UVALive - 6437
题目链接:https://vjudge.net/contest/241341#problem/D 这里有多个发电站,需要求出所有点都和发电站直接或间接相连的最小代价,那么就是求出最小生成树的问题了,有 ...
- Gym - 100989G 二分
链接:ECJTU 2018 Summer Training 1 - Virtual Judge https://vjudge.net/contest/236677#problem/G 谷歌翻译: 距 ...
- 206. Reverse Linked List (List)
Reverse a singly linked list. /** * Definition for singly-linked list. * struct ListNode { * int val ...
- String int 相互转换
String->int: int i = Integer.parseInt(s) int->String: String s = Integer.toString(i)
- 微信小程序开发——以简单易懂的浏览器页面栈理解小程序的页面路由
前言: 对于小程序的页面路由,如果没有一定开发经验的话,理解起来还是会有些困难的.哪怕是有一定小程序开发经验的开发者,能够完全理解掌握的恐怕也不多. 这里就以另外一种方式来详细的介绍小程序的页面栈及路 ...
- vue-app项目,将px自动转化为rem
1. 安装lib-flexible: npm install --save lib-flexible 2.安装postcss-loader和postcss-px2rem: npm install -- ...
- mysql之 安装(Mac)
1.官网下载安装包:https://dev.mysql.com/downloads/mysql/ 2.设置环境变量:(1)首先mysql的安装位置为:/usr/local/mysql/bin (2)在 ...
- 使用SqlBulkCopy批量插入数据,测试20万条用时5秒
using System;using System.Collections.Generic;using System.Linq;using System.Text; using System.Data ...
- Quartz代码及配置详解(转)
Quartz可以用来做什么? Quartz是一个任务调度框架.比如你遇到这样的问题 想每月25号,信用卡自动还款 想每年4月1日自己给当年暗恋女神发一封匿名贺卡 想每隔1小时,备份一下自己的爱情动作片 ...