1.安装nginx
<code>aptitude <span>install</span> nginx</code>
2.配置nginx
<code>1.查看nginx状态,启动,重载等命令 </code>
<code> service nginx status
service nginx <span><span>start</span>
service nginx reload</span></code><code>2.添加虚拟主机 在/etc/nginx/conf.d中建立相关的文件夹,将配置文件放到该文件夹下。 配置文件例:vhosts_sample.conf </code>
<code> server {
<span>listen</span><span>8080</span>; <span>#端口</span>
root /usr/share/nginx/wlj; <span>#网页文件存放路径</span><span>index</span><span>index</span>.html <span>index</span>.htm;
<span># Make site accessible from http://localhost/</span>
server_name wljcloud.com; <span>#域名</span> location / {
<span># First attempt to serve request as file, then</span><span># as directory, then fall back to displaying a 404.</span>
try_files <span>$uri</span><span>$uri</span>/ =<span>404</span>;
<span># Uncomment to enable naxsi on this location</span><span># include /etc/nginx/naxsi.rules</span>
}
}</code><code>3.修改nginx.conf文件,在http段下添加刚才的路径,例 include /etc/nginx/conf.d/vhosts_conf/*.conf; 4.将网页文件放到刚配置的路径中 </code>
<code><span>cp</span> -r 文件源路径 /usr/share/nginx/wlj</code>
<code>5.重新加载nginx的配置文件 </code>
<code> service nginx reload</code>
3.访问站点
<code>例:101.201.196.130:8080/index.html </code>
以上就介绍了linux配置webserver简易步骤,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号