溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

CentOS7上快速搭建LAMP環(huán)境

發(fā)布時(shí)間:2020-07-25 05:07:55 來源:網(wǎng)絡(luò) 閱讀:4409 作者:黎晨 欄目:MySQL數(shù)據(jù)庫

首先

確保CentOS7上網(wǎng)絡(luò)配置正確,可以正常訪問互聯(lián)網(wǎng)。

確保已經(jīng)關(guān)閉了iptables。

    CentOS7上是firewall,關(guān)閉命令:

# systemctl stop firewalld.service    # 停止firewalld服務(wù)
# systemctl disable firewalld.service    # 設(shè)置開機(jī)默認(rèn)不啟動(dòng)

確保selinux已經(jīng)關(guān)閉。

# setenforce 0  # 不重啟系統(tǒng)的狀態(tài)下關(guān)閉selinux(permissive狀態(tài))
# getenforce    # 查看狀態(tài)
# vim /etc/sysconfig/selinux    # 開機(jī)不啟動(dòng)
    SELINUX=disabled


現(xiàn)在開始介紹快速搭建LAMP的過程。

1.yum源配置

在這里使用阿里云的yum源,命令行輸入:

# wget -O /etc/yum.repos.d/CentOS-Base.repo 
# yum makecache生成緩存

2.安裝Apache

# yum install -y httpd
# vim /etc/httpd/conf/httpd.conf    # 修改配置文件
     DirectoryIndex index.html index.php  # 在該項(xiàng)后面添加index.php,支持index.php主頁
     AddType application/x-httpd-php .ph  # 添加php支持
# vim /var/www/html/index.php # 在默認(rèn)主頁存放的路徑下,添加index.php的測試文件
     <?php phpinfo(); ?>
# systemctl start httpd.service   # 啟動(dòng)httpd 
# systemctl status httpd.service    # 查看運(yùn)行狀態(tài)
# ss -ntlp    # 查看監(jiān)聽的端口
# systemctl enable httpd.service    # 設(shè)置開機(jī)啟動(dòng)

注意:如果是配置zabbix server的LAMP環(huán)境,配置文件里

DirectoryIndex index.html # 該項(xiàng)后面不要添加index.php


3.安裝MariaDB

# yum install -y mariadb-server    # yum安裝MariaDB,在CentOS6 yum install mysql-server
# vim /etc/my.cnf    # 在[mysql-safe]部分添加
    skip_name_resolve=on	# 禁止域名解析
    innodb_file_per_table=on	# 修改InnoDB為獨(dú)立表空間模式
# systemctl start mariadb.service    # 啟動(dòng)mariadb
# systemctl enable mariadb.service
# mysqladmin -u root password 'dtsdts';    # 創(chuàng)建管理員密碼
# mysql_secure_installation    # 初始化安全設(shè)置
# mysql -uroot -pdtsdts    # root用戶登錄
MariaDB [(none)]> CREATE DATABASE zabbix CHARSET 'utf8';
    #創(chuàng)建zabbix庫,默認(rèn)字符集為utf8
MariaDB [(none)]> GRANT ALL ON zabbix.* TO zbxuser@'127.0.0.1' IDENTIFIED BY 'zbxpass';
MariaDB [(none)]> GRANT ALL ON zabbix.* TO zbxuser@'localhost' IDENTIFIED BY 'zbxpass';
    # zbxuser可以從本機(jī)登錄,密碼為zbxpass,對zabbix擁有所有權(quán)限
MariaDB [(none)]> GRANT ALL ON zabbix.* TO zbxuser@'10.10.10.%' IDENTIFIED BY 'zbxpass';
    # zbxuser可以從10.10.10.0網(wǎng)段登錄,密碼為zbxpass,對zabbix擁有所有權(quán)限
MariaDB [(none)]> flush privileges;    # 刷新權(quán)限

4、安裝php

# yum install -y php php-mysql
# yum install -y php-gd  php-xml  php-process php-mbstring php-bcmath   # 安裝php擴(kuò)展組件

可以修改/etc/php.ini進(jìn)行簡單的php優(yōu)化(非必要):

max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
date.timezone PRC


5、測試

# 重啟服務(wù)
# systemctl restart httpd.service
# systemctl restart mariadb.service

瀏覽器訪問驗(yàn)證:

CentOS7上快速搭建LAMP環(huán)境


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI