How to configure nginx on centos server
Download the secure terminal mobaxterm_personal
First, after downloading the secure terminal, connect to your own public network ip
The connection is successful The display is as above.
nginx Introduction
nginx is a lightweight web server and reverse proxy server. Compared with apache and lighttpd, it has the advantages of less memory and high stability. Its most common use is to provide a reverse proxy service
After connecting to the server
The first step: install gcc gcc-c
The command is :
yum install -y gcc gcc-c++
Step 2: Install the pcre library
$ cd /usr/local/ $ wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.33/pcre-8.33.tar.gz $ tar -zxvf pcre-8.36.tar.gz $ cd pcre-8.36 $ ./configure $ make && make install
If an error is reported: configure: error: you need a c compiler for c support
Solution: yum install -y gcc gcc-c
Step 3: Install ssl library
$ cd /usr/local/ $ wget http://www.openssl.org/source/openssl-1.0.1j.tar.gz $ tar -zxvf openssl-1.0.1j.tar.gz $ cd openssl-1.0.1j $ ./config $ make && make install
Step 4: Install zlib inventory
$ cd /usr/local/ $ wget http://zlib.net/zlib-1.2.11.tar.gz $ tar -zxvf zlib-1.2.11.tar.gz $ ./configure $ make && make install
Step 5: Install nginx
$ cd /usr/local/ $ wget http://nginx.org/download/nginx-1.8.0.tar.gz $ tar -zxvf nginx-1.8.0.tar.gz $ cd nginx-1.8.0 $ ./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module (注: --with-http_ssl_module:这个不加后面在nginx.conf配置ssl:on后,启动会报nginx: [emerg] unknown directive "ssl" in /opt/nginx/conf/nginx.conf 异常) $ make && make install
Start nginx
$ /usr/local/nginx/sbin/nginx
Step 6: Check whether the startup is successful
Open the browser to access the IP of this machine. If the browser displays welcome to nginx!, it means that nginx has been installed and run successfully.
Record what I encountered during this process:
Proceed In the sixth step, the connection to the browser was unsuccessful and there was no response, so I checked whether port 80 of the firewall was opened.
The command is:
firewall- cmd --list-all Check port 80
firewall-cmd --zone=public --add-port=80/tcp If port 80 is not open, open port 80
firewall- cmd --reload Reopen the firewall
Restart the nginx service again:
/usr/local/nginx/sbin/nginx –s reload
It is found that it still cannot connect to this IP address, check whether the local connection is normal:
The command is:
curl localhost
As shown in the picture, it is found that the local connection is successful, but the ip cannot be accessed
Finally, I checked and found that it was because of the new server. The Alibaba Cloud security group only opened ports 22 and 3389, but did not open port 80.
Only these two port numbers are not enough. In order to be able to connect to the server, port 80 needs to be opened.
Add the configuration rules of the security group
Since we are using Alibaba Cloud, we use Alibaba Cloud's security group operations to achieve the port opening effect.
After logging in to Alibaba Cloud, select in the following order: Cloud Server ecs->Security Group->Configuration Rules
Add port 80
As shown in the picture only Two modifications need to be made: Port range: 21/21 means starting from 21 and ending at 21Authorization object: 0.0.0.0/0 means that all IP addresses can access the portThe above is the detailed content of How to configure nginx on centos server. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics





Improve HDFS performance on CentOS: A comprehensive optimization guide to optimize HDFS (Hadoop distributed file system) on CentOS requires comprehensive consideration of hardware, system configuration and network settings. This article provides a series of optimization strategies to help you improve HDFS performance. 1. Hardware upgrade and selection resource expansion: Increase the CPU, memory and storage capacity of the server as much as possible. High-performance hardware: adopts high-performance network cards and switches to improve network throughput. 2. System configuration fine-tuning kernel parameter adjustment: Modify /etc/sysctl.conf file to optimize kernel parameters such as TCP connection number, file handle number and memory management. For example, adjust TCP connection status and buffer size

CentOS will be shut down in 2024 because its upstream distribution, RHEL 8, has been shut down. This shutdown will affect the CentOS 8 system, preventing it from continuing to receive updates. Users should plan for migration, and recommended options include CentOS Stream, AlmaLinux, and Rocky Linux to keep the system safe and stable.

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

Complete Guide to Checking HDFS Configuration in CentOS Systems This article will guide you how to effectively check the configuration and running status of HDFS on CentOS systems. The following steps will help you fully understand the setup and operation of HDFS. Verify Hadoop environment variable: First, make sure the Hadoop environment variable is set correctly. In the terminal, execute the following command to verify that Hadoop is installed and configured correctly: hadoopversion Check HDFS configuration file: The core configuration file of HDFS is located in the /etc/hadoop/conf/ directory, where core-site.xml and hdfs-site.xml are crucial. use

You can query the Docker container name by following the steps: List all containers (docker ps). Filter the container list (using the grep command). Gets the container name (located in the "NAMES" column).

Steps to configure IP address in CentOS: View the current network configuration: ip addr Edit the network configuration file: sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change IP address: Edit IPADDR= Line changes the subnet mask and gateway (optional): Edit NETMASK= and GATEWAY= Lines Restart the network service: sudo systemctl restart network verification IP address: ip addr

Common problems and solutions for Hadoop Distributed File System (HDFS) configuration under CentOS When building a HadoopHDFS cluster on CentOS, some common misconfigurations may lead to performance degradation, data loss and even the cluster cannot start. This article summarizes these common problems and their solutions to help you avoid these pitfalls and ensure the stability and efficient operation of your HDFS cluster. Rack-aware configuration error: Problem: Rack-aware information is not configured correctly, resulting in uneven distribution of data block replicas and increasing network load. Solution: Double check the rack-aware configuration in the hdfs-site.xml file and use hdfsdfsadmin-printTopo

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.
