sudo atp-get update
php
sudo apt-get install nginx
一條指令就搞定了安裝html
默認web路徑在/var/www/html
,訪問本地http://loaclhost/
出現Welcome to Nginx!
,便是安裝成功!mysql
安裝mysql,我以前寫過lamp環境配置,內容大同小異,故此處略..
centos7下的lamp開發環境搭建nginx
sudo apt-get install php7.0-fpm php7.0-cgi php7.0-common php7.0-curl php7.0-mysql php7.0-mcrypt php7.0-sqlite3
web
配置
打開php.ini,vim /etc/php/7.0/fpm/php.ini
,設置cgi.fix_pathinfo=0:
sql
/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; } }
經過指令sudo ln -s /etc/nginx/sites-available/test.me /etc/nginx/sites-enabled/test
快捷方式到sites-enabled
目錄segmentfault
修改/etc/hosts
文件,最下面添加一句127.0.0.1 test.app
centos
重啓服務service nginx restart
service php7.0-fpm restart
後,便可訪問http://test.app/
,將顯示/var/www/nginx/test/
目錄下的內容php7
未完待續,若有不足或過錯,歡迎提出,一塊兒學習.