環境準備
鏡像: centos 7
軟件: vmware
安裝nginx
yum intall -y nginx
錯誤處理
問題1
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=i386&repo=os error was
使用yum無法檢索到鏡像列表,解決方法如下。
解決
\1. cd /etc/sysconfig/network-scripts 進入該文件夾後,然後再ls一下,查看是否有ifcfg-ens33,有時是ifcfg-eth0
\2. vi ifcfg-ens33 進入VI的一般模式,移動光標到ONBOOT=no
\3. 按下"i"進入VI的編輯模式,把no刪除改爲yes
\4. 修改後按下esc再次進入一般模式,再按下":"到文件底部,在“:”後輸入 “wq” (保存退出)
\5. 重啓一下centos,再次試一下ip addr和 yum, 就可以了。
附加: 如果在network-scripts裏找到的是ifcfg-eth0文件,那就把以下兩項改成如下,最後重啓就行。
ONBOOT=yes MM_CONTROLLED=no
問題2
已加載插件:fastestmirror 3 .... 4 nginx.x86_64 : A high performance web server and reverse proxy 5 : server
解決
換源
1.備份
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.0)
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
3、之後先清除緩存再生成緩存
# 清除緩存``yum clean ``all``# 生存緩存``yum makecache
禁用插件
1.修改插件的配置文件
# vim /etc/yum/pluginconf.d/fastestmirror.conf
enabled = 0//由1改爲0,禁用該插件
2.修改yum的配置文件
# vim /etc/yum.conf
plugins= 0//改爲0,不使用插件
問題3
沒有可用軟件包 nginx
新裝的centos7中沒有nginx的鏡像源
因爲nginx位於第三方的yum源裏面,而不在centos官方yum源裏面
解決
安裝epel;
yum list |grep epel ##查找epel源
yum -y install epel-release ##安裝epel
問題4
./configure: error: C compiler cc is not found
解決
安裝gcc編譯
yum -y install gcc gcc-c++ autoconf automake make
yum安裝
1、安裝Nginx、mysql、PHP
綜合安裝nginx和php
包:
yum -y install nginx php-fpm php php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
2、安裝mysql
#cd /usr/local/src/
#wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
#rpm -ivh mysql57-community-release-el7-8.noarch.rpm
#yum -y install mysql-server
重啓mysql
#service mysqld restart
獲取mysql創建的隨機密碼
#grep "password" /var/log/mysqld.log
通過隨機密碼登錄
mysql -u root -p
使用命令重製密碼
mysql> alter user ``'root'``@``'localhost'` `identified by ``'Passwd123!'``;
使用’ flush privileges '刷新權限
mysql> flush privileges
‘exit’ 退出
mysql> exit;
3、啓動php
systemctl restart php-fpm ##啓動PHP服務
4、Nginx的配置文件:
5.添加nginx到自啓動
看參考鏈接
源碼包安裝
Nginx的配置及運行需要gcc 、 gcc-c++ 、 make 、 pcre、pcre-devel、zlib-devel軟件包的支持,以便提供相應的庫和頭文件,確保Nginx安裝順利。
yum install gcc gcc-c++ make pcre pcre-devel zlib-devel -y
然後將準備好的的 nginx-1.17.7.tar.gz包,拷貝至/usr/local/nginx目錄下(一般習慣在此目錄下進行安裝)進行解壓縮。
在完成解壓縮後,進入nginx-1.17.7目錄進行源碼編譯安裝。
[root@localhost 桌面]# useradd -M -s /sbin/nologin nginx
[root@localhost 桌面]# mkdir /usr/local/nginx
[root@localhost 桌面]# mv nginx-1.17.7.tar.gz /usr/local/nginx/
[root@localhost 桌面]# cd /usr/local/nginx/
[root@localhost nginx]# tar -zxvf nginx-1.17.7.tar.gz
[root@localhost nginx]# cd nginx-1.17.7/
[root@localhost nginx-1.17.7]# ./configure --prefix=/usr/local/nginx --user=nginx --group=nginx --with-http_stub_status_module
[root@localhost nginx-1.17.7]# make
[root@localhost nginx-1.17.7]# make install
[root@localhost nginx-1.17.7]# ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/
參考
錯誤處理:Could not retrieve mirrorlist