ubuntu 安装nginx和php

ubuntu14.04.3

nginx下载地址:http://nginx.org/download/nginx-1.6.0.tar.gz

php下载地址:http://php.net/get/php-5.6.15.tar.gz/from/a/mirror


安装所有软件需要的包:

sudo apt-get install build-essential
sudo apt-get install libtool

安装nginx需要的包:

sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install openssl libssl-dev libperl-dev

安装php需要的包:

sudo apt-get install libxml2-dev
apt-get install libmcrypt-dev libpng-devel
apt-get -y install libjpeg-dev 

sudo apt-get install libcurl4-gnutls-dev
sudo apt-get install libxml2-dev


第一步安装nginx

wget http://nginx.org/download/nginx-1.6.0.tar.gz

tar xvf nginx-1.6.0.tar.gz

cd nginx-1.6.0

./configure --prefix=/usr/local/nginx

make 

make install

开启nginx:/usr/local/nginx/sbin/nginx 

重启nginx:/usr/local/nginx/sbin/nginx  -s reload


第二步安装php

注:为了让php支持imagecreatefromjpeg()函数,参考http://www.nginx.cn/tag/gd,gd2.1下载地址:https://github.com/libgd/libgd/releases/download/gd-2.1.1/libgd-2.1.1.tar.gz

wget php压缩包

cd php5.6

./configure --prefix=/usr/local/php5.6 --enable-fpm --with-curl --with-mysql --enable-mysqlnd --with-pdo-mysql --enable-mbstring --enable-tokenizer --with-zlib --with-pcre-dir --with-mcrypt=/usr/local/mcrypt --enable-sockets   --enable-inline-optimization  --enable-sysvsem --enable-sysvshm --enable-pcntl --with-pcre-regex  --with-jpeg-dir --with-gd --with-jpeg-dir=/usr --with-png-dir=/usr --with-mysqli=mysqlnd --enable-sockets --enable-sockets --with-zlib --with-iconv --enable-zip

make 

make install

安装gd库

# apt-get install php5-gd

php安装好后,还不能解析php的文件,此时需要2步:

1.新增php-fpm.conf文件,复制/opt/local/php5.6/conf/php-fpm.conf.default 改名为php-fpm.conf

2.php-fpm.conf文件查看组和用户名

开启php-fpm:/opt/local/php5.6/sbin/php-fpm


(完)


你可能感兴趣的:(linux)