CentOS 6下手动安装LAMP环境教程

CentOS 6下手动安装LAMP环境教程本期教程目录 1 安装 配置 Apache2 安装 配置 MySQL3 安装 配置 PHP 一 安装 配置 Apache1

大家好,欢迎来到IT知识分享网。

本期教程目录
1.安装/配置Apache
2.安装/配置MySQL
3.安装/配置PHP

CentOS 6下手动安装LAMP环境教程

一、安装/配置Apache

1.更新系统&安装Apache
yum update
yum install httpd

推荐:使用如下命令备份Apache配置文件
cp /etc/httpd/conf/httpd.conf ~/httpd.conf.backup

为了给大家拓展思路,本次在CentOS上的教程,和大家分享Apache的另外一种绑定域名和创建虚拟机的方式~

2.编辑/etc/httpd/conf.d/vhost.conf,假设我们要绑定example.com和example.org两个域名,则参照下面内容加入文件,
NameVirtualHost *:80

ServerAdmin
ServerName example.com
ServerAlias www.example.com
DocumentRoot /srv/www/example.com/public_html/
ErrorLog /srv/www/example.com/logs/error.log
CustomLog /srv/www/example.com/logs/access.log combined

ServerAdmin
ServerName example.org
ServerAlias www.example.org
DocumentRoot /srv/www/example.org/public_html/
ErrorLog /srv/www/example.org/logs/error.log
CustomLog /srv/www/example.org/logs/access.log combined

3.因为我们上文指定了几个目录而这几个目录还不存在,所以,使用如下命令创建相应目录,
mkdir -p /srv/www/example.com/public_html
mkdir /srv/www/example.com/logs

mkdir -p /srv/www/example.org/public_html
mkdir /srv/www/example.org/logs

4.启动Apache
/etc/init.d/httpd start

日后每次修改vhost.conf文件,都需要使用如下命令使Apache重新载入配置文件
/etc/init.d/httpd reload

5.设置Apache开机启动
/sbin/chkconfig –levels 235 httpd on

二、安装/配置MySQL

1.安装MySQL
yum install mysql-server

2.设置MySQL开机自动启动
/sbin/chkconfig –levels 235 mysqld on

3.启动MySQL
/etc/init.d/mysqld start

MySQL的配置文件位于/etc/my.cnf

4.安装mysql_secure_installation(MySQL安全设置)
mysql_secure_installation

5.附上常用的MySQL命令

登录MySQL
mysql -u root -p

创建数据库iaodun(注意MySQL命令行下都需要以;结尾),并将该数据库所有权限赋予iaodun_user(密码为123)
create database iaodun;
grant all on iaodun.* to ‘iaodun_user’ identified by ‘123’;

退出MySQL
quit

三、安装/配置PHP

1.安装PHP
yum install php php-pear php-mysql

2.编辑配置文件/etc/php.ini,修改如下内容
error_reporting = E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
display_errors = Off
log_errors = On
error_log = /var/log/php.log
max_execution_time = 300
memory_limit = 64M
register_globals = Off

最后,重启Apache,大功告成~
/etc/init.d/httpd restart

免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://haidsoft.com/145529.html

(0)
上一篇 2025-04-19 20:26
下一篇 2025-04-19 20:45

相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注微信