本篇文章介绍基于CentOS 7.0安装PHP7.3.7 + Nginx1.62 + Mysql5.7.26
安装Nginx1.62
切换到root账户执行安装,否则可能会遇到权限问题
sudo su
1、安装编译工具及库文件
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
2、首先要安装 PCRE
PCRE 作用是让 Nginx 支持 Rewrite 功能
2.1 下载
[root@10 local]# cd /vagrant
[root@10 vagrant]# wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
2.2 解压、进入解压文件夹
[root@10 vagrant]# tar -zxvf pcre-8.35.tar.gz
[root@10 vagrant]# cd pcre-8.35
2.3 编译安装
[root@10 pcre-8.35]# ./configure
[root@10 pcre-8.35]# make && make install
遇到错误:
[root@10 pcre-8.35]# make && make install
CDPATH="${ZSH_VERSION+.}:" && cd . && /bin/sh /vagrant/pcre-8.35/missing aclocal-1.14 -I m4
/vagrant/pcre-8.35/missing: Zeile 81: aclocal-1.14: Kommando nicht gefunden.
WARNING: 'aclocal-1.14' is missing on your system.
You should only need it if you modified 'acinclude.m4' or
'configure.ac' or m4 files included by 'configure.ac'.
The 'aclocal' program is part of the GNU Automake package:
<http://www.gnu.org/software/automake>
It also requires GNU Autoconf, GNU m4 and Perl in order to run:
<http://www.gnu.org/software/autoconf>
<http://www.gnu.org/software/m4/>
<http://www.perl.org/>
make: *** [aclocal.m4] Fehler 127
解决:
执行下面命令,在重新编译、安装
[root@10 pcre-8.35]# autoreconf -ivf
[root@10 pcre-8.35]# ./configure
[root@10 pcre-8.35]# make && make install
2.4 查看pcre版本
[root@10 pcre-8.35]# pcre-config --version
8.35
3、安装Nginx
3.1 卸载旧版本
yum remove nginx
3.2 下载 Nginx
[root@10 pcre-8.35]# cd /vagrant/
[root@10 vagrant]# wget http://nginx.org/download/nginx-1.6.2.tar.gz
3.3 解压、进入解压文件夹
[root@10 vagrant]# tar zxvf nginx-1.6.2.tar.gz
[root@10 vagrant]# cd nginx-1.6.2
3.4 编译安装
[root@10 nginx-1.6.2]# ./configure --prefix=/usr/local/webserver/nginx \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre=/usr/local/src/pcre-8.3
[root@10 nginx-1.6.2]# make && make install
- –prefix=/usr/local/webserver/nginx:为安装目录
遇到错误:
[root@10 nginx-1.6.2]# make && make install
make -f objs/Makefile
make[1]: Entering directory `/vagrant/nginx-1.6.2'
cd /usr/local/src/pcre-8.3 \
&& if [ -f Makefile ]; then make distclean; fi \
&& CC="cc" CFLAGS="-O2 -fomit-frame-pointer -pipe " \
./configure --disable-shared
/bin/sh: Zeile 0: cd: /usr/local/src/pcre-8.3: Datei oder Verzeichnis nicht gefunden
make[1]: *** [/usr/local/src/pcre-8.3/Makefile] Fehler 1
make[1]: Leaving directory `/vagrant/nginx-1.6.2'
make: *** [build] Fehler 2
/usr/local/src/pcre-8.3,路径有误,本机下载路径为 /vagrant/pcre-8.3,所以要修改过来
解决:
修改编译命令pcre-8.3的路径 --with-pcre,重新编译
[root@10 nginx-1.6.2]# ./configure --prefix=/usr/local/webserver/nginx \
--with-http_stub_status_module \
--with-http_ssl_module \
--with-pcre=/vagrant/pcre-8.3
编译好在重新执行安装
[root@10 nginx-1.6.2]# make && make install
3.5 查看版本
[root@10 vagrant]# /usr/local/webserver/nginx/sbin/nginx -v
nginx version: nginx/1.6.2
添加Nginx路径到环境变path
[root@10 vagrant]# export PATH=/usr/local/webserver/nginx/sbin:$PATH
[root@10 vagrant]# echo $PATH
/usr/local/webserver/nginx/sbin:/usr/local/webserver/nginx/sbin/nginx:/sbin:/bin:/usr/sbin:/usr/bin
可直接执行nginx命令查看版本
[root@10 vagrant]# nginx -v
nginx version: nginx/1.6.2
4、配置Nginx
创建 Nginx 运行使用的用户 www
[root@10 vagrant]# /usr/sbin/groupadd www
[root@10 vagrant]# /usr/sbin/useradd -g www www
找不到配置文件的可用命令查找
[root@10 vagrant]# find / -name nginx.conf
/usr/local/webserver/nginx/conf/ngin