centos 7 2安裝 lamp環境

2022-05-16 09:45:57 字數 3846 閱讀 7188

**:

一、準備工作

centos7.2的網路配置:

vim /etc/sysconfig/network-scripts/ifcfg-eno16777736

type=ethernet

bootproto=static

defroute=yes

peerdns=yes

peerroutes=yes

ipv4_failure_fatal=no

ipv6init=yes

ipv6_autoconf=yes

ipv6_defroute=yes

ipv6_peerdns=yes

ipv6_peerroutes=yes

ipv6_failure_fatal=no

name=eno16777736

uuid=a90b6241-89da-450a-9742-d5b186a17084

device=eno16777736

onboot=yes

ipaddr0=192.168.0.228

prefixo0=24

gateway0=192.168.0.1

dns1=192.168.0.1

配置完畢後,使用systemctl restart network.service重啟網路,然後ping  www.linuxidc.com測試是否網路連線通暢。

2.   配置防火牆,開啟80、3306埠。centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆。

#停止firewall服務

systemctl stop firewalld.service

#禁止firewall開機啟動

systemctl disable firewalld.service

#安裝yum install iptables-services

#編輯防火牆配置檔案

vi /etc/sysconfig/iptables

加入紅色的兩行**,請注意位置一定要對應。

# firewall configuration written by system-config-firewall

# manual customization of this file is not recommended.

*filter

:input accept [0:0]

:forward accept [0:0]

:output accept [0:0]

-a input -m state --state established,related -j accept

-a input -p icmp -j accept

-a input -i lo -j accept

-a input -m state --state new -m tcp -p tcp --dport 22 -j accept-a input -m state --state new -m tcp -p tcp --dport 80 -j accept-a input -m state --state new -m tcp -p tcp --dport 3306 -j accept-a input -j reject --reject-with icmp-host-prohibited

-a forward -j reject --reject-with icmp-host-prohibited

commit

:wq! #儲存退出

#最後重啟防火牆使配置生效

systemctl restart iptables.service

#設定防火牆開機啟動

systemctl enable iptables.service

3. 關閉seinux

#修改配置檔案

vi /etc/selinux/config

#selinux=enforcing #注釋掉

#selinuxtype=targeted #注釋掉

selinux=disabled #增加

:wq! #儲存退出

#使配置立即生效

setenforce 0

二、安裝lamp環境。1.  安裝apahce

可能會用到的:

systemctl start httpd.service #啟動apache

systemctl stop httpd.service #停止apache

systemctl restart httpd.service #重啟apache

systemctl enable httpd.service #設定apache開機啟動

重啟服務, systemctl restart httpd.service

輸入localhost

出現之後代表已經安裝上去了。

2. 安裝mysql。

# wget 

# rpm -ivh mysql-community-release-el7-5.noarch.rpm

# yum install mysql-community-server

安裝完成後重啟mysql,  systemctl restarat mysqld.service

初入安裝 root使用者沒有密碼:

[root@linuxidc-web linuxidc]# mysql -u root 

#設定msyql密碼為123456mysql> set password for 'root'@'localhost' =password('123456');#遠端連線設定,所有以root賬號連線的遠端使用者,設其密碼為123456mysql> grant all privileges on *.* to root@'%'identified by '123456';#更新許可權mysql>flush privileges;

3.  安裝phpyum install php

#安裝php元件,使php支援mysql

yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash

#重啟對應服務

以上 安裝 apahce 、mysql 、php  安裝完畢。

檢視安裝環境版本:

cd  /var/www/html  ,新建index.php檔案,輸入:

<?php 

phpinfo();

最終檢視為:php版本:

CentOS 7 2下安裝lamp環境

環境 yum install httpd安裝成功後啟動一下httpd服務 service httpd start在瀏覽器輸入ip訪問,頁面如下 安裝完成後重啟mysql systemctl restart mysqld.service測試一下,進入mysql 剛安裝好的時候root使用者沒有密碼 m...

CentOS7 2搭建LAMP環境

所謂的lamp就是 linux apache mysql php。這裡的linux使用centos7.2.0x00 開始我們可以先更新一下yum 公升級所有包同時也公升級軟體和系統核心 yum y update 只公升級所有包,不公升級軟體和系統核心 yum y upgrade 0x01 安裝apa...

CentOS 7 2 安裝教程

目錄 1.what is centos?介紹 特點 官網 2.download 製作u盤啟動 centos community enterprise operating system,中文意思是社群企業作業系統 是linux發行版之一,它是來自於red hat enterprise linux依照開...