一: # setenforce 0 # systemctl stop firewalld //尽量使用国内源 # yum install -y epel-release # cd /etc/yum.repos.d/ # yum install -y nginx # killall httpd //有Apache服务先关 # systemctl restart nginx # ps aux | grep nginx 或 二:nginx源下载 # cd /etc/yum.repos.d/ # rpm -Uvh http:///packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm # vim nginx.repo # yum -y install nginx # systemctl restart nginx
Nginx配置支持PHP
# vim /etc/nginx/conf.d/admin.conf server { listen 80; server_name www.test.com admin.test.com; index index.html inex.htm index.php; root /var/www/card/public; location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=/$1 last; break; } } location ~ \.php$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } # yum install -y php-fpm # vim /etc/php-fpm.d/www.conf user = nginx group = nginx # cd /var/www # mkdir -p card/public # cd card/public # vim php_info.php <?php echo "php解析正常" ?> # systemctl restart php-fpm # lsof -i:9000 # systemctl restart nginx # setenforce 0 # systemctl stop firewalld //192.168.1.2/php_info.php
Nginx配置反向代理192.168.1.3 web端 192.168.1.2 代理服务器(www.test.com) # cd /etc/nginx/conf.d/ # mv admin.conf admin.conf.bak # rm -rf default.conf.rpmsave # vim default.conf upstream test{ server 192.168.1.3 weight=1 #权重越高访问次数越多 } server { listen 80; server_name www.test.com; access_log /var/log/nginx/host.access.log main; location / { proxy_pass http://test; #这里可直接写IP地址进行配置,如果需要配置负载均衡,可以使用http://test和upstream名称一致 } } # systemctl restart nginx # //web端 # systemctl stop firewalld # setenforce 0
|
|