搜索
首页php教程php手册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<<eof
* 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<<EOF
;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<<EOF
[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 结束========================================

声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover

AI Clothes Remover

用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool

Undress AI Tool

免费脱衣服图片

Clothoff.io

Clothoff.io

AI脱衣机

AI Hentai Generator

AI Hentai Generator

免费生成ai无尽的。

热门文章

R.E.P.O.能量晶体解释及其做什么(黄色晶体)
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.最佳图形设置
3 周前By尊渡假赌尊渡假赌尊渡假赌
R.E.P.O.如果您听不到任何人,如何修复音频
3 周前By尊渡假赌尊渡假赌尊渡假赌
WWE 2K25:如何解锁Myrise中的所有内容
4 周前By尊渡假赌尊渡假赌尊渡假赌

热工具

MinGW - 适用于 Windows 的极简 GNU

MinGW - 适用于 Windows 的极简 GNU

这个项目正在迁移到osdn.net/projects/mingw的过程中,你可以继续在那里关注我们。MinGW:GNU编译器集合(GCC)的本地Windows移植版本,可自由分发的导入库和用于构建本地Windows应用程序的头文件;包括对MSVC运行时的扩展,以支持C99功能。MinGW的所有软件都可以在64位Windows平台上运行。

DVWA

DVWA

Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

EditPlus 中文破解版

EditPlus 中文破解版

体积小,语法高亮,不支持代码提示功能

SublimeText3 Linux新版

SublimeText3 Linux新版

SublimeText3 Linux最新版

SublimeText3汉化版

SublimeText3汉化版

中文版,非常好用