cd /etc/yum.repos.d/
rm -rf *
2、下载:
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
3、下载完后执行:rpm -e rpmforge-release --nodeps
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
rpm -ivh rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
(再次执行:rpm -e rpmforge-release --nodeps)
4、最后分别执行:
yum clean all;yum makecache;yum update
如果提示404访问不到源编辑/etc/yum.repos.d/rpmforge.repo文件替换成清华大学的源
vim /etc/yum.repos.d/rpmforge.repo
### Name: RPMforge RPM Repository for RHEL 6 - dag
### URL: http://rpmforge.net/
[rpmforge]
name = RHEL $releasever - RPMforge.net - dag
baseurl = http://mirrors.tuna.tsinghua.edu.cn/repoforge/redhat/el6/en/$basearch/rpmforge
mirrorlist = http://mirrors.tuna.tsinghua.edu.cn/repoforge/redhat/el6/en/mirrors-rpmforge
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge
enabled = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
[rpmforge-extras]
name = RHEL $releasever - RPMforge.net - extras
baseurl = http://mirrors.tuna.tsinghua.edu.cn/repoforge/redhat/el6/en/$basearch/extras
mirrorlist = http://mirrors.tuna.tsinghua.edu.cn/repoforge/redhat/el6/en/mirrors-rpmforge-extras
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-extras
enabled = 0
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
[rpmforge-testing]
name = RHEL $releasever - RPMforge.net - testing
baseurl = http://mirrors.tuna.tsinghua.edu.cn/repoforge/redhat/el6/en/$basearch/testing
mirrorlist = http://mirrors.tuna.tsinghua.edu.cn/repoforge/redhat/el6/en/mirrors-rpmforge-testing
#mirrorlist = file:///etc/yum.repos.d/mirrors-rpmforge-testing
enabled = 0
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
gpgcheck = 1
wget ftp://ftp.bytemine.net/exim/pcre/pcre-8.13.tar.gz
wget http://www.openssl.org/source/openssl-fips-2.0.9.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz
wget http://nginx.org/download/nginx-1.12.1.tar.gz
2、安装gcc
yum install gcc gcc-c++
3、安装pcre
tar -zxvf pcre-8.13.tar.gz
cd pcre-8.13
./configure
make
make install
4、安装zlib
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install
5、安装openssl
yum -y install openssl openssl-devel
6、安装nginx
tar -zxvf nginx-1.12.1.tar.gz && cd nginx-1.12.1 && ./configure --with-http_ssl_module && make && make install
7、检查nginx是否安装成功
# cd /usr/local/nginx/sbin
# ./nginx -t
结果显示:
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
8、nginx启动、重启、停止
echo "/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf" >> /etc/rc.local
10、nginx.conf文件配置:
vim /usr/local/nginx/conf/nginx.conf
user apache; ###用户组设置成与php-fpm.conf文件完全一致
worker_processes 8;
events {
worker_connections 65535;
}
虚拟主机配置:
server {
listen 80;
server_name yourweb.com;
location / {
root /data/www/your_web;
index index.html index.htm index.php;
}
location ~ \.php$ {
root /data/www/your_web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath mhash libmcrypt libmcrypt-devel php-fpm php-redis php-solr
/etc/init.d/nginx restart #重启nginx(或者:/usr/local/nginx/sbin/nginx -s reload)
/etc/rc.d/init.d/php-fpm #启动php-fpm
chkconfig php-fpm on #设置开机启动
yum install epel-release //扩展包更新包安装完成再执行一次安装php
还有未安装的尝试编辑/etc/yum.repos.d/epel.repo,把基础的恢复,镜像的地址注释掉#mirrorlist
Nginx配置php后,访问php页面如果出现File not found (日志信息为:FastCGI sent in stderr: "Primary script unknown"),关闭SELinux即可
参考文章