一、安装nginx
安装方式有两种,一种源码安装,一种yum安装。
源码安装>
1、下载源码,网址:http://nginx.org/en/download.html
wget http://nginx.org/download/nginx-1.16.1.tar.gz
若提示没有wget指令,yum wget 安装一下
2、解压压缩包
tar -zxvf nginx-1.16.1.tar.gz,解压目录/usr/local/src,位置自己选择
3、编译,安装
./configure --prefix=/usr/local/nginx --with-http_ssl_module
安装目录 配置ssl需要,如不配置可不加
安装时可能会报错
configure: error: You need a C++ compiler for C++ support
解决:yum install -y gcc gcc-c++
./configure: error: the HTTP rewrite module requires the PCRE library.
解决:yum install -y pcre-devel openssl openssl-devel
最后两步
make
make install
源码安装到此安装完成。
之后可将nginx添加到service
/etc/init.d 目录下创建nginx文件,文件写入以下代码
更改权限:chmod 777 nginx
添加nginx开机自启:chkconfig nginx on (此处是centos6+版本,cnetos7版本不一样自行查找)
此时应该可用 service nginx start 等命令操作nginx
设置nginx为全局指令:(软连接)ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin/nginx
yum安装>
1、yum源配置:
# CentOS 6.5(亲测有效)
yum clean all
yum --disablerepo="epel" update nss
# CentOS 7.x(未测试)
yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
2、安装nginx
yum install -y nginx
添加开机自启
chkconfig nginx on
安装之后可查看版本:nginx -v
yum安装会自动添加到service无需手动添加
二、安装PHP
此处只写yum安装,源码安装自行查找
1、配置yum源
yum install epel-release
# Centos 5.X
rpm -Uvh http:
//mirror.webtatic.com/yum/el5/latest.rpm
# CentOs 6.x
rpm -Uvh http:
//mirror.webtatic.com/yum/el6/latest.rpm
# CentOs 7.X
rpm -Uvh https:
//mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https:
//mirror.webtatic.com/yum/el7/webtatic-release.rpm
2、安装扩展包(这里直接全部安装)
PHP7.1
yum install php71w php71w-mysql php71w-odbc php71w-common php71w-embedded php71w-pgsql php71w-xml php71w-ldap php71w-fpm php71w-gd php71w-pdo php71w-devel php71w-mbstring php71w-mcrypt php71w-cli php71w-json php71w-imap php71w-bcmath mod_php71w php71w-pear
PHP5.6
yum install php71w php71w-mysql php71w-odbc php71w-common php71w-embedded php71w-pgsql php71w-xml php71w-ldap php71w-fpm php71w-gd php71w-pdo php71w-devel php71w-mbstring php71w-mcrypt php71w-cli php71w-json php71w-imap php71w-bcmath mod_php71w php71w-pear
3、启动
开机自启
chkconfig php-fpm on
service php-fpm start
或
/etc/init.d/php-fpm start
Nginx配置SSL
nginx配置php
本文地址:http://silver.eleuu.com/?post=32
版权声明:若无注明,本文皆为“月丶”原创,转载请保留文章出处。