整理一下最近学习搭建lamp的心得
VMware版本号:11.1.2
CentOS版本:6.6
安装<strong>Apache</strong>
1.安装<strong>Apache</strong>
<code> yum -y install httpd</code>
2. <strong>Apache</strong>配置httpd.conf
通过命令 find / -name httpd.conf 找到<strong>Apache</strong>配置文件httpd.conf(默认在/etc/httpd/conf/httpd.conf)
编辑httpd.conf文件
<code> vi /etc/httpd/conf/httpd.conf</code>
修改DocumentRoot "/xx/xx/xxx",项目在哪个目录下,就将"/xx/xx/xxx"改为哪个目录,例如DocumentRoot "/var/www/html" ,同样将<directory></directory>修改为<directory></directory>。
查看是否安装成功(启动<strong>Apache</strong>,并查看<strong>Apache</strong>状态)
<code> service httpd start service httpd status</code>
显示OK说明安装成功
配置<strong>Apache</strong>开机启动项
<code> chkconfig --add httpd (在服务清单中添加httpd服务) chkconfig httpd on </code>
安装Mysql
1. 安装Mysql
<code>yum -y install mysql mysql-devel mysql-server mysql-libs</code>
2. 查看Mysql版本
<code>rpm -qi mysql-server</code>
3. 数据库字符集设置
Mysql配置文件/etc/my.cnf中加入default-character-set=utf8
4. 启动Mysql
<code>service mysqld start</code>
5. 创建root管理员
<code>mysqladmin -u root password 密码</code>
6. 配置Mysql开机启动服务
<code> chkconfig --add mysqld (在服务清单中添加mysql服务) chkconfig mysqld on (设置mysql服务随开机启动) </code>
7. 登录Mysql
<code>mysql -u root -p 回车输入密码</code>
安装PHP
1. 安装PHP
<code>yum -y install php </code>
2. 安装PHP扩展
<code>yum -y install php-mysql php-gd php-imap php-ldap php-odbc php-mbstring php-devel php-soap php-cli php-pdo yum -y install php-mcrypt php-tidy php-xml php-xmlrpc php-pear yum -y install php-pecl-memcache php-eaccelerator</code>
3. 重启<strong>Apache</strong>
<code>service httpd restart</code>
4. 测试
在/var/www/html/下创建index.php文件,并写入phpinfo()
浏览器访问index.php文件,如果输出phpinfo信息,安装成功
以上就介绍了Linux下搭建LAMP环境YUM,包括了Apache,安装Apache方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号