登陆腾讯云centos安装nginx环境

本地电脑安装putty,下载网址https://www.ssh.com/ssh/putty/download
在这里插入图片描述
然后输入用户名,默认root
输入密码,输入密码时候并不会出现星号,输入完直接会车。

开始就告诉你,如果wget一个安装包很慢或者下载不下来,可以把网址复制到迅雷里下载,即使被墙了,迅雷也能p2p帮你下载下来的。然后自己使用winscp复制到 /usr/local/src目录下即可。

1.安装make
yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++

2.安装pcre
PCRE(Perl Compatible Regular Expressions)是一个Perl库,包括 perl 兼容的正则表达式库。这些在执行正规表达式模式匹配时用与Perl 5同样的语法和语义是很有用的。Boost太庞大了,使用boost regex后,程序的编译速度明显变慢。测试了一下,同样一个程序,使用boost::regex编译时需要3秒,而使用pcre不到1秒。因此改用pcre来解决C语言中使用正则表达式的问题.网址:ftp://ftp.pcre.org/pub/pcre/。自己查找最新版本的。
在这里插入图片描述
cd /usr/local/src
wget ftp://ftp.pcre.org/pub/pcre/pcre-8.44.tar.gz
tar -zxvf pcre-8.44.tar.gz
cd pcre-8.44
./configure
make && make install

3.安装zlib
zlib 是通用的压缩库,提供了一套 in-memory 压缩和解压函数,并能检测解压出来的数据的完整性(integrity)。zlib 也支持读写 gzip (.gz) 格式的文件。网址:http://www.zlib.net/。可以找到最新版本。
cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install

4.安装openssl
ssl,可以让网站变成https。需要ssl证书,阿里云腾讯云可以申请免费的。下载网址:https://www.openssl.org/source/

cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.1.1e.tar.gz
tar -zxvf openssl-1.1.1e.tar.gz
cd openssl-1.1.1e/
./config --prefix=/usr/local/ssl --openssldir=/usr/local/ssl shared zlib
make && make install

5.安装nginx
这个就不用说了,网址 http://nginx.org/download/,查找最新版。
cd /usr/local/src
wget http://nginx.org/download/nginx-1.17.9.tar.gz
tar -zxvf nginx-1.17.9.tar.gz
cd nginx-1.17.9
./configure
make && make install

./configure时候报错了。
./configure: error: the HTTP rewrite module requires the PCRE library.
解决:
yum -y install pcre-devel
yum -y install openssl openssl-devel
然后再次执行./configure

启动nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
在这里插入图片描述
开机自启动
即在rc.local增加启动代码就可以了。
vi /etc/rc.local
增加一行 /usr/local/nginx/sbin/nginx
设置执行权限:
chmod 755 rc.local

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章