#设置root密码
sudo passwd root
#创建work用户
su -
adduser work
vim /etc/
所有软件的安装用户:work:work
所有的软件源代码编译安装到/home/work/src下面,
./configure 使用选项--prefix=/home/work/xxx,xxx为源码解压目录
参考:http://www.nginx.cn/install
正式开始前,编译环境gcc g++ 开发库之类的需要提前装好,这里默认你已经装好。
#ububtu平台编译环境可以使用以下指令
apt-get install build-essential
apt-get install libtool
#安装PCRE库
(注意这里我用了pcre2-10.20编译nginx出现了src/core/ngx_regex.h:15:18: fatal error: pcre.h: No such file or directory错误)
cd /home/work
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre2-10.20.tar.gz
tar zxvf pcre2-10.20.tar.gz
cd pcre2-10.20/
./configure --prefix=/home/work/pcre2-10.20
make
make install
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz
tar zxvf pcre-8.37.tar.gz
cd pcre-8.37/
./configure --prefix=/home/work/pcre-8.37
make
make install
#安装zlib库
cd /home/work
wget http://zlib.net/zlib-1.2.8.tar.gz
tar zxvf zlib-1.2.8.tar.gz
cd zlib-1.2.8/
./configure --prefix=/home/work/zlib-1.2.8
make
make install
#安装ssl(某些vps默认没装ssl),使用which openssl查看
cd /home/work
wget http://www.openssl.org/source/openssl-1.0.2c.tar.gz
tar zxvf openssl-1.0.2c.tar.gz
#安装nginx
cd /home/work
wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar zxvf nginx-1.8.0.tar.gz
cd nginx-1.8.0/
./configure
--prefix=/home/work/nginx-1.8.0 \
--with-http_ssl_module \
--with-pcre=/home/work/pcre-8.37 \
--with-zlib=/home/work/zlib-1.2.8 \
--with-openssl=/home/work/openssl-1.0.2c
make
make install
#启动nginx
#检查80端口是否占用
netstat -ano|grep 80
信息如下:
Configuration summary
+ using PCRE library: /home/work/pcre-8.37
+ using OpenSSL library: /home/work/openssl-1.0.2c
+ md5: using OpenSSL library
+ sha1: using OpenSSL library
+ using zlib library: /home/work/zlib-1.2.8
nginx path prefix: "/home/work/nginx-1.8.0"
nginx binary file: "/home/work/nginx-1.8.0/sbin/nginx"
nginx configuration prefix: "/home/work/nginx-1.8.0/conf"
nginx configuration file: "/home/work/nginx-1.8.0/conf/nginx.conf"
nginx pid file: "/home/work/nginx-1.8.0/logs/nginx.pid"
nginx error log file: "/home/work/nginx-1.8.0/logs/error.log"
nginx http access log file: "/home/work/nginx-1.8.0/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
work@nobubuntu:~/nginx-1.8.0$ make install
make -f objs/Makefile install
make[1]: Entering directory '/home/work/nginx-1.8.0'
test -d '/home/work/nginx-1.8.0' || mkdir -p '/home/work/nginx-1.8.0'
test -d '/home/work/nginx-1.8.0/sbin' || mkdir -p '/home/work/nginx-1.8.0/sbin'
test ! -f '/home/work/nginx-1.8.0/sbin/nginx' || mv '/home/work/nginx-1.8.0/sbin/nginx' '/home/work/nginx-1.8.0/sbin/nginx.old'
cp objs/nginx '/home/work/nginx-1.8.0/sbin/nginx'
test -d '/home/work/nginx-1.8.0/conf' || mkdir -p '/home/work/nginx-1.8.0/conf'
cp conf/koi-win '/home/work/nginx-1.8.0/conf'
cp: ?.onf/koi-win?.and ?.home/work/nginx-1.8.0/conf/koi-win?.are the same file
make[1]: *** [install] Error 1
make[1]: Leaving directory '/home/work/nginx-1.8.0'
make: *** [install] Error 2
由于在当源码目录安装出错,所有先将源码复制到/home/work/src/nginx-1.8.0,然后指定--prefix=/home/work/nginx-1.8.0进行
#安装php
#首先安装一些依赖库,ubuntu下,参考http://blog.itphp.org/archives/39
apt-get install libxml2-dev
apt-get install libcurl4-gnutls-dev
apt-get install libjpeg-dev
apt-get install libpng-dev
apt-get install libmcrypt-dev
cd /home/work/src
wget https://downloads.php.net/~ab/php-7.0.0alpha2.tar.gz
tar zxvf php-7.0.0alpha2.tar.gz
cd /home/work/src/php-7.0.0alpha2
./configure --prefix=/home/work/php-7.0.0alpha2 --with-config-file-path=/home/work/php-7.0.0alpha2/etc --enable-fpm --with-mcrypt --enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-zlib --with-zlib-dir=/home/work/zlib-1.2.8 --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysqli --with-gd --with-jpeg-dir
make
make test #好费时间
make install
You may want to add: /home/work/php-7.0.0alpha2/lib/php to your php.ini include_path
/home/work/src/php-7.0.0alpha2/build/shtool install -c ext/phar/phar.phar /home/work/php-7.
ln -s -f phar.phar /home/work/php-7.0.0alpha2/bin/phar
#定位php.ini路径
php -i |grep php.ini
注:这里去掉了--with-bz2,ubuntu下没找到
去掉了--with-mysql,php7已经没有这一项
#启动测试
vim nginx.conf,在默认的配置上修改如下
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
在/home/work/nginx-1.8.0/html下创建index.php文件,输入如下内容
<?php
echo phpinfo();
#重新启动nginx
sudo /usr/local/nginx/sbin/nginx -s reload
php-fpm 启动:
/home/work/php-7.0.0alpha2/sbin/php-fpm
php-fpm 关闭:
kill -INT `cat /home/work/php-7.0.0alpha2/var/run/php-fpm.pid`
php-fpm 重启:
kill -USR2 `cat /home/work/php-7.0.0alpha2/var/run/php-fpm.pid`
# 安装swoole
git clone https://github.com/swoole/swoole-src.git
cd swoole-src
phpize
./configure
make && make install
报错:
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script
解决:
sudo apt-get install m4 autoconf
38 tengine编译参数:
--prefix=/home/work/tengine-2.1.0
--user=work
--group=work
--with-http_stub_status_module
--with-http_ssl_module
--with-http_realip_module
--with-http_sub_module
--with-http_gzip_static_module
--with-http_concat_module
--with-http_flv_module
--with-md5=/usr/lib
--with-sha1=/usr/lib
--with-pcre
--with-pcre=/home/work/source/pcre-8.10
--with-openssl=/home/work/source/openssl-1.0.0r
--with-zlib=/home/work/source/lib/zlib-1.2.8
--with-ld-opt=-Wl,-rpath,/home/work/source/LuaJIT-2.0.3/lib
--add-module=/home/work/source/ngx_devel_kit-0.2.19
--add-module=/home/work/source/lua-nginx-module-0.9.15
php编译参数
'./configure'
'--prefix=/home/work/php-5.3.10'
'--with-config-file-path=/home/work/php-5.3.10/etc'
'--with-iconv-dir=/home/work/lib/libiconv'
'--with-freetype-dir'
'--with-mysql=/home/work/mysql'
'--with-mysqli=/home/work/mysql/bin/mysql_config'
'--with-pdo-mysql=/home/work/mysql'
'--with-openssl'
'--with-jpeg-dir'
'--with-png-dir'
'--with-zlib'
'--with-mhash'
'--enable-sockets'
'--enable-ftp'
'--with-libxml-dir'
'--enable-xml'
'--disable-rpath'
'--enable-safe-mode'
'--enable-bcmath'
'--enable-shmop'
'--enable-sysvsem'
'--enable-inline-optimization'
'--with-curl'
'--with-curlwrappers'
'--enable-mbregex'
'--enable-mbstring'
'--with-mcrypt=/home/work/lib/libmcrypt'
'--with-gd'
'--enable-gd-native-ttf'
'--with-openssl'
'--enable-pcntl'
'--enable-sockets'
'--enable-fpm'
'--with-xmlrpc'
'--enable-zip'
'--enable-soap'
'--enable-debug'
'--without-pear'
ubuntu14.04安装scrapy,这里使用pip安装
首先确认import lxml, import OpenSSL
如果lxml没安装,操作:
apt-get install libxml2-dev libxslt-dev python-dev
sudo pip install lxml
sudo pip install Scrapy