Ubuntu下编译安装Nginx,php和MySQL

一、安装配置Nginx

1.1、安装依赖项

sudo apt-get update
sudo apt-get install build-essential zliblg-dev libpcre3 libpcre3-dev libssl-dev libxslt1-dev libxml2-dev libgd2-xpm-dev libgeoip-dev libgoogle-perftools-dev libperl-dev libtool
sudo apt-get install openssl

1.2、下载并安装

wget http://nginx.org/download/nginx-1.13.5.tar.gz
tar -zxvf nginx-1.13.5.tar.gz
cd nginx-1.13.5.tar.gz
sudo ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-stream --with-mail=dynamic
sudo make
sudo make install
ps -ef | grep nginx

1.3 nginx.conf中配置php

location / {

 root  html;

 index index.html index.htm index.php;

 fastcgi_pass  [127.0.0.1](127.0.0.1):9000;

 fastcgi_index index.php;

 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

 include fastcgi_params;

 }

二、安装配置php

2.1、下载安装

sudo apt install php7.0 php7.0-fpm php7.0-dev libpcre32-3
sudo apt install php7.0-mysql

2.2、php配置

sudo gedit /etc/php/7.0/fpm/pool.d/www.conf
//update the listen
listen: 9000
pkill php-pfm
whereis php-fpm
/usr/sbin/php-fpm7.0
Ubuntu下编译安装Nginx,php和MySQL_第1张图片
image.png

三、安装配置MySQL

3.1、下载安装

sudo apt-get install mysql-server

3.2、测试是否成功

// remember update the password and create database
query('SET NAMES utf8');
    } catch(Exception $e) {
        die('error'.$e->getMessage());
    }

四、常见错误

4.1、安装php-mysql的时候出现无法启动php-fpm

pkill php-fpm
sudo apt-get install php-mysql

wu.apache + php

apt-get install libapache2-mod-php
yum install php php-fpm php-bcmatch php-gd php-mbstring php-mcrypt php-mysql

主要步骤:
1,安装apache
sudo apt-get install apache2
sudo /etc/init.d/apache2 restart
2,安装php
sudo apt-get install libapache2-mod-php5 php5 php5-gd php5-mysql
sudo /etc/init.d/apache2 restart
3,安装mysql数据库
sudo apt-get install mysql-server mysql-client
/etc/init.d/mysql start
4,安装phpmyadmin-Mysql数据库管理
apt-get install phpmyadmin

你可能感兴趣的:(Ubuntu下编译安装Nginx,php和MySQL)