ubuntu 16.04 下配置lnmp環境

系統升級

  1. sudo atp-get updatephp

安裝nginx

  1. sudo apt-get install nginx一條指令就搞定了安裝html

  2. 默認web路徑在/var/www/html,訪問本地http://loaclhost/出現Welcome to Nginx!,便是安裝成功!mysql

安裝mysql

安裝mysql,我以前寫過lamp環境配置,內容大同小異,故此處略..
centos7下的lamp開發環境搭建nginx

安裝php7.0

  1. sudo apt-get install php7.0-fpm php7.0-cgi php7.0-common php7.0-curl php7.0-mysql php7.0-mcrypt php7.0-sqlite3web

  2. 配置
    打開php.ini,vim /etc/php/7.0/fpm/php.ini,設置cgi.fix_pathinfo=0:sql

nginx虛擬主機配置

  1. /etc/nginx/sites-available目錄下,新建test.app文件,寫下以下內容vim

    server {
            listen 80;
            listen [::]:80;
    
            server_name test.app;
    
            root /var/www/nginx/test;
            index index.html index.php;
    
            location / {
                    try_files $uri $uri/ =404;
            }
    
            location ~ \.php$ {
                    include snippets/fastcgi-php.conf;
    
                    # With php7.0-cgi alone:
                    # fastcgi_pass 127.0.0.1:9000;
                    # With php7.0-fpm:
                    fastcgi_pass unix:/run/php/php7.0-fpm.sock;
            }
    }
  2. 經過指令sudo ln -s /etc/nginx/sites-available/test.me /etc/nginx/sites-enabled/test快捷方式到sites-enabled目錄segmentfault

  3. 修改/etc/hosts文件,最下面添加一句127.0.0.1 test.appcentos

  4. 重啓服務
    service nginx restart service php7.0-fpm restart後,便可訪問http://test.app/,將顯示/var/www/nginx/test/目錄下的內容php7


未完待續,若有不足或過錯,歡迎提出,一塊兒學習.

相關文章
相關標籤/搜索