php5.3+for+linux,Centos 安装 nginx + php5.3
Centos 安裝 nginx + php5.3,點開查看詳情。 #查看系統版本信息cat /etc/issue uname -a#設置時區 rm -rf /etc/localtime ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime#使用ntpdate同步時間 yum install -y ntp ntpdate -u pool.ntp.org date#
Centos 安裝 nginx + php5.3,點開查看詳情。
#查看系統版本信息
cat /etc/issue
uname -a
#設置時區
rm -rf /etc/localtime
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
#使用ntpdate同步時間
yum install -y ntp
ntpdate -u pool.ntp.org
date
#搜索刪除相關rpm包
rpm -qa|grep httpd #[搜索指定rpm包是否安裝]--all搜索*httpd*
rpm -e httpd #[刪除一個rpm包]
rpm -qa | grep php
rpm -e php
yum -y remove httpd*
yum -y remove php*
yum -y remove php-mysql
#自動選擇最快的yum源
yum -y install yum-fastestmirror
#關閉SELinux
vi /etc/selinux/config
#將SELINUX=enforcing改為SELINUX=disabled
#yum安裝依賴庫
yum -y install gcc gcc-c++ gcc-g77 flex bison file libtool libtool-libs autoconf kernel-devel libjpeg libjpeg-devel libpng libpng-devel libpng10 libpng10-devel gd gd-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glib2 glib2-devel bzip2 bzip2-devel libevent libevent-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel vim-minimal nano fonts-chinese gettext gettext-devel ncurses-devel gmp-devel pspell-devel unzip libcap diffutils
#下載、安裝依賴庫
wget -c http://soft.vpser.net/web/libiconv/libiconv-1.14.tar.gz
wget -c http://soft.vpser.net/web/libmcrypt/libmcrypt-2.5.8.tar.gz
wget -c http://soft.vpser.net/web/mhash/mhash-0.9.9.9.tar.gz
wget -c http://soft.vpser.net/web/mcrypt/mcrypt-2.6.8.tar.gz
wget -c http://soft.vpser.net/lib/autoconf/autoconf-2.13.tar.gz
#autoconf
tar zxf autoconf-2.13.tar.gz
cd autoconf-2.13/
./configure --prefix=/usr/local/autoconf-2.13
make && make install
cd ../
#libiconv
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14/
./configure
make && make install
cd ../
#libmcrypt
tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8/
./configure
make && make install
/sbin/ldconfig
cd libltdl/
./configure --enable-ltdl-install
make && make install
cd ../../
#mhash
tar zxf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make && make install
cd ../
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ldconfig
#mcrypt
tar zxf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure
make && make install
cd ../
#如果是64位系統 則執行:
ln -s /usr/lib64/libpng.* /usr/lib/
ln -s /usr/lib64/libjpeg.* /usr/lib/
ldconfig
#修改ld.so.conf
cat /etc/ld.so.conf
echo "/lib" >> /etc/ld.so.conf
echo "/usr/lib" >> /etc/ld.so.conf
echo "/usr/lib64" >> /etc/ld.so.conf
echo "/usr/local/lib" >> /etc/ld.so.conf
#更新庫緩存
ldconfig
#高負載linux服務器的內核調優
#修改限制
ulimit -v unlimited
#系統最大打開文件數優化
? ? 默認情況下,系統允許最大打開文件數為1024個,這對于訪問量較大的web服務器來說遠遠不夠用。系統最大打開文件數可以通過ulimit來修改和查詢。
一般情況下,可以通過ulimit -n來查看目前系統允許的最大打開文件數,例如 :
ulimit -n
1024 #系統返回
? ? 永久修改該參數,要修改/etc/security/limits.conf
執行:
cat >>/etc/security/limits.conf<
* soft nproc 65535
* hard nproc 65535
* soft nofile 65535
* hard nofile 65535
eof
##修改 /etc/sysctl.conf。 執行:
echo "fs.file-max=65535" >> /etc/sysctl.conf
##修改完成后運行以下命令使參數生效:
/sbin/sysctl -p
============================安裝PHP5.3.28========================================
#安裝PHP
#設置環境變量
export PHP_AUTOCONF=/usr/local/autoconf-2.13/bin/autoconf
export PHP_AUTOHEADER=/usr/local/autoconf-2.13/bin/autoheader
#下載PHP安裝包
wget -c http://soft.vpser.net/web/php/php-5.3.28.tar.gz
#安裝
tar zxf php-5.3.28.tar.gz
cd php-5.3.28/
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --disable-fileinfo
make ZEND_EXTRA_LIBS='-liconv'
make install
rm -f /usr/bin/php
ln -s /usr/local/php/bin/php /usr/bin/php
ln -s /usr/local/php/bin/phpize /usr/bin/phpize
ln -s /usr/local/php/sbin/php-fpm /usr/bin/php-fpm
ldconfig#復制php配置文件
mkdir -p /usr/local/php/etc
cp php.ini-production /usr/local/php/etc/php.ini
# php extensions
修改php.ini
sed -i 's/post_max_size = 8M/post_max_size = 50M/g' /usr/local/php/etc/php.ini
sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 50M/g' /usr/local/php/etc/php.ini
sed -i 's/;date.timezone =/date.timezone = PRC/g' /usr/local/php/etc/php.ini
sed -i 's/short_open_tag = Off/short_open_tag = On/g' /usr/local/php/etc/php.ini
sed -i 's/; cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /usr/local/php/etc/php.ini
sed -i 's/; cgi.fix_pathinfo=0/cgi.fix_pathinfo=0/g' /usr/local/php/etc/php.ini
sed -i 's/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=0/g' /usr/local/php/etc/php.ini
sed -i 's/max_execution_time = 30/max_execution_time = 300/g' /usr/local/php/etc/php.ini
sed -i 's/register_long_arrays = On/;register_long_arrays = On/g' /usr/local/php/etc/php.ini
sed -i 's/magic_quotes_gpc = On/;magic_quotes_gpc = On/g' /usr/local/php/etc/php.ini
sed -i 's/disable_functions =.*/disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server/g' /usr/local/php/etc/php.ini
#Install ZendGuardLoader for PHP 5.3
64位系統執行:
wget -c?http://soft.vpser.net/web/zend/ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
tar zxf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz
mkdir -p /usr/local/zend/
cp ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /usr/local/zend/
32位系統執行:
wget -c?http://soft.vpser.net/web/zend/ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
tar zxf ZendGuardLoader-php-5.3-linux-glibc23-i386.tar.gz
mkdir -p /usr/local/zend/
cp ZendGuardLoader-php-5.3-linux-glibc23-i386/php-5.3.x/ZendGuardLoader.so /usr/local/zend/
#Write ZendGuardLoader to php.ini……
cat >>/usr/local/php/etc/php.ini<
;eaccelerator
;ionCube
[Zend Optimizer]
zend_extension=/usr/local/zend/ZendGuardLoader.so
zend_loader.enable=1
zend_loader.disable_licensing=0
zend_loader.obfuscation_level_support=3
zend_loader.license_path=
EOF
echo “Creating new php-fpm configure file……”
cat >/usr/local/php/etc/php-fpm.conf<
[global]
pid = /usr/local/php/var/run/php-fpm.pid
error_log = /usr/local/php/var/log/php-fpm.log
log_level = notice
[www]
listen = /tmp/php-cgi.sock
listen.backlog = -1
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = dynamic
pm.max_children = 10
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 6
request_terminate_timeout = 100
request_slowlog_timeout = 0
slowlog = /var/log/slow.log
EOF
#復制php-fpm init.d文件
cp ./php-5.3.28/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod +x /etc/init.d/php-fpm
============================安裝PHP結束========================================
============================安裝Nginx 1.6.0========================================
#安裝Nginx
#建立用戶組和用戶
groupadd www
useradd -s /sbin/nologin -g www www
#下載安裝PCRE庫
wget -c http://soft.vpser.net/web/pcre/pcre-8.12.tar.gz
tar zxf pcre-8.12.tar.gz
cd pcre-8.12/
./configure
make && make install
cd ../
ldconfig
#下載、安裝nginx
wget -c http://soft.vpser.net/web/nginx/nginx-1.6.0.tar.gz
tar zxf nginx-1.6.0.tar.gz
cd nginx-1.6.0/
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-ipv6
make && make install
cd ../
##設置軟連接
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
ldconfig
#創建網站目錄及設置權限
mkdir -p /data0/wwwroot
chmod +w /data0/wwwroot
chown -R www:www /data0/wwwroot
#創建日志目錄及設置權限
mkdir -p /data0/wwwlogs
chmod 777 /data0/wwwlogs
#nginx配置文件
替換 /usr/local/nginx/conf/nginx.conf 的文本為:
user www www;
worker_processes auto;
error_log /data0/wwwlogs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events
{
use epoll;
worker_connections 51200;
multi_accept on;
}
http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
gzip_proxied expired no-cache no-store private auth;
gzip_disable "MSIE [1-6]\.";
#limit_conn_zone $binary_remote_addr zone=perip:10m;
##If enable limit_conn_zone,add "limit_conn perip 10;" to server section.
server_tokens off;
#log format
log_format access '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
include vhost/*.conf;
}
mkdir -p? /usr/local/nginx/conf/vhost
#創建虛擬機
#假如網站域名為 www.xxx.com,則創建網站目錄
mkdir -p /data0/wwwroot/www.xxx.com
chown -R?www:www /data0/wwwroot/www.xxx.com
#,并在 /usr/local/nginx/conf/vhost? 下創建文件 www.xxx.com.conf,文件內容為一下,www.xxx.com替換為實際域名。
server
{
listen 80;
server_name www.xxxx.com;
index index.html index.htm index.php default.html default.htm default.php;
root /data0/wwwroot/www.xxxx.com;
#error_page 404 /404.html;
location ~ [^/]\.php(/|$)
{
# comment try_files $uri =404; to enable pathinfo
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fastcgi.conf;
#include pathinfo.conf;
}
location /nginx_status {
stub_status on;
access_log off;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log /data0/wwwlogs/www.xxxx.com.log access;
}
#運行測試
cat >/data0/wwwroot/www.xxx.com/phpinfo.php<
phpinfo();
?>
eof
#訪問 http://www.xxx.com/phpinfo.php
#設置Nginx開機自啟動
wget -c http://soft.vpser.net/lnmp/ext/init.d.nginx
cp init.d.nginx /etc/init.d/nginx
chmod +x /etc/init.d/nginx
chkconfig –add php-fpm
chkconfig –add nginxchkconfig –level 345 php-fpm on
chkconfig –level 345 nginx onchkconfig –list
/etc/init.d/php-fpm start
/etc/init.d/nginx start
#添加防火墻設置開放端口(看自身情況需要)
vi /etc/sysconfig/iptables
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT
#重啟防火墻
service iptables restart
#保存對防火墻的設置
service iptables save
============================安裝Nginx 結束========================================
總結
以上是生活随笔為你收集整理的php5.3+for+linux,Centos 安装 nginx + php5.3的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java完成登录页面+连接数据库
- 下一篇: oracle可以只装客户端吗,我想在li