centos7無網絡下安裝部署php7.1.33+mysql5.7.28+apache2.4.6
一、
1、先ping www.baidu.com,root賬戶下,如果未聯網,創建目錄,把提前下載好的rpm包拷貝到rpm目錄下如圖:(如果沒有安裝包請查看我的另一篇教程下載這些安裝包)
mkdir /data/rpm -p
3、進入該目錄
cd /data/rpm
5、安裝該目錄下所有.rpm后綴的安裝包
yum localinstall *.rpm -y
6、安裝完后開始啟動服務
(1)安裝好后將php-fpm設置為開機啟動
systemctl enable php-fpm.service
(2)啟動php 的服務
systemctl start php-fpm #啟動
下面是php啟動關閉重啟命令,這里執行啟動:
systemctl start php-fpm #啟動
systemctl stop php-fpm #關閉
systemctl restart php-fpm #重啟
(3)apache啟動服務
systemctl start httpd.service
(4)apache開機自啟
systemctl enable httpd.service
下面是apache的啟動停止重啟命令
# 啟動apache
systemctl start httpd.service
# 停止apache
systemctl stop httpd.service
# 重啟apache
systemctl restart httpd.service
(5)啟動 MySQL 服務
systemctl start mysqld.service
(6)開機啟動 MySQL 服務
systemctl enable mysqld
7、修改 MySQL 配置文件
vim /etc/my.cnf
進入如圖界面后用i編輯,修改默認編碼為 UTF-8,添加在 [mysqld] 后
character_set_server = utf8
init_connect = 'SET NAMES utf8'
然后按Esc推出并輸入
:wq!
保存退出。
如圖:
退出后如圖:
重新加載服務
systemctl daemon-reload
9、搜索 MySQL 的 root 用戶密碼,systemctl start mysqld.service啟動后會在 /var/log/mysqld.log 中給 root 生成密碼,查看密碼:
grep 'temporary password' /var/log/mysqld.log
查看密碼后使用 root 用戶登錄
mysql -uroot -p
如圖;
10、修改 MySQL 的 root 用戶密碼
set password for 'root'@'localhost' = password('新密碼');
11、注意使用mysql數據庫,配置這一步
use mysql;
查看表
show tables;
修改表
update user set user.Host = '%' where user.User = 'root';
查看修改結果
select user.Host,user.User from user;
退出
quit;
12、現在我們要查看一下防火墻的狀態
systemctl list-unit-files|grep firewalld.service
13、如果處于enabled狀態,關閉防火墻:
systemctl stop firewalld.service
14、禁止防火墻開機自啟:
systemctl disable firewalld.service
15、配置SELinux:
vim /etc/selinux/config
按i進行編輯,把找到SELINUX=enforcing將它改為
SELINUX=disabled
然后按Esc再按:再輸入
:wq!
保存退出,退出后一定執行
reboot
命令重啟,否則會影響訪問!
16、我們還有最后一步,配置httpd.conf,先找到他的位置:
whereis httpd.conf
如圖
這個/etc/httpd就是該文件存放的目錄,我們進入該目錄:
cd /etc/httpd
然后查看
ll
我們就能看到這個文件夾里的文件,如圖:我們cd到conf這個文件夾
cd conf
17、最終到conf文件夾里編輯我們要編輯的httpd.conf文件ll
執行
vim httpd.conf
修改相應配置
關于httpd.conf我是直接用已經配置好的httpd.conf文件傳輸到該目錄系下替換原來的配置
18、修改完httpd.conf文件后記得重啟該服務
19、然后把php的源碼壓縮包放入,ll查看一下該目錄的權限
這里html目錄的權限是root,我們把權限更改為apache權限
chown -R apache:apache html(項目文件夾名稱)
20、重啟服務
systemctl restart httpd.service
21、解壓該目錄的壓縮包,注意解壓后查看項目是否在html根目錄下
tar -xvf 名稱.tar