Installing Nginx
Yum Install Nginx
If the Nginx package cannot be found, create a new file/etc/yum.repos.d/nginx.repo, Content:
[Nginx]name=nginx repobaseurl=http://nginx.org/packages/os/osrelease/$basearch/gpgcheck=0enabled=1
Where: OS replaced with CentOS orRhel, according to the release version you installed osrelease replaced with 5, 6 or 7, respectively, corresponding to 5.6.x,7.xsuch as:
[Nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/6/$basearch/gpgcheck=0enabled=1~
Delete the previous httpd
Yum Remove httpd
Installation
Yum Install Ngnix
Judging conf
/usr/sbin/nginx-t
Start: Service Nginx restart
Added self-priming chkconfig--levels 235 nginx on
Install PHP
Yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcryp T php-mssql php-snmp Php-soap Php-tidy
Vi/etc/php.ini
Add Cgi.fix_pathinfo = 1 at the end of the file
Start PHP-FPM:
Service PHP-FPM Start
PHP-FPM Join the Startup entry:
Chkconfig--levels 235 PHP-FPM on
Install tomcat download unzip to/usr/local/tomcat port to 8090 boot
Installing Mysql:yum install MySQL Mysql-server
Change Password:
Grant all on * * to ' root ' @ ' localhost ' identified by ' your password ' with GRANT option; Flush privileges
Configure Nginx: Enter/etc/nginx Create a new file: proxy.conf:
Proxy_redirect off;proxy_set_header Host $host;p roxy_set_header x-real-ip $remote _addr; #proxy_set_ Header x-forwarded-for $proxy _add_x_forwarded_for;client_max_body_size 10m;client_body_buffer_size 128k;proxy_connect_timeout 90;proxy_send_timeout 90;proxy_read_timeout 90;proxy_buffer_size 4k ;p roxy_buffers 4 32k;proxy_busy_buffers_size 64k;proxy_temp_file_write_size 64k;
Enter:/ETC/NGINX/CONF.D new tomcat.conf
server {listen 8080; server_name localhost; #charset Koi8-r; #access_log/var/log/nginx/log/host.access.log Main; Location/{#root/usr/share/nginx/html; Index index.html Index.htm;proxy_pass http://127.0.0.1:8090/; } #error_page 404/404.html; # REDIRECT Server error pages to the static page/50x.html # Error_page 502 503 504/50x.html; Location =/50x.html {root/usr/share/nginx/html; } # Proxy The PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ {# Proxy_pass/http/ 127.0.0.1; #} # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ {# root html # Fastcgi_pass 127.0.0.1:9000; # Fastcgi_index index.php; # Fastcgi_param Script_filename/scripts$fastcgi_script_name; # include Fastcgi_params; #} # Deny access to. htaccess files, if Apache ' s document Root # concurs with Nginx ' s one # #location ~/\.ht {# deny all; #}}
Nginx Configuration Complete
Configure default.conf (You can also create a new one):
server {Listen 80; server_name localhost; #charset Koi8-r; #access_log/var/log/nginx/log/host.access.log Main; Location/{#root/usr/share/nginx/html; root/var/www/html; Index index.html index.htm; } #error_page 404/404.html; # REDIRECT Server error pages to the static page/50x.html # Error_page 502 503 504/50x.html; Location =/50x.html {root/usr/share/nginx/html; } # Proxy The PHP scripts to Apache listening on 127.0.0.1:80 # #location ~ \.php$ {# Proxy_pass/http/ 127.0.0.1; #} # Pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ {# root html # Fastcgi_pass 127.0.0.1:9000; # Fastcgi_index index.php; # Fastcgi_param Script_filename/scripts$fastcgi_script_name; # include Fastcgi_params; #} # Deny access to. htaccess files, if Apache ' s document Root # concurs with Nginx ' s one # #location ~/\.ht {# deny all; #}}
Restart canYou can also smooth restart:/usr/sbin/nginx-t-c/etc/nginx/nginx.conf
Note:
CHKCONFIG  usage Example:
chkconfig--list # List all system services
Chkconfig--add httpd #增加httpd服务
Chkconfig--del httpd #删除httpd服务
chkconfig--level httpd 2345 on #设置httpd在运行级别为2, 3, 4, 5 are on (open) status
Chkconfig--list #列出系统所有的服务启动情况
Chkconfig--list mysqld #列出mysqld服务设置情况
Chkconfig--level mysqld on #设定mysqld在等级3和5为开机运行服务,--level 35 indicates that the operation is performed only at levels 3 and 5, on indicates start, and off indicates that the
Chkconfig mysqld on #设定mysqld在各等级为on is turned off. "Levels" include 2, 3, 4, 5 levels
How to add a service:
1. The service script must be stored in the/etc/ini.d/directory;
2.chkconfig--add ServiceName
Add this service to the list of Chkconfig tool services, at which point the service is given the k/s entry in/ETC/RC.D/RCN.D;
3.chkconfig--level mysqld on
Modifies the default startup level of the service.
CentOS under Installation configuration Ngnix_tomcat_php_mysql