# 基本编译环境 yum -y install gcc automake autoconf libtool make gcc-c++ glibc # PHP依赖 yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg \ libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 \ libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel \ bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs \ e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel # 安装pcre: cd /usr/local/src wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-xx.xx.tar.gz tar -zxvf pcre-xx.xx.tar.gz cd pcre-xx.xx ./configure make make install # 安装zlib: cd /usr/local/src wget http://zlib.net/zlib-x.x.x.tar.gz tar -zxvf zlib-x.x.x.tar.gz cd zlib-x.x.x ./configure make make install # 安装ssl: cd /usr/local/src wget http://www.openssl.org/source/openssl-x.x.x.tar.gz tar -zxvf openssl-x.x.x.tar.gz
安装PHP
安装
这里可能遇到各种缺少依赖的错误,遇到什么就安装什么就行,可以参考文章“20+ common PHP compilation errors and fix”。这里的配置项比较多,也很难对每一项都非常了解,所以其实可以设置少一些选项,然后等真的需要的时候再重新编译。这其实非常容易,重新安装一遍后重启php-fpm就可以了
cd /usr/local/src wget http://nginx.org/download/nginx-x.x.x.tar.gz tar -zxvf nginx-x.x.x.tar.gz cd nginx-x.x.x ./configure --sbin-path=/usr/local/nginx/nginx \ --conf-path=/usr/local/nginx/nginx.conf \ --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module \ --with-pcre=/usr/local/src/pcre-xx.xx --with-zlib=/usr/local/src/zlib-x.x.x \ --with-openssl=/usr/local/src/openssl-x.x.x make make install
user www-data; worker_processes 1; pid logs/nginx.pid;
events { worker_connections 1024; }
http { include mime.types; default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" "$request_time"'; #[important] need to specify the index index index.php index.html index.htm;
#若有多个server,建议分为多个文件,每个包含一个server模块,用include包含 server { listen 80; server_name example.com;
#access_log logs/host.access.log main;
#[important] need to make sure each subpath in the root have +x permission root /home/work/laravel/public;
#[important] need to do the rewrite here location / { try_files $uri $uri/ /index.php?$query_string; }
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { }
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #[important] need to have the * below location ~* \.php$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
# deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } } }