ECS Ubuntu配置nginx运行TP

1.删除Apache

sudo service apache2 stop
update-rc.d -f apache2 remove
sudo apt-get remove apache2

删除完之后,更新一下包列表
sudo apt-get update

2.Nginx

  • 安装

sudo apt-get install Nginx
  • 使用

sudo service Nginx start //启动
sudo service Nginx restart //重启
sudo service Nginx status //查看状态

在浏览器地址栏输入公网IP,你就可以看的welcome to Nginx的界面了

3.PHP

  • 安装

sudo apt-get install PHP5-fpm PHP5-cli PHP5-mcrypt
  • 配置

sudo vim /etc/PHP5/fpm/PHP.ini
//打开PHP配置文件,找到cgi.fix_pathinfo选项,去掉它前面的注释分号;,然后将它的值设置为0,如下

cgi.fix_pathinfo=0
5.启用PHP5-mcrypt:
sudo PHP5enmod mcrypt
6.重启PHP5-fpm:
sudo service PHP5-fpm restart
在搭建完LEMP环境之后,首先要明确两个重要目录

Nginx认root文件

/usr/share/Nginx/html
Nginx的服务器配置文件所在目录

/etc/Nginx/sites-available/

server {

    listen 80 default_server;
  listen [::]:80 default_server ipv6only=on;

root /var/www/jiajiao-web-test/;
index index.PHP index.html index.htm;

Make site accessible from http://localhost/

server_name jiajiaodaojia.cn;

location / {

      root /var/www/jiajiao-web-test/;
      # F<a href="https://www.jb51.cc/tag/irs/" target="_blank" class="keywords">irs</a>t attempt to serve request as file,then
      # as directory,then fall back to index.html
      try_files $uri $uri/ /index.html;
      # Uncomment to enable naxsi on this location
      # include /etc/<a href="https://www.jb51.cc/tag/Nginx/" target="_blank" class="keywords">Nginx</a>/naxsi.rules
      if (!-e $request_filename)
      {
              rewrite ^/<a href="https://www.jb51.cc/tag/PHP/" target="_blank" class="keywords">PHP</a>Parser/(.*)$ /<a href="https://www.jb51.cc/tag/PHP/" target="_blank" class="keywords">PHP</a>Parser/index.<a href="https://www.jb51.cc/tag/PHP/" target="_blank" class="keywords">PHP</a>?s=$1 last;
              break;
      }
      # F<a href="https://www.jb51.cc/tag/irs/" target="_blank" class="keywords">irs</a>t attempt to serve request as file,then fall back to <a href="https://www.jb51.cc/tag/dis/" target="_blank" class="keywords">dis</a>playing a 404.

# NOTE: You should have "cgi.fix_pathinfo = 0;" in PHP.ini

# With PHP5-cgi alone:

      #fastcgi_pass 127.0.0.1:9000;

# With PHP5-fpm:

      # Uncomment to enable naxsi on this location
      # include /etc/<a href="https://www.jb51.cc/tag/Nginx/" target="_blank" class="keywords">Nginx</a>/naxsi.rules

}

location ~ \.PHP$ {

            root /var/www/jiajiao-web-test/;
          try_files $uri = 404;
          fastcgi_split_path_info ^(.+\.PHP)(/.+)$;
  #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in PHP.ini
  #
  #       # With PHP5-cgi alone:
          #fastcgi_pass 127.0.0.1:9000;
          fastcgi_split_path_info ^(.+\.PHP)(.*)$;
          fastcgi_param PATH_INFO $fastcgi_path_info;
  #       # With PHP5-fpm:

相关文章

显卡天梯图2024最新版,显卡是电脑进行图形处理的重要设备,...
初始化电脑时出现问题怎么办,可以使用win系统的安装介质,连...
todesk远程开机怎么设置,两台电脑要在同一局域网内,然后需...
油猴谷歌插件怎么安装,可以通过谷歌应用商店进行安装,需要...
虚拟内存这个名词想必很多人都听说过,我们在使用电脑的时候...