首頁技術(shù)文章正文

如何部署LAMP環(huán)境?[IT運維培訓]

更新時間:2019-10-29 來源:黑馬程序員 瀏覽量:

環(huán)境說明:當前系統(tǒng)版本為RedHat8.0系統(tǒng)

1、基礎(chǔ)環(huán)境配置

(1)關(guān)閉防火墻和selinux

臨時關(guān)閉防火墻

[root@rhel8 ~]# systemctl stop firewalld.service

下次開機不自動啟動

[root@rhel8 ~]# systemctl disable firewalld.service

[root@rhel8 ~]# systemctl list-unit-files |grep firewalld

firewalld.service                           disabled

 

關(guān)閉selinux

[root@rhel8 ~]# setenforce 0

[root@rhel8 ~]# getenforce

Permissive

[root@rhel8 ~]# vim /etc/selinux/config

...

SELINUX=disabled

....

(2)配置本地軟件倉庫

手動掛載光盤到本地/mnt下

[root@rhel8 ~]# mount -o ro /dev/sr0 /mnt

開機自動啟動

[root@rhel8 ~]# echo "mount -o ro /dev/sr0 /mnt" >> /etc/rc.local

[root@rhel8 ~]# chmod +x /etc/rc.d/rc.local

 

修改配置文件指定軟件倉庫

[root@rhel8 ~]# cd /etc/yum.repos.d/

[root@rhel8 yum.repos.d]# cat local.repo

[BaseOS]

name=BaseOS yum

baseurl=file:///mnt/BaseOS/

enabled=1

gpgcheck=0

 

[App]

name=Appstream yum

baseurl=file:///mnt/AppStream/

enabled=1

gpgcheck=0

 

 

2、一鍵構(gòu)建LAMP環(huán)境

(1) 安裝Apache(httpd)軟件

說明:RedHat8默認自帶httpd-2.4.37版本

[root@rhel8 ~]# yum install httpd -y

(2)安裝PHP相關(guān)軟件

說明:RedHat8默認php-7.2版本

yum -y install php-xml-7.2.11-1.module+el8+2561+1aca3413.x86_64 \
php-json-7.2.11-1.module+el8+2561+1aca3413.x86_64 \
php-mysqlnd-7.2.11-1.module+el8+2561+1aca3413.x86_64 \
php-common-7.2.11-1.module+el8+2561+1aca3413.x86_64 \
php-fpm-7.2.11-1.module+el8+2561+1aca3413.x86_64 \
php-bcmath-7.2.11-1.module+el8+2561+1aca3413.x86_64 \
php-cli-7.2.11-1.module+el8+2561+1aca3413.x86_64 \
php-7.2.11-1.module+el8+2561+1aca3413.x86_64 \
php-gd-7.2.11-1.module+el8+2561+1aca3413.x86_64 \
php-pdo-7.2.11-1.module+el8+2561+1aca3413.x86_64 \
php-devel-7.2.11-1.module+el8+2561+1aca3413.x86_64

(3) 安裝Mariadb數(shù)據(jù)庫軟件

說明:從RedHat7以后,系統(tǒng)默認自帶Mariadb數(shù)據(jù)庫

[root@rhel8 ~]# yum install mariadb-server mariadb


3、啟動相應(yīng)服務(wù)

(1)啟動后臺數(shù)據(jù)庫

[root@rhel8 ~]# systemctl start mariadb.service
[root@rhel8 ~]# systemctl enable mariadb.service

[root@rhel8 ~]# netstat -nltp|grep 3306
tcp6       0      0 :::3306          :::*           LISTEN      45368/mysqld

[root@rhel8 ~]# mysqladmin -u root password '123'

(2)啟動前端web服務(wù)

[root@rhel8 ~]# systemctl start httpd.service
[root@rhel8 ~]# systemctl enable httpd.service
[root@rhel8 conf]# netstat -nltp|grep :80
tcp        0      0 0.0.0.0:80       0.0.0.0:*       LISTEN      45593/httpd

4、測試是否可以解析php頁面

[root@rhel8 ~]# vim /var/www/html/index.php
[root@rhel8 ~]# cat /var/www/html/index.php
<?php
       phpinfo();
?>

1572341656004_lamp部署.jpg


推薦了解:黑馬程序員linux云計算+運維開發(fā)培訓課程。


分享到:
在線咨詢 我要報名
和我們在線交談!