ubuntu16默认装置的LNMP(nginx:1.10 php:7.0 mysql:5.7)
1.更新ubuntu软件源:
apt-get update
2.装置nginx:
apt-get install nginx拜访ip能够看到Welcome Nginx的界面,阐明nginx装置胜利
3.装置mysql:
apt-get install mysql-server mysql-client
4.装置php:
apt-get install php php-gd php-xml php-mbstring php-curl php-mysql php-mongodb
5.nginx简略配置:
vim /etc/php/7.0/fpm/pool.d/www.conf #批改php-fpm配置文件listen = /run/php/php7.0-fpm.sock#listen = 127.0.0.1:9000php-fpm7.0 -t #查看下配置文件是否有谬误service php7.0-fpm restart #重启 php-fpm7.0 vim /etc/nginx/sites-enabled/default #批改nginx配置文件root /var/www;# Add index.php to the list if you are using PHPindex index.php index.html index.htm index.nginx-debian.html;location ~ \.php$ { #socket 形式 必须和php-fpm设置的listen门路一样 # With php7.0-fpm: fastcgi_pass unix:/run/php/php7.0-fpm.sock; # With php7.0-cgi alone: #fastcgi_pass 127.0.0.1:9000;}nginx -t #查看下配置文件是否有谬误service nginx restart #重启nginx
6.网站测试:
mkdir /var/www/testecho '<?php phpinfo();' > /var/www/test/index.phpchown -R www-data:www-data /var/www/test && chmod -R 755 /var/www/testcd /etc/nginx/conf.dvim test.conf写入以下内容:server { listen 80 default_server; listen [::]:80 default_server; root /var/www/test; index index.php index.html index.htm; server_name _; #禁止执行PHP的目录。 location ~ .*(Images|images|Img|img|Template|template|Upload|upload|Public|public)/.*\.php$ { deny all; } #设置图片缓存为30天,临时正文掉 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; } #设置js和css缓存为12小时,临时正文掉 location ~ .*\.(js|css)?$ { expires 12h; } location / { try_files $uri $uri/ =404; } location ~ \.php$ { fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; include fastcgi_params; }}service nginx restart浏览器拜访http:ip地址/index.php看到上图页面则示意曾经网站搭建胜利之后你能够到万网,阿里云或腾讯云等买个域名,批改下nginx配置,即可用域名拜访
7.扩大装置(mongodb,php扩大后面4步骤曾经装置):
apt-get install mongodb