我發現在linux上面安裝linux很簡單 在CentOS release 6.5 上面
先看一下操作系統的版本:
lsb_release -a
直接執行
yum install nginx
系統自動的將nginx注冊到環境變量當中,
如何查看linux的環境變量
echo $PATH
結果:
[root@tx-qcs-regulation-xm-staging01 sbin]# echo $PATH /usr/local/java/bin:/sbin:/bin:/usr/sbin:/usr/bin [root@tx-qcs-regulation-xm-staging01 sbin]#
請注意:linux的環境變量,有三組:
/usr/local/java/bin
/sbin:/bin
/usr/sbin:/usr/bin
也就是說 在這三組文件夾下面的文件 都在環境變量里,都可以執行的:
看一下nginx是否在這底下:
whereis nginx
[root@tx-qcs-regulation-xm-staging01 sbin]# echo $PATH /usr/local/java/bin:/sbin:/bin:/usr/sbin:/usr/bin [root@tx-qcs-regulation-xm-staging01 sbin]# whereis nginx nginx: /usr/sbin/nginx /etc/nginx /usr/share/nginx
注意到:nginx在/usr/sbin/nginx底下,因此 nginx已經注冊到環境變量里面了,可以直接執行
啟動nginx :
[root@tx-qcs-regulation-xm-staging01 sbin]# nginx
[root@tx-qcs-regulation-xm-staging01 sbin]#
這就是啟動了,驗證一下:
使用 ps -ef | grep 'nginx'
[root@tx-qcs-regulation-xm-staging01 sbin]# nginx [root@tx-qcs-regulation-xm-staging01 sbin]# ps -ef|grep 'nginx' root 10363 1 0 19:17 ? 00:00:00 nginx: master process nginx nginx 10364 10363 0 19:17 ? 00:00:00 nginx: worker process root 10857 7344 0 19:17 pts/0 00:00:00 grep nginx
有master進程,說明啟動成功了;
就可以了;停止NGINX:命令:
nginx -s stop
以下是原來的博客;
如果安裝了centos 之后無法上網,只需要修改一個小小的配置使用 root用戶,進入 /etc/sysconfig/network-script/ifcfg-ens33 (可能你的網卡不是這名字,需要找到自己的網卡 在這個文件夾中輸入 ifcfg-e 然后按TAB鍵就可以) 在這個文件中 修改onboot=yes (原來是 no) 然后 重啟機器 命令 reboot now 就可以上網了;
(1) 登陸linux: 下載nginx: wget http://nginx.org/download/nginx-1.8.0.tar.gz 下載openssl : wget http://www.openssl.org/source/openssl-fips-2.0.9.tar.gz 下載zlib : wget http://zlib.net/zlib-1.2.11.tar.gz
(這里是最新的版本,如果這個地址無法下載,請在瀏覽器中輸入http://zlib.net/ 看看最近的是什么版本,改一下版本號就可以 比如 wget http://zlib.net/zlib-1.2.34.tar.gz)
下載pcre : wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
(如果沒有此壓縮包,跟剛才一樣的處理,輸入ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/,看一下最近發布的包,然后改一下 包的版本,再下載即可)
下載perl5 wget http://www.cpan.org/src/5.0/perl-5.16.1.tar.gz
如果各位下載不方便可以直接從本人雲盤下載
zlib:
https://pan.baidu.com/s/1dE0TGdV
pcre:
https://pan.baidu.com/s/1boNs3lP
perl:
https://pan.baidu.com/s/1i4RjZRB
(2)如果沒有安裝c++編譯環境,還得安裝,通過yum install gcc-c++ -y完成安裝
(3)別忘了安裝perl5 (編譯openssl需要perl5)
解壓源碼包
[root@akinlau /]# tar -xzf perl-5.16.1.tar.gz
編譯並安裝,目錄可以自定義
[root@akinlau /]# cd perl-5.16.1
[root@akinlau perl-5.16.1]# ./Configure -des -Dprefix=/usr/local/perl
[root@akinlau perl-5.16.1]# make
[root@akinlau perl-5.16.1]# make test
[root@akinlau perl-5.16.1]# make install
如果系統以前已安裝了舊版本的perl的話,替換系統原有的版本。
[root@akinlau perl-5.16.1]# mv /usr/bin/perl /usr/bin/perl.bak
[root@akinlau perl-5.16.1]# ln -s /usr/local/perl/bin/perl /usr/bin/perl
再看看是不是最新的版本
[root@akinlau perl-5.16.1]# perl -v
This is perl 5, version 16, subversion 1 (v5.16.1) built for x86_64-linux
Copyright 1987-2012, Larry Wall
Perl may be copied only under the terms of either the Artistic License or the
GNU General Public License, which may be found in the Perl 5 source kit.
Complete documentation for Perl, including FAQ lists, should be found on
this system using “man perl” or “perldoc perl”. If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.
如果看到以上信息,就證明perl安裝成功了。
(4)然后開始安裝:openssl : [root@localhost] tar zxvf openssl-fips-2.0.9.tar.gz [root@localhost] cd openssl-fips-2.0.9 [root@localhost] ./config && make && make install (5)安裝pcre: [root@localhost] tar zxvf pcre-8.36.tar.gz [root@localhost] cd pcre-8.36 [root@localhost] ./configure && make && make install (6)開始安裝:zlib: [root@localhost]tar zxvf zlib-1.2.8.tar.gz [root@localhost] cd zlib-1.2.8 [root@localhost] ./configure && make && make install (7) 最后安裝nginx [root@localhost]tar zxvf nginx-1.8.0.tar.gz [root@localhost] cd nginx-1.8.0 [root@localhost] ./configure && make && make install
(8) 啟動nginx
/usr/local/nginx/sbin/nginx
然后測試一下:
使用ps -ef | grep nginx
然后前台訪問: 使用 http://192.168.111.135(請換成您機器的ip)
(9)然后總是無法顯示
原因需要把 防火牆關掉
方法: systemctl stop firewalld.service
systemctl disable firewalld.service
(10)然后安裝成功
(11) 如果想要停止,請使用:
pkill -9 nginx
后面的問題; 后來我發現 修改了 html/index.html中的文件,卻沒有生效,把 conf/nginx.conf中的開始頁面,也是沒效果,這個一直不知道原因,哪位知道能否說一下原因;
參考:http://www.centoscn.com/image-text/install/2014/0928/3869.html
安裝perl5:
http://www.centoscn.com/image-text/install/2014/0928/3869.html
啟動nginx
http://www.cnblogs.com/codingcloud/p/5095066.html