1 將本地的yum源 切換為 阿里云yum源
1罩驻、備份
[root]$ mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下載新的CentOS-Base.repo 到/etc/yum.repos.d/
// 選擇 CentOS 7
[root]$ wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
[root]$ curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3、之后
[root]$ yum clean all 清除緩存
[root]$ yum makecache生成緩存
[root]$ yum -y update 更新整個(gè)倉(cāng)庫(kù)
[root]$ init 1 重啟機(jī)器
2 安裝php7.1X
使用 Webtatic Yum Repository 安裝 php 里面包含了所以最新版本的PHP
CentOS/RHEL 7.x:
[root]$ rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
//或者
[root]$ yum install epel-release
[root]$ rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
[root]$ yum makecache
(企業(yè)版 Linux 附加軟件包(epel)EPEL 官網(wǎng))
安裝php71詳細(xì)文檔
yum install -y mod_php71w //main
yum install -y php71w-cli
yum install -y php71w-fpm
yum install -y php71w-pdo //PHP PDO 擴(kuò)展
yum install -y php71w-mbstring // Mbstring 擴(kuò)展
yum install -y php71w-mcrypt // Mcrypt 擴(kuò)展
yum install -y php71w-gd // Gd擴(kuò)展
yum install -y php71w-mysqlnd // mysql 相關(guān)擴(kuò)展
yum install -y php71w-pecl-redis // redis 擴(kuò)展
3 安裝nginx
[root]$ yum install -y nginx
注解:?jiǎn)为?dú)安裝最新版本: 安裝nginx nginx官方下載頁(yè)
進(jìn)入官網(wǎng) 找到download頁(yè)的 Linux packages for stable version
找到教程
4 安裝redis
[root]$ yum install -y redis
豬 :安裝最新版本 redis官網(wǎng)安裝教程
5 安裝mysql5.7
msyql 官網(wǎng) download yum Respository 找到 yum Repository
[root]$ rpm -Uvh https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
[root]$ yum makecache
[root]$ yum install -y mysql-community-server
安裝歷史版本
查看 repository 當(dāng)前版本
[root]$ yum repolist all | grep mysql
Repository epel is listed more than once in the configuration
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
mysql-cluster-7.5-community/x86_64 MySQL Cluster 7.5 Community disabled
mysql-cluster-7.5-community-source MySQL Cluster 7.5 Community - disabled
mysql-cluster-7.6-community/x86_64 MySQL Cluster 7.6 Community disabled
mysql-cluster-7.6-community-source MySQL Cluster 7.6 Community - disabled
!mysql-connectors-community/x86_64 MySQL Connectors Community enabled: 42
mysql-connectors-community-source MySQL Connectors Community - disabled
!mysql-tools-community/x86_64 MySQL Tools Community enabled: 53
mysql-tools-community-source MySQL Tools Community - Sourc disabled
mysql-tools-preview/x86_64 MySQL Tools Preview disabled
mysql-tools-preview-source MySQL Tools Preview - Source disabled
mysql55-community/x86_64 MySQL 5.5 Community Server disabled
mysql55-community-source MySQL 5.5 Community Server - disabled
mysql56-community/x86_64 MySQL 5.6 Community Server disabled
mysql56-community-source MySQL 5.6 Community Server - disabled
!mysql57-community/x86_64 MySQL 5.7 Community Server enabled: 227
mysql57-community-source MySQL 5.7 Community Server - disabled
mysql80-community/x86_64 MySQL 8.0 Community Server disabled
mysql80-community-source MySQL 8.0 Community Server - disabled
mysql57-community/x86_64 ------- enabled ---
切換版本
[root]$ yum-config-manager --disable mysql57-community
[root]$ yum-config-manager --enable mysql56-community
// yum-config-manager 指令 not found 執(zhí)行下面
[root]$ yum -y install yum-utils
// 安裝
[root]$ yum install -y mysql-community-server
啟動(dòng)軟件
在此之前需要開(kāi)發(fā)端口
1.設(shè)置騰訊云 中的 安全組 边锁,不然 端口全部開(kāi)放 選擇默認(rèn)[放通22票腰,80颖杏,443螟蒸,3306端口和ICMP協(xié)議] 滿足基本需求
2.設(shè)置firewall
[root]$ firewall-cmd --add-port=80/tcp --permanent
[root]$ firewall-cmd --add-port=3306/tcp --permanent
.......
[root]$ firewall-cmd --reload
1.nginx [nginx:nginx]
[root]$ systemctl start nginx
使用默認(rèn)配置文件 /etc/nginx/nginx.conf 即可 如果想深入了解: (配置詳細(xì)說(shuō)明)
修改 /etc/nginx/conf.d/default.conf 文件 把php文件交給php-fpm處理
server {
.....
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
.....
}
修改完之后 需要 restart nginx服務(wù)
2.php-fpm [apache:apache]
[root]$ systemctl start php-fpm
3. MySQL
[root]$ systemctl start mysqld
修改mysql登錄密碼:
//# 找到臨時(shí)密碼
[root]$ grep "password" /var/log/mysqld.log
2018-03-15T02:35:02.355088Z 1 [Note] A temporary password is generated for root@localhost: LDl16K=kbIrm
//#使用臨時(shí)密碼登錄并修改密碼
[mysql> set password = password('**********'); #密碼需要有大小寫(xiě)字母符號(hào)和數(shù)字
[mysql> flush privileges; #刷新
修改字符集編碼
編輯 /etc/my.cnf
在 [mysqld] 下添加 character-set-server=utf8 即可
4 Redis
[root]$ redis-server /etc/redis.conf -daemonize