[精讚] [會員登入]
2722

[Centos7] 安裝apache+php7+mariadb10+selinux

Centos7 安裝apache+php7+mariadb10+selinux

分享此文連結 //n.sfs.tw/11045

分享連結 [Centos7] 安裝apache+php7+mariadb10+selinux@新精讚
(文章歡迎轉載,務必尊重版權註明連結來源)
2022-10-07 12:27:57 最後編修
2017-05-10 12:54:41 By 張○○
 

自動目錄

OS

CentOS Linux release 7.3.1611 (Core)

安裝apache

# yum install httpd

 

開啟防火牆 Selinux

# firewall-cmd --zone=public --add-port=80/tcp --permanent

# firewall-cmd --reload

開啟SELINUX

# setsebool httpd_can_network_connect on

# setsebool httpd_can_network_connect_db on

# setsebool httpd_can_sendmail on

要讓httpd寫入的目錄,例如上傳目錄
# chcon -t httpd_sys_rw_content_t /path/to/upload

要讓httpd讀取的目錄,例如網頁目錄 (預設的/var/www/html已設定)
# chcon -R -t httpd_sys_content_t /path/to/html

安裝PHP7[1]

如果你已有安裝其他版本的PHP,請先移除它們

# yum remove php*

# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

# yum install php70w php70w-opcache

# yum install php70w-mysqlnd php70w-mbstring php70w-gd

# yum install php70w-pecl-imagick

===  111.10.6 更新,因為此時的php版本已經到7.4.x[2] =====

# yum -y install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

# yum -y install https://rpms.remirepo.net/enterprise/remi-release-7.rpm

# yum -y install yum-utils

# yum-config-manager --enable remi-php74

主要使用 remi來更新

# yum update

# yum install php php-cli

# php -v
PHP 7.4.32 (cli) (built: Sep 28 2022 09:09:55) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

 

設定 vi /etc/php.ini

; 時區
date.timezone =  "Asia/Taipei"
; Session 時間改一天
session.gc_maxlifetime = 86400
; 記憶體,預設128M
memory_limit = 1024M
; 上傳大小限制和時間
post_max_size = 20M
upload_max_filesize = 20M
max_input_time = 120
default_socket_timeout = 600

安裝mariadb10.9

建立 yum repository

# vim /etc/yum.repos.d/MariaDB.repo

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.9/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

# yum install MariaDB-server MariaDB-client

 

安裝 phpmyadmin

到官網 https://www.phpmyadmin.net/ 找尋下載連結

# cd /var/www/html
# wget https://files.phpmyadmin.net/phpMyAdmin/5.2.0/phpMyAdmin-5.2.0-all-languages.zip
# unzip phpMyAdmin-5.2.0-all-languages.zip

修改設定檔

# cd phpMyAdmin-5.2.0-all-languages/ 請視版本修改目錄
# mv config.sample.inc.php config.inc.php
# vi config.inc.php

 

去 [3] phpMyAdmin blowfish secret generator 取得secret,這個頁面只要點開就會隨機產生一組,只要貼上即可

$cfg['blowfish_secret'] = 'l54xE78nRD;7Fiz{K85X5e{U9iwm7k;X';

建立暫存目錄以提升速度

# mkdir tmp
# chmod 777 tmp
# chcon -t httpd_sys_rw_content_t tmp

開啟頁面,警告消失。

 

啟動

# systemctl enable httpd

# systemctl enable mariadb

# systemctl start mariadb

# systemctl start httpd

你的檔案放在 /var/www/html中

開你的網頁 http://x.x.x.x/ 來測試能不能看到歡迎畫面,我發現這頁還是responsive web design。

如果出現forbidden代表selinux或檔案權限問題,如果等很久沒頁面是防火牆問題。

其他的問題原因太複雜得CASE by CASE

參考資料

[1] https://webtatic.com/packages/php70/

[2] https://computingforgeeks.com/how-to-install-php-7-4-on-centos-7/

[3] https://phpsolved.com/phpmyadmin-blowfish-secret-generator

END

你可能感興趣的文章

[Linux] mongodb 初步--2/3 我使用mongo 的一些大小事:叢集

[Centos7] 使用網路安裝 Centos7 使用網路來安裝Centos7,雖然這不是什麼新鮮事,但可以省你的磁碟空間或光碟片

[Centos7] 安裝 semanage (selinux工具程式) 安裝selinux的工具程式 semanage

[Linux] 刪除last/lastb登出入記錄 linux shell的登出入記錄

[Centos7] 把帳號新增移除具有root權限等級的sudoer 把帳號新增或移除具有root權限等級的sudoer

[Centos7] 安裝apache+php7+mariadb10+selinux Centos7 安裝apache+php7+mariadb10+selinux

我有話要說

>>

限制:留言最高字數1000字。 限制:未登入訪客,每則留言間隔需超過10分鐘,每日最多5則留言。

訪客留言

[無留言]

隨機好文

NETCRAFT發現你的網站及作業系統 NETCRAFT可以發現你的網站及作業系統

魔球中小女孩唱的歌 The show 魔球中小女孩唱的歌 The show

[AS3] 我做的唯一一個Flash As3遊戲UFO INVADSION [AS3] 我做的唯一一個Flash As3遊戲,是第一個也是最後一個,後來就沒再寫as3,不過as3還滿好玩的。

[PHP] 檢查檔案是否是圖檔 使用getimagesize函數檢查檔案是否是圖檔

外匯課程經驗 有天遇到某個朋友的正妹朋友,說她有個很棒的外匯投資課程,要我們去聽,只收場地費200大洋。她又說續效最差一個月也有1%,誰還在苦哈哈上班?