Ubuntu安装Nginx+PHP7.0.4+MySQL5.6

Ubuntu安装Nginx+PHP7.0.4+MySQL5.6

安装Nginx

1、首先添加nginx_signing.key(必须,否则出错)

$ wget http://nginx.org/keys/nginx_signing.key

$ sudo apt-key add nginx_signing.key

2、添加]Nginx](http://nginx.org/)官方提供的源

$ echo "deb http://nginx.org/packages/ubuntu/ trusty nginx" >> /etc/apt/sources.list

$ echo "deb-src http://nginx.org/packages/ubuntu/ trusty nginx" >> /etc/apt/sources.list

3、更新源并安装Nginx

$ sudo apt-get update$ sudo apt-get install nginx

4、安装Nginx完成后可查看版本号,输入

$ /usr/sbin/nginx -v

安装PHP7

1、添加PPA

$ sudo apt-get install python-software-properties software-properties-common

$ sudo add-apt-repository ppa:ondrej/php

$ sudo apt-get update

2、安装PHP7以及所需的一些扩展

$ sudo apt-get install php7.0-fpm php7.0-mysql php7.0-common php7.0-curl php7.0-cli php7.0-mcrypt php7.0-mbstring php7.0-dom

3、配置PHP7

打开php.ini配置文件:

$ sudo vim /etc/php/7.0/fpm/php.ini

找到cgi.fix_pathinfo选项,去掉注释;,然后将值设置为0:

cgi.fix_pathinfo = 0;

display_errors  =  On


location ~ \.php$ {

          # include snippets/fastcgi-php.conf;

         #

          # # With php7.0-cgi alone:

        # fastcgi_pass 127.0.0.1:9000;

         # # With php7.0-fpm:

                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

                  fastcgi_pass unix:/run/php/php7.0-fpm.sock;

                  fastcgi_index index.php;

                  include fastcgi_params;

}


安装MySQL

安装mysql

$ sudo apt-get install mysql-server-5.6 mysql-client-5.6

途中会提示设置MySQL的密码,安装好后:

$ mysql -uroot -p


然后输入刚刚设置的密码,能成功进入即成功安装。

你可能感兴趣的:(Ubuntu安装Nginx+PHP7.0.4+MySQL5.6)