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 结束========================================
原文地址:Centos 安装 nginx + php5.3, 感谢原作者分享。

查版本号的命令:1、“cat /etc/issue”或“cat /etc/redhat-release”,可输出centos版本号;2、“cat /proc/version”、“uname -a”或“uname -r”,可输出内核版本号。

centos重启网卡的方法:1、对于centos6的网卡重启命令是“service network restart”;2、对于centos7的网卡重启命令是“systemctl restart network”。

centos php安装opcache的方法:1、执行“yum list php73* | grep opcache”命令;2、通过“yum install php73-php-opcache.x86_64”安装opcache;3、使用“find / -name opcache.so”查找“opcache.so”的位置并将其移动到php的扩展目录即可。

centos离线安装mysql的方法:1、将lib中的所有依赖上传到linux中,并用yum命令进行安装;2、解压MySQL并把文件复制到想要安装的目录;3、修改my.cnf配置文件;4、复制启动脚本到资源目录并修改启动脚本;5、将mysqld服务加入到系统服务里面;6、将mysql客户端配置到环境变量中,并使配置生效即可。

centos7安装不出现界面的解决办法:1、选择“Install CentOS 7”,按“e”进入启动引导界面;2、 将“inst.stage2=hd:LABEL=CentOS\x207\x20x86_64”改为“linux dd”;3、重新进入“Install CentOS 7”,按“e”将“hd:”后的字符替换成“/dev/sdd4”,然后按“Ctrl+x”执行即可。

centos删除php的方法:1、通过“#rpm -qa|grep php”命令查看全部php软件包;2、通过“rpm -e”命令卸载相应的依赖项;3、重新使用“php -v”命令查看版本信息即可。

我们的PC中有一个磁盘驱动器专门用于所有与Windows操作系统相关的安装。该驱动器通常是C驱动器。如果您还在PC的C盘上安装了最新的Windows11操作系统,那么所有系统更新(很可能是您安装的所有软件)都会将其所有文件存储在C盘中。因此,保持此驱动器没有垃圾文件并在C驱动器中拥有足够的存储空间变得非常重要,因为该驱动器拥有的空间越多,您的Windows11操作系统运行起来就越顺畅。但是您可以在磁盘驱动器上增加多少空间以及可以删除多少文件是有限制的。在这种情况下,

方法:1、利用“vim ~/.bashrc”编辑用户目录(~)下的“.bashrc”文件;2、在文件内添加“alias ls="ls --color"”;3、利用“:wq!”命令保存文件内的更改;4、“exit”命令退出终端后重新连接即可。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

EditPlus 中文破解版
體積小,語法高亮,不支援程式碼提示功能

Dreamweaver Mac版
視覺化網頁開發工具

ZendStudio 13.5.1 Mac
強大的PHP整合開發環境

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),