阿里雲ECS配置LNMP環境

在阿里雲上搭建LNMP環境

系統:ubuntu14.04 64位php

1)首先登錄ssh root@ 公網IPhtml

2)包更新:sudo apt-get updatemysql

3)安裝nginx:sudo apt-get install nginx安裝以後執行sudo service nginx start在瀏覽器上查看公網IP看到WELCOME TO NGINX就成功了nginx

4)安裝Mysqlsudo apt-get install mysql-server mysql-client,執行mysql -u root -p若是進入到mysql命令行既成功sql

5)安裝phpsudo apt-get install php5-fpm php5-cli php5-mcrypt php5-mysql此處能夠定義本身想要安裝的包,詳情見php官方手冊ubuntu

6)配置php.ini:sudo vim /etc/php5/fpm/php.ini找到cgi.fix_pathinfo選項去掉前面的分號並把值置爲0http://php.net/manual/zh/install.unix.nginx.phpvim

7)重啓php-fpmsudo service php5-fpm restart瀏覽器

8)Nginx默認root文件夾/usr/share/nginx/html服務器

9)Nginx默認配置文件夾位置/etc/nginx/sites-available/ssh

10)建立新的網站的根目錄sudo mkdir -p /var/www

11)配置nginx服務器,sudo vim /etc/nginx/sites-available/default

根目錄root修改root /var/www

index修改(默認支持的後綴名),加上index.php

修改server_name 公網IP

location修改location / { try_files $uri $uri/ /index.php?$query_string; } 配置Nginx:

location ~ \.php$ {
        try_files $uri /index.php =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

重啓nginx:sudo service nginx restart

附錄:推薦zsh代碼補全很是好用sudo apt-get install zsh 安裝後進入命令行直接zsh既能夠切換

相關文章
相關標籤/搜索