First, prepare
Nginx version: nginx-1.7.7.tar.gz please download the corresponding version on your own website.
Second, step
? Create a new Queenlove user on Linux
[Email protected]/]# useradd queenlove-d/queenlove
To set a new user password, the following message appears, follow the prompts to do
[[email protected]/]# passwd queenlove change user queenlove password. New Password: invalid password: It re-enters a new password based on a dictionary word: passwd: All authentication tokens have been successfully updated
? Create a directory Queenlove, and set permissions
[Email protected]/]# mkdir/queenlove[[email protected]/]# chown queenlove:queenlove/queenlove/-R
? Some of the Nginx modules rely on some LIB libraries, before installing Nginx, you must install these LIB libraries
[Email protected]/]# yum-y install gcc-c++ [[email protected]/]# yum-y install pcre pcre-devel [[Email Protec Ted]/]# yum-y install zlib zlib-devel [[email protected]/]# yum-y install OpenSSL openssl-devel
Upload Nginx file Package and unzip the installation
[[email protected]/]# mkdir/usr/local/src/nginx[[email protected]/]# Cd/usr/local/src/nginx[[email protected] nginx] # Rzz waiting to Receive.**b0100000023be50[[email protected] nginx]# LS-LRT total usage 804-rw-r--r--. 1 root root 819949 November 9 nginx-1.7.7.tar.gz[[email protected]/]# TAR-XVF Nginx-1.7.7.tar.gz[[email protected]/ ]# CD nginx-1.7.7
? Install Nginx to Queenlove
[Email protected]/]# mkdir-p/queenlove/soft/nginx[[email protected]/]#./configure--prefix=/queenlove/soft/nginx- -user=queenlove--group=queenlove[[email protected]/]# make [[e-mail protected]/]# make install
Enter the Queenlove directory, you will find all the file directory is the root user, this time need to modify/queenlove under the file belongs to, after executing the following command, you will find that the owning has changed
[Email protected]/]# cd/queenlove[[email protected] queenlove]$ ls-lrtdrwxr-xr-x. 3 root root 4096 June 06:49 soft #属于root [[email protected] root]$ CD Soft[[email protected] soft]$ ls-lrtdrwxr-x R-x. Root root 4096 June #属于root [[email protected]/]# chown queenlove:queenlove/soft/-r[[email prote CTED] queenlove]# ls-lrtdrwxr-xr-x. 3 queenlove queenlove 4096 June 06:49 soft #属于queenLove [[email protected] queenlove]# CD Soft[[email protected] s oft]# Ls-lrtdrwxr-xr-x. Queenlove queenlove 4096 June #属于queenLove
Switch Queenlove user, to start nginx as a normal user, easy to manage, enter the/queenlove/soft/nginx/sbin directory under the start Nginx
[[email protected] sbin]# Cd/queenlove/soft/nginx/sbin[[email protected] sbin]#./nginxnginx: [Emerg] bind () to 0.0.0.0: Failed (13:permission denied) #权限不够, non-root users can not occupy 80 ports, so the normal user to start as root nginx[[email protected] sbin]$ su root #切换回root用户密码: [[email protected] sbin]# cd/queenlove/soft/nginx/sbin[[email protected] sbin]# chown root nginx[[ Email protected] sbin]# chmod u+s nginx #让普通用户可以以root的方式启动nginx [[email protected] sbin]# su queenlove[[email Protected] sbin]$ Lsnginx[[email protected] sbin]$./nginx
Check if Nginx is turned on, use PS pipe command
[[email protected] sbin]# ps-ef|grep nginxroot 4795 1 0 07:34? 00:00:00 nginx:master process./nginx501 4796 4795 0 07:34? 00:00:00 nginx:worker processroot 4798 4774 0 07:34 pts/0
The above-mentioned Nginx service has been opened, access to the front desk, found that access is not, because the firewall is not open, to do the following:
[[email protected]/]#/sbin/iptables-i input-p TCP--dport 80-j accept[[email protected]/]#/etc/rc.d/init.d/iptables Save[[email protected]/]#/etc/init.d/iptables status
? Restart Nginx
[Email protected]/]#/nginx-s restart
See the following interface instructions to start successfully, Access link http://192.168.136.100:80, the default 80 can be removed. This article IP is my own virtual machine IP, please replace your own IP address
Article blog address:http://www.marsitman.com/nginx/linux_install_nginx.html
So far we have introduced the installation and configuration of the Nginx Linux. If you want to know more about Java knowledge can refer to my personal blog, please poke: www.marsitman.com
Installing and configuring Nginx under Linux