两大主角:OpenEularOS和Nginx
一、当事人简介二、进入命令行控制台三、使用浏览器访问
两大主角:OpenEularOS和Nginx 一、当事人简介
1. OpenEularOS:
2021年9月,华为公司将基于稳定成熟的CentOS内核研发的服务器操作系统EularOS进行全量开源,形成OpenEularOS,捐赠给开放原子开源基金会(OpenAtom Foundation)并由其孵化及运营。OpenEularOS对X86、Arm64、LoogArch等主流架构提供全栈支持,具备高性能、高安全、高效协同等特点。
2. Nginx:
nginx是一个高性能的http服务器和反向代理web服务器,由俄罗斯开发者伊戈尔·赛索耶夫开发,在高并发的场景下,Nginx具有比Apache服务器更强大的性能和兼容性,支持绝大多数Linux系统,是Apache的理想替代品。
1. 确认当前环境信息:
[root@openEularOS ~] cat /etc/os-release NAME="openEuler" VERSION="20.03 (LTS)" ID="openEuler" VERSION_ID="20.03" PRETTY_NAME="openEuler 20.03 (LTS)" ANSI_COLOR="0;31"
[root@openEularOS ~] uname -i aarch64
2. cd进入想要安装的目录:
[root@openEularOS ~] cd /srv/web-server/ [root@openEularOS web-server]
3. 下载最新版本nginx压缩包:
这里建议使用官方最新版本,写博客时是1.21.6,可以前往nginx官网查看你当时的最新版本:Nginx官方网站
[root@openEularOS web-server] wget https://nginx.org/download/nginx-1.21.6.tar.gz --2022-03-02 13:49:55-- https://nginx.org/download/nginx-1.21.6.tar.gz Resolving nginx.org (nginx.org)... 52.58.199.22, 3.125.197.172 Connecting to nginx.org (nginx.org)|52.58.199.22|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 1073364 (1.0M) [application/octet-stream] Saving to: ‘nginx-1.21.6.tar.gz’ nginx-1.21.6.tar.gz 100%[=================================>] 1.02M 1.24MB/s in 0.8s 2022-03-02 13:49:58 (1.24 MB/s) - ‘nginx-1.21.6.tar.gz’ saved [1073364/1073364]
解压到当前目录:
[root@openEularOS web-server] tar -zxvf nginx-1.21.6.tar.gz
4. 安装nginx环境支持:
[root@openEularOS web-server] yum -y install pcre-devel openssl openssl-devel
5. cd进入刚才的解压目录,执行安装操作:
[root@openEularOS web-server] cd nginx-1.21.6 [root@openEularOS nginx-1.21.6] ll total 832K drwxr-xr-x 6 1001 1001 4.0K Mar 2 14:02 auto -rw-r--r-- 1 1001 1001 310K Jan 25 23:04 CHANGES -rw-r--r-- 1 1001 1001 473K Jan 25 23:03 CHANGES.ru drwxr-xr-x 2 1001 1001 4.0K Mar 2 14:02 conf -rwxr-xr-x 1 1001 1001 2.6K Jan 25 23:03 configure drwxr-xr-x 4 1001 1001 4.0K Mar 2 14:02 contrib drwxr-xr-x 2 1001 1001 4.0K Mar 2 14:02 html -rw-r--r-- 1 1001 1001 1.4K Jan 25 23:03 LICENSE -rw------- 1 root root 438 Mar 2 14:07 Makefile drwxr-xr-x 2 1001 1001 4.0K Mar 2 14:02 man drwx------ 3 root root 4.0K Mar 2 14:08 objs -rw-r--r-- 1 1001 1001 49 Jan 25 23:03 README drwxr-xr-x 9 1001 1001 4.0K Mar 2 14:02 src [root@openEularOS nginx-1.21.6] ./configure #此处省略很多行 [root@openEularOS nginx-1.21.6] make install #此处又省略很多行
6. 启动服务,检查运行情况:
[root@openEularOS nginx-1.21.6] cd /usr/local/nginx/sbin/ [root@openEularOS sbin] ll total 4.5M -rwx------ 1 root root 4.5M Mar 2 14:08 nginx [root@openEularOS sbin] ./nginx [root@openEularOS sbin]
[root@openEularOS sbin] ps -ef | grep nginx root 5729 1 0 14:12 ? 00:00:00 nginx: master process ./nginx nobody 5730 5729 0 14:12 ? 00:00:00 nginx: worker process root 5746 2938 0 14:13 pts/0 00:00:00 grep --color=auto nginx
7. 修改运行用户nobody:
[root@openEularOS sbin] cd /usr/local/nginx/conf/ [root@openEularOS conf] ll total 68K -rw------- 1 root root 1.1K Mar 2 14:08 fastcgi.conf -rw------- 1 root root 1.1K Mar 2 14:08 fastcgi.conf.default -rw------- 1 root root 1007 Mar 2 14:08 fastcgi_params -rw------- 1 root root 1007 Mar 2 14:08 fastcgi_params.default -rw------- 1 root root 2.8K Mar 2 14:08 koi-utf -rw------- 1 root root 2.2K Mar 2 14:08 koi-win -rw------- 1 root root 5.3K Mar 2 14:08 mime.types -rw------- 1 root root 5.3K Mar 2 14:08 mime.types.default -rw------- 1 root root 2.6K Mar 2 14:08 nginx.conf -rw------- 1 root root 2.6K Mar 2 14:08 nginx.conf.default -rw------- 1 root root 636 Mar 2 14:08 scgi_params -rw------- 1 root root 636 Mar 2 14:08 scgi_params.default -rw------- 1 root root 664 Mar 2 14:08 uwsgi_params -rw------- 1 root root 664 Mar 2 14:08 uwsgi_params.default -rw------- 1 root root 3.6K Mar 2 14:08 win-utf [root@openEularOS conf] vi nginx.conf
按【i】键进入输入模式,将nobody改为root,之后按Esc进入底栏模式,输入【:wq】保存修改并退出vi编辑器,配置修改完成。此时可以通过重新启动nginx服务达到对外访问的效果。
在浏览器地址栏输入http://你的公网IP:80,看下如下页面就说明部署成功,想当年的马云一样,创办一个中国黄页吧,人生巅峰指日可待(狗头)
这里默认展示的是/nginx-1.21.6/html/index.html页面文件,后期部署时,可以将你的html文件命名为index,或通过修改配置文件实现访问。



