Home php教程 php手册 centos 6.5 安装配置LAMP(linux,apache,mysql,php)环境

centos 6.5 安装配置LAMP(linux,apache,mysql,php)环境

Jun 06, 2016 pm 07:58 PM
ap centos lamp linux Install Configuration

一、安装apahce 1、更新yum yum update 输入y更新 2、安装apache yum install httpd 输入y安装 3、可选择安装apache的帮助文档 yum install httpd-manual 访问文档:http://localhost/manual/howto/cgi 4、启动apache /etc/init.d/httpd start (restart:重

一、安装apahce

1、更新yum

yum update

输入y更新


2、安装apache

yum install httpd

输入y安装


3、可选择安装apache的帮助文档

yum install httpd-manual

访问文档:http://localhost/manual/howto/cgi


4、启动apache

/etc/init.d/httpd start  (restart:重启)   或者   service httpd start  (restart:重启)

启动之后会报错误:Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 10.171.202.8 for ServerName

可以忽略这个错误,也可解决,方法如下:

打开apache配置文件:vim /etc/httpd/conf/httpd.conf

找到 #ServerName www.example.com:80  改我自己的域名或者localhost 重启apache即可解决


5、开机启动apache

chkconfig httpd on


二、安装mysql

可用资源包:

http://centos.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm 
http://rpms.famillecollet.com/enterprise/6/remi/x86_64/remi-release-6.5-1.el6.remi.noarch.rpm


1、选择版本:可自行去搜索第三方yum资源包

版本5.1.*:yum  install mysql mysql-server mysql-devel

版本5.5.*:yum --enablerepo=remi install mysql mysql-server mysql-devel


2、启动mysql

/etc/init.d/mysqld start  (restart:重启)   或者   service mysqld start  (restart:重启)


3、开机启动mysql

chkconfig mysqld on


4、更改my.cnf文件

cp /usr/share/mysql/my-medium.cnf /etc/my.cnf 如果存在直接覆盖


5、设置密码

安装好mysql后会自动设置一个密码主要安装信息

也可使用msyql_secure_installation:第一步按回车,之后输入两次密码,一直按Y即可


三、安装php

1、选择版本:可自行去搜索第三方yum资源包

版本5.3.*:yum  install php php-mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc

版本5.4.*:yum --enablerepo=remi install php php-mysql php-mcrypt php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc

2、重启apache mysql


apache简单配置说明

打开文件 vim /etc/httpd/conf/httpd.conf


这3项没用到,看到很多人写我也就加上了

KeepAlive Off           在76行 修改为:KeepAlive On (允许程序性联机)

Options Indexes FollowSymLinks    在331行 修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI)

#AddHandler cgi-script .cgi             在796行 修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行)


这5项有用到

AllowOverride None   在338行 修改为:AllowOverride All (允许.htaccess)

AddDefaultCharset UTF-8 在759行 设置字符编码,按需配置

Options Indexes        配置域名时如果将 Indexes 删除:不在浏览器上显示树状目录结构

DirectoryIndex index.html index.html.var   在 402行 设置默认首页文件,增加index.php等

MaxKeepAliveRequests 100  在83行 修改为 1000 (增加同时连接数)


修改apache解析目录

DocumentRoot "/var/www/html"  修改为你的目录   "/data0/www/xxx"  (这个目录就是挂载的数据盘)

rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html    #删除默认测试页

 

Apache的日志文件   
ErrorLog  /etc/httpd/logs/error_log   (php的错误日志也输出到这里)
CustomLog  /etc/httpd/logs/access_log combined


php简单配置

打开配置文件 vim  /etc/php.ini 

date.timezone = PRC    把前面的分号去掉,改为date.timezone = PRC 中国时区

magic_quotes_gpc = On   #在745行 打开magic_quotes_gpc来防止SQL注入  (php5.4开始不支持))

 

重启apache


关于apache php mysql的配置更多要自己去查阅相关资料




Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to solve the permissions problem encountered when viewing Python version in Linux terminal? How to solve the permissions problem encountered when viewing Python version in Linux terminal? Apr 01, 2025 pm 05:09 PM

Solution to permission issues when viewing Python version in Linux terminal When you try to view Python version in Linux terminal, enter python...

Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Why does an error occur when installing an extension using PECL in a Docker environment? How to solve it? Apr 01, 2025 pm 03:06 PM

Causes and solutions for errors when using PECL to install extensions in Docker environment When using Docker environment, we often encounter some headaches...

How to efficiently integrate Node.js or Python services under LAMP architecture? How to efficiently integrate Node.js or Python services under LAMP architecture? Apr 01, 2025 pm 02:48 PM

Many website developers face the problem of integrating Node.js or Python services under the LAMP architecture: the existing LAMP (Linux Apache MySQL PHP) architecture website needs...

How to solve permission issues when using python --version command in Linux terminal? How to solve permission issues when using python --version command in Linux terminal? Apr 02, 2025 am 06:36 AM

Using python in Linux terminal...

How to configure apscheduler timing task as a service on macOS? How to configure apscheduler timing task as a service on macOS? Apr 01, 2025 pm 06:09 PM

Configure the apscheduler timing task as a service on macOS platform, if you want to configure the apscheduler timing task as a service, similar to ngin...

Can the Python interpreter be deleted in Linux system? Can the Python interpreter be deleted in Linux system? Apr 02, 2025 am 07:00 AM

Regarding the problem of removing the Python interpreter that comes with Linux systems, many Linux distributions will preinstall the Python interpreter when installed, and it does not use the package manager...

Four ways to implement multithreading in C language Four ways to implement multithreading in C language Apr 03, 2025 pm 03:00 PM

Multithreading in the language can greatly improve program efficiency. There are four main ways to implement multithreading in C language: Create independent processes: Create multiple independently running processes, each process has its own memory space. Pseudo-multithreading: Create multiple execution streams in a process that share the same memory space and execute alternately. Multi-threaded library: Use multi-threaded libraries such as pthreads to create and manage threads, providing rich thread operation functions. Coroutine: A lightweight multi-threaded implementation that divides tasks into small subtasks and executes them in turn.

How to open web.xml How to open web.xml Apr 03, 2025 am 06:51 AM

To open a web.xml file, you can use the following methods: Use a text editor (such as Notepad or TextEdit) to edit commands using an integrated development environment (such as Eclipse or NetBeans) (Windows: notepad web.xml; Mac/Linux: open -a TextEdit web.xml)

See all articles