lnmp建站常识

1.nginx配置网站目录并修改访问的端口:nginx.conf文件

listen 666;//端口默认为80,修改后增强安全性
server_name www.lnmp.org;
index index.html index.htm index.php;
root /home/www;

 2.nginx配置虚拟目录:

(1)修改nginx.conf,加载vhost中的配置项
        include vhost/*.conf; 

(2)如在vhost里写一个配置项:test.conf

 server
        {
                listen       80;
                server_name test.com;
                index index.html index.htm index.php default.html default.htm default.php;
                root  /opt/www/test/www;

                location / {
                        index  index.html index.htm index.php;

                        if (!-e $request_filename) {
                                rewrite ^/(.+)$ /index.php/$1 last;
                        }
                }

                location ~ .*\.(php|php5)?($|/)
                {
                        fastcgi_pass  unix:/tmp/php-cgi.sock;
                        fastcgi_index index.php;

                        fastcgi_param  SCRIPT_FILENAME  /opt/www/test/www/$fastcgi_script_name;
                        fastcgi_split_path_info ^(.+.php)(.*)$;
                        fastcgi_param PATH_INFO $fastcgi_path_info;

                        include fcgi.conf;
                }

 

修改完后重启nginx:

/usr/bin/nginx -s reload

或/etc/init.d/nginx restart

 

Linux 防火墙开放特定端口

iptables是linux下的防火墙,同时也是服务名称。

service  iptables  status         查看防火墙状态
service  iptables  start          开启防火墙
service  iptables  stop           关闭防火墙
service  iptables  restart        重启防火墙

防火墙开放特定端口:

①文件/etc/sysconfig/iptables    

②添加:

     -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

       ★数字8080代表开放8080端口,也可以改成其他的端口

③重启防火墙
 

 

posted @ 2014-04-28 21:16  不负韶华668  阅读(304)  评论(0编辑  收藏  举报