search
Homephp教程php手册centos-yum-lamp环境,centosyum

centos-yum-lamp环境,centosyum

  

首先安装Apache2
一条命令即可:
yum -y install httpd
回车后,yum会提示当前已经安装的httpd版本,并自动更新;如果没有安装,则会自动安装。注意在yum安装过程中输入“Y”以确认安装。
Apache安装完成后,手动启动Apache2:
/etc/init.d/httpd start
这时,直接在浏览器中输入服务器的IP地址,即可看到Apache2的默认页面。此时的Apache仅仅能提供HTTP服务,不能执行php、也不能连接MySQL数据库。

安装MySQL
由于CentOS中已经包含了MySQL,因此也仅需要yum即可:
yum -y install mysql mysql-server
完成后,使用如下命令启动MySQL服务:
/etc/init.d/mysqld start

安装php5
使用如下命令安装php5:
yum install php
安装完php5后,必须要重新启动Apache以使php生效:
/etc/init.d/httpd restart
这时,Apache已经可以解析执行php脚本了。由于Apache的默认网站根目录位于:/var/www/html/,因此在此目录建立一个info.php用来测试Apache+PHP的正确安装与否:
vi
然后在浏览器中访问/info.php,出现了PHPINFO的输出信息:


PHP与Apache已经正确安装。
接下来安装MySQL数据库与其它模块(如GD图形库、mbstring库等):
yum -y install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
安装过程可能比较慢,请耐心等待。完成后再次重启Apache:
/etc/init.d/httpd restart
重新在浏览器中打开IP/info.php页面,应该能找到MySQL、GD、mbstring等模块:


此时LAMP运行环境已经初步安装完毕。最后还需要将LAMP组件设置为自动启动:
1
chkconfig --levels 2345 httpd on
2
chkconfig --levels 2345 mysqld on

最后介绍相关配置与环境
Apache主配置文件:/etc/httpd/conf/httpd.conf
Apache主配置目录,可以将不同类型的配置分门别类放入这个目录中:/etc/httpd/conf.d/
Apache网站根目录:/var/www/html/
Apache日志文件目录:/var/log/httpd
MySQL的my.cnf配置文件:/etc/my.cnf
MySQL数据库文件位置:/usr/lib/mysql

Statement
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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment