centos7之lamp環境搭建

一、配置防火牆

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

1、關閉firewall:

  1. systemctl stop firewalld.service #停止firewall  
  2. systemctl disable firewalld.service #禁止firewall開機啓動  

2、關閉SELINUX

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

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

  1. yum install mariadb mariadb-server #詢問是否要安裝,輸入Y即可自動安裝,直到安裝完成  
  2. systemctl start mariadb.service #啓動MariaDB  
  3. systemctl stop mariadb.service #停止MariaDB  
  4. systemctl restart mariadb.service #重啓MariaDB  
  5. systemctl enable mariadb.service #設置開機啓動  
  1. 修改mysql密碼:set password for 'root'@'localhost'=password('root');  
  1. mysql授權遠程連接(navicat等): grant all on *.* to root identified by 'root';  

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

  1. yum install php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash  
  2. #這裏選擇以上安裝包進行安裝,根據提示輸入Y回車  
  3. systemctl restart mariadb.service #重啓MariaDB  
  4. systemctl restart httpd.service #重啓apache  

測試篇

cd /var/www/html

vi index.php #輸入下面內容

<?php

phpinfo();

?>

:wq! #保存退出

在客戶端瀏覽器輸入服務器IP地址,可以看到如下圖所示相關的配置信息!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章