歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> 搭建lamp環境

搭建lamp環境

日期:2017/3/3 11:17:14   编辑:Linux技術

一、配置防火牆

CentOS 7.0默認使用的是firewall作為防火牆。

1、關閉firewall:

systemctl stop firewalld.service #停止firewall  
    systemctl disable firewalld.service #禁止firewall開機啟動
2、關閉SELINUX

vi /etc/selinux/config  
#SELINUX=enforcing #注釋掉  
SELINUX=disabled #增加  
:wq! #保存退出  
setenforce 0 #使配置立即生效
3.安裝apache

yum install httpd #根據提示,輸入Y安裝即可成功安裝  
systemctl start httpd.service #啟動apache  
systemctl stop httpd.service #停止apache  
systemctl restart httpd.service #重啟apache  
systemctl enable httpd.service #設置apache開機啟動
4.安裝mariadb(mysql)

yum install mariadb mariadb-server #詢問是否要安裝,輸入Y即可自動安裝,直到安裝完成  
systemctl start mariadb.service #啟動MariaDB  
systemctl stop mariadb.service #停止MariaDB  
systemctl restart mariadb.service #重啟MariaDB  
systemctl enable mariadb.service #設置開機啟動
set password for 'root'@'localhost'=password('root');  <pre name="code" class="python">#修改mysql密碼

grant all on *.* to root identified by 'root';  <pre name="code" class="python">#mysql授權遠程連接(navicat等)

5、安裝PHP以及組件,使PHP支持 MariaDB

yum install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash  
#這裡選擇以上安裝包進行安裝,根據提示輸入Y回車  
systemctl restart mariadb.service #重啟MariaDB  
systemctl restart httpd.service #重啟apache
進入目錄,測試一下

cd /var/www/html

vi index.php #輸入下面內容

<?php

phpinfo();

?>

:wq! #保存退出

Copyright © Linux教程網 All Rights Reserved