配置源javascript
純淨的Centos 6.5系統php
配置163yum源 (這個比較簡單,百度能解決不少問題)css
開始html
安裝 開發軟件包:yum -y groupinstall "Development Tools"java
安裝 mysql : yum -y install mysql mysql-server mysql-develnode
下載 php-5.6.2 wgethttp://cn2.php.net/distributions/php-5.6.2.tar.gzmysql
解壓 tar -zxvf php-5.6.2.tar.gznginx
cd php-5.6.2 ./configure \ --prefix=/usr/local/php \ --with-config-file-path=/usr/local/php/etc \ --enable-fpm \ --with-fpm-user=php-fpm \ --with-fpm-group=php-fpm \ --with-mysql=mysqlnd \ //這裏mysqlnd 是內部查找命令 --with-mysql-sock=/tmp/mysql.sock \ --with-libxml-dir \ --with-gd \ --with-jpeg-dir \ --with-png-dir \ --with-freetype-dir \ --with-iconv-dir \ --with-zlib-dir \ --with-mcrypt \ --enable-soap \ --enable-gd-native-ttf \ --enable-ftp \ --enable-mbstring \ --enable-exif \ --disable-ipv6 \ --with-pear \ --with-curl \ --with-openssl
出現未安裝的錯誤,直接用yum 進行安裝便可,不要忘了裝上 -devel (libcurl libpng libcrul12等等)sql
make make install
修改配置文件app
cd php-5.6.2 cp php.ini-production /usr/local/php/etc/php.ini cd /usr/local/php/etc cp php-fpm.conf.default php-fpm.conf
保存配置文件後,檢驗配置是否正確的方法爲
/usr/local/php/sbin/php-fpm -t
若是出現諸如 「test is successful」 字樣,說明配置沒有問題
啓動php-fpm
service php-fpm start
若是想讓它開機啓動,執行
chkconfig php-fpm on
檢測是否啓動
ps aux |grep php-fpm netstat -ant |grep 9000
安裝nginx
wget http://nginx.org/download/nginx-1.6.2.tar.gz //最新穩定版哦 tar zxvf nginx-1.6.2.tar.gz cd nginx-1.6.2 ./configure \ --prefix=/usr/local/nginx \ --with-http_realip_module \ --with-http_sub_module \ --with-http_gzip_static_module \ --with-http_stub_status_module \ --with-pcre=/root/pcre-8.35 //不少人沒講這裏,這裏爲pcre的解壓目錄。不過得先安裝pcre
若是出錯了,yum安裝pcre-devel。若是yum安裝不了,就到官網上自行下載源碼包,而後解壓安裝。
make make install
添加一個nginx主程序的符號連接
ln -sf /usr/local/nginx/sbin/nginx /usr/sbin/nginx nginx -t //測試一下吧
nginx配置
把原來的配置文件清空
> /usr/local/nginx/conf/nginx.conf
「>」這個符號爲重定向的意思,單獨用它,能夠把一個文本文檔快速清空。
編輯nginx.conf
vi /usr/local/nginx/conf/nginx.conf
插入如下內容
user nobody nobody; worker_processes 2; error_log /usr/local/nginx/logs/nginx_error.log crit; pid /usr/local/nginx/logs/nginx.pid; worker_rlimit_nofile 51200; events { use epoll; worker_connections 6000; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 3526; server_names_hash_max_size 4096; log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]' '$host "$request_uri" $status' '"$http_referer" "$http_user_agent"'; sendfile on; tcp_nopush on; keepalive_timeout 30; client_header_timeout 3m; client_body_timeout 3m; send_timeout 3m; connection_pool_size 256; client_header_buffer_size 1k; large_client_header_buffers 8 4k; request_pool_size 4k; output_buffers 4 32k; postpone_output 1460; client_max_body_size 10m; client_body_buffer_size 256k; client_body_temp_path /usr/local/nginx/client_body_temp; proxy_temp_path /usr/local/nginx/proxy_temp; fastcgi_temp_path /usr/local/nginx/fastcgi_temp; fastcgi_intercept_errors on; tcp_nodelay on; gzip on; gzip_min_length 1k; gzip_buffers 4 8k; gzip_comp_level 5; gzip_http_version 1.1; gzip_types text/plain application/x-javascript text/css text/htm application/xml; server { listen 80; server_name localhost; index index.html index.htm index.php; root /usr/local/nginx/html; location ~ \.php$ { include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name; }
}
測試是否解析php文件
建立測試文件
vi /usr/local/nginx/html/1.php
插入如下內容
<?php echo "測試php解析"; ?>
測試
curl localhost/1.php