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
未完待续,若有不足或过错,欢迎提出,一块儿学习.