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

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

安裝Nginxphp

一、首先添加nginx_signing.key(必須,不然出錯)

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

$ sudo apt-key add nginx_signing.key

二、添加]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

三、更新源並安裝Nginx

$ sudo apt-get update

$ sudo apt-get install nginx

四、安裝Nginx完成後可查看版本號,輸入

$ /usr/sbin/nginx -v

安裝PHP7 

一、添加PPA

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

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

$ sudo apt-get update

二、安裝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

三、配置PHP7

打開php.ini配置文件:html

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

找到cgi.fix_pathinfo選項,去掉註釋;,而後將值設置爲0:

cgi.fix_pathinfo = 0;python

display_errors  =  Onmysql

 

location ~ \.php$ {nginx

          # include snippets/fastcgi-php.conf;sql

         #ubuntu

          # # With php7.0-cgi alone:vim

        # fastcgi_pass 127.0.0.1:9000;php7

         # # With php7.0-fpm:dom

                 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

 

而後輸入剛剛設置的密碼,能成功進入即成功安裝。

相關文章
相關標籤/搜索