plurk 2010-6-23 12:55
安裝最新 CentOS 5.5 + Nginx + php-fpm + MySQL
<p>PHP 5.3.1<br>MySQL 5.0.89<br>Nginx 0.8.33</p>
<p>CentOS 5.5</p>
<p> </p>
<p>現在,我們可以快速全自動搞定 <strong><font color="#00ccff">CentOS + Nginx + PHP-FPM + MySQL</font></strong> 的安裝了</p>
<p>這個可比網上流傳的什麼一鍵安裝包要好得多,強烈推薦此法安裝,適合所有菜鳥和高手</p>
<p>我服務器上全用的源代碼編譯安裝,也好不到哪去,還很費勁 ...
<script src="http://www.gstatic.com/ig/modules/dictionary/azMIoKQxpRI.cache.js"></script>
<script>gadgets.util.runOnLoadHandlers();</script>
</p>
<p> </p>
<p>這個裝完已經包含php 的一些常用擴展, PDO,eaccelerator,memcache,tidy等等</p>
<p>本文為 <font color="#00cc99">21andy </font>原创,轉載請以超鏈結方式注明出處 <a href="http://www.21andy.com/blog/20100219/1701.html" target="_blank">http://www.21andy.com</a></p>
<p> </p>
<p>先新建一個 repo</p>
<p>[quote]</p>
<div class="hl-main"># vi /etc/yum.repos.d/centos.21andy.com.repo</div>
<p>[/quote]</p>
<p> </p>
<p>放入如下内容</p>
<p>[quote]</p>
<div class="hl-main">[21Andy.com]<br>name=21Andy.com Packages for Enterprise Linux 5 - $basearch<br>baseurl=http://www.21andy.com/centos/5/$basearch/<br>enabled=1<br>gpgcheck=0<br>protect=1</div>
<p>[/quote]</p>
<p> </p>
<p>啟用 EPEL repo<br>i386 </p>[attach]4958[/attach]<br><p> </p>
<p>x86_64</p>
<p>[quote]</p>
<div class="hl-main"><div class="hl-main">rpm -ihv http://free.nchc.org.tw/fedora-epel/5/x86_64/epel-release-5-4.noarch.rpm</div><a href="http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm" target="_blank"></a></div>
<p>[/quote]</p>
<p> </p>
<p>接著導入key</p>
<p>[quote]</p>
<div class="hl-main">rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL</div>
<p>[/quote]</p>
<p> </p>
<p>好了,一鍵安裝</p>
<p>[quote]</p>
<div class="hl-main"># yum install nginx php-fpm mysql-server</div>
<p>[/quote]</p>
<p> </p>
<p>爽吧!</p>
<p>如果 nginx 你要用 0.7.65 最新穩定版,把<br>yum -y install nginx<br>換成<br>yum -y install nginx-stable<br>就可以了</p>
<p> </p>
<p><font color="sienna">更完整的安裝,只要一句</font></p>
<p>[quote]</p>
<div class="hl-main">yum -y install nginx mysql-server php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator</div>
<p>[/quote]</p>
<p> </p>
<p>安裝結果,全自動</p>
<p>[quote]</p>
<blockquote>
<p>Dependencies Resolved</p>
<p>==========================================================<br>Package Arch Version Repository Size<br>==========================================================<br>Installing:<br>mysql x86_64 5.0.89-1.el5 21Andy.com 3.5 M<br>mysql-server x86_64 5.0.89-1.el5 21Andy.com 10 M<br>nginx x86_64 0.8.33-3.el5 21Andy.com 422 k<br>php-cli x86_64 5.3.1-2.el5 21Andy.com 2.4 M<br>php-eaccelerator x86_64 2:0.9.6-1.el5 21Andy.com 118 k<br>php-fpm x86_64 5.3.1-2.el5 21Andy.com 1.2 M<br>php-gd x86_64 5.3.1-2.el5 21Andy.com 110 k<br>php-mbstring x86_64 5.3.1-2.el5 21Andy.com 1.1 M<br>php-mcrypt x86_64 5.3.1-2.el5 21Andy.com 27 k<br>php-mysql x86_64 5.3.1-2.el5 21Andy.com 84 k<br>php-pdo x86_64 5.3.1-2.el5 21Andy.com 91 k<br>php-pear noarch 1:1.9.0-1.el5 21Andy.com 420 k<br>php-pecl-memcache x86_64 2.2.5-3.el5 21Andy.com 44 k<br>php-tidy x86_64 5.3.1-2.el5 21Andy.com 31 k<br>php-xml x86_64 5.3.1-2.el5 21Andy.com 115 k<br>php-xmlrpc x86_64 5.3.1-2.el5 21Andy.com 48 k<br>Installing for dependencies:<br>gmp x86_64 4.1.4-10.el5 base 201 k<br>libXaw x86_64 1.0.2-8.1 base 329 k<br>libXmu x86_64 1.0.2-5 base 63 k<br>libXpm x86_64 3.5.5-3 base 44 k<br>libedit x86_64 2.11-2.20080712cvs.el5 epel 80 k<br>libmcrypt x86_64 2.5.8-4.el5.centos extras 105 k<br>libtidy x86_64 0.99.0-14.20070615.el5 epel 140 k<br>php-common x86_64 5.3.1-2.el5 21Andy.com 554 k<br>sqlite2 x86_64 2.8.17-5.el5 21Andy.com 165 k<br>t1lib x86_64 5.1.1-7.el5 epel 208 k<br>Updating for dependencies:<br>libevent x86_64 1.4.12-1.el5 21Andy.com 129 k</p>
<p>Transaction Summary<br>==========================================================<br>Install 26 Package(s)<br>Update 1 Package(s)<br>Remove 0 Package(s) </p></blockquote>
<p>[/quote]</p>
<p> </p>
<p> </p>
<p>最後只要 yum -y update 一下,全是最新的<br>別忘了開機啟動</p>
<p>[quote]</p>
<div class="hl-main">chkconfig --level 345 mysqld on<br>chkconfig --level 345 php-fpm on<br>chkconfig --level 345 nginx on</div>
<p>[/quote]</p>
<p> </p>
<p><strong><font color="#00ccff">補充:所有的配置文件都在 /etc 目錄下,包括 nginx, php-fpm, mysql 的配置文件,請自行查找設置,以下為我的 nginx 的配置範例</font></strong></p>
<p><strong><font color="#00ccff"></font></strong> </p><font color="black">
<p>網站目錄 /var/www/html<br></p>
<p><font color="#00ccff"># vi /etc/nginx/nginx.conf</font></p></font>
<p><font color="black">[quote]</font></p>
<p>user nobody nobody;<br>worker_processes 10; 啟動進程,若是是256MB的VPS最好設定在4-8之間。<br>worker_rlimit_nofile 100000; 開啟文件數</p>
<p>error_log /var/log/nginx/error.log; 錯誤信息日誌路徑<br>#error_log /var/log/nginx/error.log notice;<br>#error_log /var/log/nginx/error.log info;</p>
<p>pid /var/run/nginx.pid;</p>
<p><br>events {<br> worker_connections 51200; 規定進程的最大連接數<br> use epoll; 利用I/O複用模式<br>}</p>
<p><br>http {<br> include /etc/nginx/mime.types; 定義文件類型<br> default_type application/octet-stream;</p>
<p> </p>
<p> log_format main '$remote_addr - $remote_user [$time_local] "$request" '<br> '$status $body_bytes_sent "$http_referer" '<br> '"$http_user_agent" "$http_x_forwarded_for"';</p>
<p> </p>
<p> access_log /var/log/nginx/access.log main; 設定訪問日誌</p>
<p> server_names_hash_bucket_size 128;<br> client_header_buffer_size 16k;<br> large_client_header_buffers 4 16k;<br> client_max_body_size 8m;</p>
<p> fastcgi_connect_timeout 180;<br> fastcgi_send_timeout 180;<br> fastcgi_read_timeout 180;<br> fastcgi_buffer_size 64k;<br> fastcgi_buffers 8 128k;<br> fastcgi_busy_buffers_size 128k;<br> fastcgi_temp_file_write_size 128k;</p>
<p> </p>
<p> sendfile on; 開啟網路傳輸加快模式</p>
<p> tcp_nopush on; 改進TCP的傳輸速率BSD上的好東西<br> tcp_nodelay on;<br> server_tokens off;<br> gzip on; 啟動Gzip傳輸數據<br> gzip_static on;<br> gzip_comp_level 5;<br> gzip_min_length 1024;<br> keepalive_timeout 60;<br> #limit_zone myzone $binary_remote_addr 10m;</p>
<p> # Load config files from the /etc/nginx/conf.d directory<br> include /etc/nginx/conf.d/*.conf;</p>
<p>}</p>
<p>[/quote]</p>
<p> </p>
<p><font color="#00ccff"># vi /etc/nginx/conf.d/server.conf</font></p>
<p><font color="black">[quote]</font></p>
<p><font color="black">server {<br> listen 80;<br> server_name <a href="http://www.adj.idv.tw/">www.adj.idv.tw</a>;<br> access_log /var/log/nginx/www.adj.idv.tw.access.log;<br> error_log /var/www/html/adj/error.log error;<br> charset utf8;</font></p>
<p>
</p><p><font color="black"></font></p><font color="black"></font>
<p></p>
<p><font color="black">## Default location<br> location / {<br> root /var/www/html/adj;<br> index index.php;<br> }</font></p>
<p><font color="black"></font> </p>
<p><font color="black">## Images and static content is treated different<br> location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {<br> access_log on;<br> expires 30d;<br> root /var/www/html/adj;<br> }</font></p>
<p><font color="black">## Parse all .php file in the /var/www/html/adj directory<br> location ~ .php$ {<br> fastcgi_split_path_info ^(.+\.php)(.*)$;<br> fastcgi_pass 127.0.0.1:9000;<br> fastcgi_index index.php;<br> fastcgi_param SCRIPT_FILENAME /var/www/html/adj$fastcgi_script_name;<br> include fastcgi_params;<br> fastcgi_param QUERY_STRING $query_string;<br> fastcgi_param REQUEST_METHOD $request_method;<br> fastcgi_param CONTENT_TYPE $content_type;<br> fastcgi_param CONTENT_LENGTH $content_length;<br> fastcgi_intercept_errors on;<br> fastcgi_ignore_client_abort off;<br> fastcgi_connect_timeout 120;<br> fastcgi_send_timeout 180;</font></p>
<p> fastcgi_read_timeout 180;<br> fastcgi_buffer_size 256k;<br> fastcgi_buffers 4 256k;<br> fastcgi_busy_buffers_size 256k;<br> fastcgi_temp_file_write_size 256k;</p>
<p>}</p>
<p> </p>
<p>## Disable viewing .htaccess & .htpassword<br> location ~ /\.ht {<br> deny all;<br> }<br>}</p>
<p><font color="black">[/quote]</font></p>
<p><font color="#00ccff"></font> </p>
<p><font color="black">最後啟動相關服務</font></p>
<p>[quote]</p>
<p>service mysqld start</p>
<p>service php-fpm start</p>
<p>service nginx start</p>
<p>[/quote]</p>
<p> </p>
<p>這樣就大功告成啦~~</p>
<p> </p>
<p>相關文件參考:</p>
<p><a href="http://www.howtoforge.com/installing-php-5.3-nginx-and-php-fpm-on-ubuntu-debian" target="_blank">http://www.howtoforge.com/installing-php-5.3-nginx-and-php-fpm-on-ubuntu-debian</a><br><a href="http://wangchengtai.blog.hexun.com.tw/42855094_d.html" target="_blank">http://wangchengtai.blog.hexun.com.tw/42855094_d.html</a></p>
<p> </p>
<p>這個裝完已經包含php 的一些常用擴展, PDO,eaccelerator,memcache,tidy等等</p>
<p>本文為 <font color="#00cc99">21andy </font>原创,轉載請以超鏈結方式注明出處 <a href="http://www.21andy.com/blog/20100219/1701.html" target="_blank">http://www.21andy.com</a></p>
<p> </p>
<p>先新建一個 repo</p>
<p>[quote]</p>
<div class="hl-main"># vi /etc/yum.repos.d/centos.21andy.com.repo</div>
<p>[/quote]</p>
<p> </p>
<p>放入如下内容</p>
<p>[quote]</p>
<div class="hl-main">[21Andy.com]<br>name=21Andy.com Packages for Enterprise Linux 5 - $basearch<br>baseurl=http://www.21andy.com/centos/5/$basearch/<br>enabled=1<br>gpgcheck=0<br>protect=1</div>
<p>[/quote]</p>
<p> </p>
<p>啟用 EPEL repo<br>i386 </p>[attach]4958[/attach]<br><p> </p>
<p>x86_64</p>
<p>[quote]</p>
<div class="hl-main"><div class="hl-main">rpm -ihv http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm</div><a href="http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm" target="_blank"></a></div>
<p>[/quote]</p>
<p> </p>
<p>接著導入key</p>
<p>[quote]</p>
<div class="hl-main">rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL</div>
<p>[/quote]</p>
<p> </p>
<p>好了,一鍵安裝</p>
<p>[quote]</p>
<div class="hl-main"># yum install nginx php-fpm mysql-server</div>
<p>[/quote]</p>
<p> </p>
<p>爽吧!</p>
<p>如果 nginx 你要用 0.7.65 最新穩定版,把<br>yum -y install nginx<br>換成<br>yum -y install nginx-stable<br>就可以了</p>
<p> </p>
<p><font color="sienna">更完整的安裝,只要一句</font></p>
<p>[quote]</p>
<div class="hl-main">yum -y install nginx mysql-server php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator</div>
<p>[/quote]</p>
<p> </p>
<p>安裝結果,全自動</p>
<p>[quote]</p>
<blockquote>
<p>Dependencies Resolved</p>
<p>==========================================================<br>Package Arch Version Repository Size<br>==========================================================<br>Installing:<br>mysql x86_64 5.0.89-1.el5 21Andy.com 3.5 M<br>mysql-server x86_64 5.0.89-1.el5 21Andy.com 10 M<br>nginx x86_64 0.8.33-3.el5 21Andy.com 422 k<br>php-cli x86_64 5.3.1-2.el5 21Andy.com 2.4 M<br>php-eaccelerator x86_64 2:0.9.6-1.el5 21Andy.com 118 k<br>php-fpm x86_64 5.3.1-2.el5 21Andy.com 1.2 M<br>php-gd x86_64 5.3.1-2.el5 21Andy.com 110 k<br>php-mbstring x86_64 5.3.1-2.el5 21Andy.com 1.1 M<br>php-mcrypt x86_64 5.3.1-2.el5 21Andy.com 27 k<br>php-mysql x86_64 5.3.1-2.el5 21Andy.com 84 k<br>php-pdo x86_64 5.3.1-2.el5 21Andy.com 91 k<br>php-pear noarch 1:1.9.0-1.el5 21Andy.com 420 k<br>php-pecl-memcache x86_64 2.2.5-3.el5 21Andy.com 44 k<br>php-tidy x86_64 5.3.1-2.el5 21Andy.com 31 k<br>php-xml x86_64 5.3.1-2.el5 21Andy.com 115 k<br>php-xmlrpc x86_64 5.3.1-2.el5 21Andy.com 48 k<br>Installing for dependencies:<br>gmp x86_64 4.1.4-10.el5 base 201 k<br>libXaw x86_64 1.0.2-8.1 base 329 k<br>libXmu x86_64 1.0.2-5 base 63 k<br>libXpm x86_64 3.5.5-3 base 44 k<br>libedit x86_64 2.11-2.20080712cvs.el5 epel 80 k<br>libmcrypt x86_64 2.5.8-4.el5.centos extras 105 k<br>libtidy x86_64 0.99.0-14.20070615.el5 epel 140 k<br>php-common x86_64 5.3.1-2.el5 21Andy.com 554 k<br>sqlite2 x86_64 2.8.17-5.el5 21Andy.com 165 k<br>t1lib x86_64 5.1.1-7.el5 epel 208 k<br>Updating for dependencies:<br>libevent x86_64 1.4.12-1.el5 21Andy.com 129 k</p>
<p>Transaction Summary<br>==========================================================<br>Install 26 Package(s)<br>Update 1 Package(s)<br>Remove 0 Package(s) </p></blockquote>
<p>[/quote]</p>
<p> </p>
<p> </p>
<p>最後只要 yum -y update 一下,全是最新的<br>別忘了開機啟動</p>
<p>[quote]</p>
<div class="hl-main">chkconfig --level 345 mysqld on<br>chkconfig --level 345 php-fpm on<br>chkconfig --level 345 nginx on</div>
<p>[/quote]</p>
<p> </p>
<p><strong><font color="#00ccff">補充:所有的配置文件都在 /etc 目錄下,包括 nginx, php-fpm, mysql 的配置文件,請自行查找設置,以下為我的 nginx 的配置範例</font></strong></p>
<p><strong><font color="#00ccff"></font></strong> </p><font color="black">
<p>網站目錄 /var/www/html<br></p>
<p><font color="#00ccff"># vi /etc/nginx/nginx.conf</font></p></font>
<p><font color="black">[quote]</font></p>
<p>user nobody nobody;<br>worker_processes 10; 啟動進程,若是是256MB的VPS最好設定在4-8之間。<br>worker_rlimit_nofile 100000; 開啟文件數</p>
<p>error_log /var/log/nginx/error.log; 錯誤信息日誌路徑<br>#error_log /var/log/nginx/error.log notice;<br>#error_log /var/log/nginx/error.log info;</p>
<p>pid /var/run/nginx.pid;</p>
<p><br>events {<br> worker_connections 51200; 規定進程的最大連接數<br> use epoll; 利用I/O複用模式<br>}</p>
<p><br>http {<br> include /etc/nginx/mime.types; 定義文件類型<br> default_type application/octet-stream;</p>
<p> </p>
<p> log_format main '$remote_addr - $remote_user [$time_local] "$request" '<br> '$status $body_bytes_sent "$http_referer" '<br> '"$http_user_agent" "$http_x_forwarded_for"';</p>
<p> </p>
<p> access_log /var/log/nginx/access.log main; 設定訪問日誌</p>
<p> server_names_hash_bucket_size 128;<br> client_header_buffer_size 16k;<br> large_client_header_buffers 4 16k;<br> client_max_body_size 8m;</p>
<p> fastcgi_connect_timeout 180;<br> fastcgi_send_timeout 180;<br> fastcgi_read_timeout 180;<br> fastcgi_buffer_size 64k;<br> fastcgi_buffers 8 128k;<br> fastcgi_busy_buffers_size 128k;<br> fastcgi_temp_file_write_size 128k;</p>
<p> </p>
<p> sendfile on; 開啟網路傳輸加快模式</p>
<p> tcp_nopush on; 改進TCP的傳輸速率BSD上的好東西<br> tcp_nodelay on;<br> server_tokens off;<br> gzip on; 啟動Gzip傳輸數據<br> gzip_static on;<br> gzip_comp_level 5;<br> gzip_min_length 1024;<br> keepalive_timeout 60;<br> #limit_zone myzone $binary_remote_addr 10m;</p>
<p> # Load config files from the /etc/nginx/conf.d directory<br> include /etc/nginx/conf.d/*.conf;</p>
<p>}</p>
<p>[/quote]</p>
<p> </p>
<p><font color="#00ccff"># vi /etc/nginx/conf.d/server.conf</font></p>
<p><font color="black">[quote]</font></p>
<p><font color="black">server {<br> listen 80;<br> server_name <a href="http://www.adj.idv.tw/">www.adj.idv.tw</a>;<br> access_log /var/log/nginx/www.adj.idv.tw.access.log;<br> error_log /var/www/html/adj/error.log error;<br> charset utf8;</font></p>
<p>
</p><p><font color="black"></font></p><font color="black"></font>
<p></p>
<p><font color="black">## Default location<br> location / {<br> root /var/www/html/adj;<br> index index.php;<br> }</font></p>
<p><font color="black"></font> </p>
<p><font color="black">## Images and static content is treated different<br> location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {<br> access_log on;<br> expires 30d;<br> root /var/www/html/adj;<br> }</font></p>
<p><font color="black">## Parse all .php file in the /var/www/html/adj directory<br> location ~ .php$ {<br> fastcgi_split_path_info ^(.+\.php)(.*)$;<br> fastcgi_pass 127.0.0.1:9000;<br> fastcgi_index index.php;<br> fastcgi_param SCRIPT_FILENAME /var/www/html/adj$fastcgi_script_name;<br> include fastcgi_params;<br> fastcgi_param QUERY_STRING $query_string;<br> fastcgi_param REQUEST_METHOD $request_method;<br> fastcgi_param CONTENT_TYPE $content_type;<br> fastcgi_param CONTENT_LENGTH $content_length;<br> fastcgi_intercept_errors on;<br> fastcgi_ignore_client_abort off;<br> fastcgi_connect_timeout 120;<br> fastcgi_send_timeout 180;</font></p>
<p> fastcgi_read_timeout 180;<br> fastcgi_buffer_size 256k;<br> fastcgi_buffers 4 256k;<br> fastcgi_busy_buffers_size 256k;<br> fastcgi_temp_file_write_size 256k;</p>
<p>}</p>
<p> </p>
<p>## Disable viewing .htaccess & .htpassword<br> location ~ /\.ht {<br> deny all;<br> }<br>}</p>
<p><font color="black">[/quote]</font></p>
<p><font color="#00ccff"></font> </p>
<p><font color="black">最後啟動相關服務</font></p>
<p>[quote]</p>
<p>service mysqld start</p>
<p>service php-fpm start</p>
<p>service nginx start</p>
<p>[/quote]</p>
<p> </p>
<p>這樣就大功告成啦~~</p>
<p> </p>
<p>相關文件參考:</p>
<p><a href="http://www.howtoforge.com/installing-php-5.3-nginx-and-php-fpm-on-ubuntu-debian" target="_blank">http://www.howtoforge.com/installing-php-5.3-nginx-and-php-fpm-on-ubuntu-debian</a><br><a href="http://wangchengtai.blog.hexun.com.tw/42855094_d.html" target="_blank">http://wangchengtai.blog.hexun.com.tw/42855094_d.html</a></p>
<p> </p>
<p>這個裝完已經包含php 的一些常用擴展, PDO,eaccelerator,memcache,tidy等等</p>
<p>本文為 <font color="#00cc99">21andy </font>原创,轉載請以超鏈結方式注明出處 <a href="http://www.21andy.com/blog/20100219/1701.html" target="_blank">http://www.21andy.com</a></p>
<p> </p>
<p>先新建一個 repo</p>
<p>[quote]</p>
<div class="hl-main"># vi /etc/yum.repos.d/centos.21andy.com.repo</div>
<p>[/quote]</p>
<p> </p>
<p>放入如下内容</p>
<p>[quote]</p>
<div class="hl-main">[21Andy.com]<br>name=21Andy.com Packages for Enterprise Linux 5 - $basearch<br>baseurl=http://www.21andy.com/centos/5/$basearch/<br>enabled=1<br>gpgcheck=0<br>protect=1</div>
<p>[/quote]</p>
<p> </p>
<p>啟用 EPEL repo<br>i386 </p>[attach]4958[/attach]<br><p> </p>
<p>x86_64</p>
<p>[quote]</p>
<div class="hl-main"><div class="hl-main">rpm -ihv http://free.nchc.org.tw/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm</div><a href="http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm" target="_blank"></a></div>
<p>[/quote]</p>
<p> </p>
<p>接著導入key</p>
<p>[quote]</p>
<div class="hl-main">rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL</div>
<p>[/quote]</p>
<p> </p>
<p>好了,一鍵安裝</p>
<p>[quote]</p>
<div class="hl-main"># yum install nginx php-fpm mysql-server</div>
<p>[/quote]</p>
<p> </p>
<p>爽吧!</p>
<p>如果 nginx 你要用 0.7.65 最新穩定版,把<br>yum -y install nginx<br>換成<br>yum -y install nginx-stable<br>就可以了</p>
<p> </p>
<p><font color="sienna">更完整的安裝,只要一句</font></p>
<p>[quote]</p>
<div class="hl-main">yum -y install nginx mysql-server php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator</div>
<p>[/quote]</p>
<p> </p>
<p>安裝結果,全自動</p>
<p>[quote]</p>
<blockquote>
<p>Dependencies Resolved</p>
<p>==========================================================<br>Package Arch Version Repository Size<br>==========================================================<br>Installing:<br>mysql x86_64 5.0.89-1.el5 21Andy.com 3.5 M<br>mysql-server x86_64 5.0.89-1.el5 21Andy.com 10 M<br>nginx x86_64 0.8.33-3.el5 21Andy.com 422 k<br>php-cli x86_64 5.3.1-2.el5 21Andy.com 2.4 M<br>php-eaccelerator x86_64 2:0.9.6-1.el5 21Andy.com 118 k<br>php-fpm x86_64 5.3.1-2.el5 21Andy.com 1.2 M<br>php-gd x86_64 5.3.1-2.el5 21Andy.com 110 k<br>php-mbstring x86_64 5.3.1-2.el5 21Andy.com 1.1 M<br>php-mcrypt x86_64 5.3.1-2.el5 21Andy.com 27 k<br>php-mysql x86_64 5.3.1-2.el5 21Andy.com 84 k<br>php-pdo x86_64 5.3.1-2.el5 21Andy.com 91 k<br>php-pear noarch 1:1.9.0-1.el5 21Andy.com 420 k<br>php-pecl-memcache x86_64 2.2.5-3.el5 21Andy.com 44 k<br>php-tidy x86_64 5.3.1-2.el5 21Andy.com 31 k<br>php-xml x86_64 5.3.1-2.el5 21Andy.com 115 k<br>php-xmlrpc x86_64 5.3.1-2.el5 21Andy.com 48 k<br>Installing for dependencies:<br>gmp x86_64 4.1.4-10.el5 base 201 k<br>libXaw x86_64 1.0.2-8.1 base 329 k<br>libXmu x86_64 1.0.2-5 base 63 k<br>libXpm x86_64 3.5.5-3 base 44 k<br>libedit x86_64 2.11-2.20080712cvs.el5 epel 80 k<br>libmcrypt x86_64 2.5.8-4.el5.centos extras 105 k<br>libtidy x86_64 0.99.0-14.20070615.el5 epel 140 k<br>php-common x86_64 5.3.1-2.el5 21Andy.com 554 k<br>sqlite2 x86_64 2.8.17-5.el5 21Andy.com 165 k<br>t1lib x86_64 5.1.1-7.el5 epel 208 k<br>Updating for dependencies:<br>libevent x86_64 1.4.12-1.el5 21Andy.com 129 k</p>
<p>Transaction Summary<br>==========================================================<br>Install 26 Package(s)<br>Update 1 Package(s)<br>Remove 0 Package(s) </p></blockquote>
<p>[/quote]</p>
<p> </p>
<p> </p>
<p>最後只要 yum -y update 一下,全是最新的<br>別忘了開機啟動</p>
<p>[quote]</p>
<div class="hl-main">chkconfig --level 345 mysqld on<br>chkconfig --level 345 php-fpm on<br>chkconfig --level 345 nginx on</div>
<p>[/quote]</p>
<p> </p>
<p><strong><font color="#00ccff">補充:所有的配置文件都在 /etc 目錄下,包括 nginx, php-fpm, mysql 的配置文件,請自行查找設置,以下為我的 nginx 的配置範例</font></strong></p>
<p><strong><font color="#00ccff"></font></strong> </p><font color="black">
<p>網站目錄 /var/www/html<br></p>
<p><font color="#00ccff"># vi /etc/nginx/nginx.conf</font></p></font>
<p><font color="black">[quote]</font></p>
<p>user nobody nobody;<br>worker_processes 10; 啟動進程,若是是256MB的VPS最好設定在4-8之間。<br>worker_rlimit_nofile 100000; 開啟文件數</p>
<p>error_log /var/log/nginx/error.log; 錯誤信息日誌路徑<br>#error_log /var/log/nginx/error.log notice;<br>#error_log /var/log/nginx/error.log info;</p>
<p>pid /var/run/nginx.pid;</p>
<p><br>events {<br> worker_connections 51200; 規定進程的最大連接數<br> use epoll; 利用I/O複用模式<br>}</p>
<p><br>http {<br> include /etc/nginx/mime.types; 定義文件類型<br> default_type application/octet-stream;</p>
<p> </p>
<p> log_format main '$remote_addr - $remote_user [$time_local] "$request" '<br> '$status $body_bytes_sent "$http_referer" '<br> '"$http_user_agent" "$http_x_forwarded_for"';</p>
<p> </p>
<p> access_log /var/log/nginx/access.log main; 設定訪問日誌</p>
<p> server_names_hash_bucket_size 128;<br> client_header_buffer_size 16k;<br> large_client_header_buffers 4 16k;<br> client_max_body_size 8m;</p>
<p> fastcgi_connect_timeout 180;<br> fastcgi_send_timeout 180;<br> fastcgi_read_timeout 180;<br> fastcgi_buffer_size 64k;<br> fastcgi_buffers 8 128k;<br> fastcgi_busy_buffers_size 128k;<br> fastcgi_temp_file_write_size 128k;</p>
<p> </p>
<p> sendfile on; 開啟網路傳輸加快模式</p>
<p> tcp_nopush on; 改進TCP的傳輸速率BSD上的好東西<br> tcp_nodelay on;<br> server_tokens off;<br> gzip on; 啟動Gzip傳輸數據<br> gzip_static on;<br> gzip_comp_level 5;<br> gzip_min_length 1024;<br> keepalive_timeout 60;<br> #limit_zone myzone $binary_remote_addr 10m;</p>
<p> # Load config files from the /etc/nginx/conf.d directory<br> include /etc/nginx/conf.d/*.conf;</p>
<p>}</p>
<p>[/quote]</p>
<p> </p>
<p><font color="#00ccff"># vi /etc/nginx/conf.d/server.conf</font></p>
<p><font color="black">[quote]</font></p>
<p><font color="black">server {<br> listen 80;<br> server_name <a href="http://www.adj.idv.tw/">www.adj.idv.tw</a>;<br> access_log /var/log/nginx/www.adj.idv.tw.access.log;<br> error_log /var/www/html/adj/error.log error;<br> charset utf8;</font></p>
<p>
</p><p><font color="black"></font></p><font color="black"></font>
<p></p>
<p><font color="black">## Default location<br> location / {<br> root /var/www/html/adj;<br> index index.php;<br> }</font></p>
<p><font color="black"></font> </p>
<p><font color="black">## Images and static content is treated different<br> location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {<br> access_log on;<br> expires 30d;<br> root /var/www/html/adj;<br> }</font></p>
<p><font color="black">## Parse all .php file in the /var/www/html/adj directory<br> location ~ .php$ {<br> fastcgi_split_path_info ^(.+\.php)(.*)$;<br> fastcgi_pass 127.0.0.1:9000;<br> fastcgi_index index.php;<br> fastcgi_param SCRIPT_FILENAME /var/www/html/adj$fastcgi_script_name;<br> include fastcgi_params;<br> fastcgi_param QUERY_STRING $query_string;<br> fastcgi_param REQUEST_METHOD $request_method;<br> fastcgi_param CONTENT_TYPE $content_type;<br> fastcgi_param CONTENT_LENGTH $content_length;<br> fastcgi_intercept_errors on;<br> fastcgi_ignore_client_abort off;<br> fastcgi_connect_timeout 120;<br> fastcgi_send_timeout 180;</font></p>
<p> fastcgi_read_timeout 180;<br> fastcgi_buffer_size 256k;<br> fastcgi_buffers 4 256k;<br> fastcgi_busy_buffers_size 256k;<br> fastcgi_temp_file_write_size 256k;</p>
<p>}</p>
<p> </p>
<p>## Disable viewing .htaccess & .htpassword<br> location ~ /\.ht {<br> deny all;<br> }<br>}</p>
<p><font color="black">[/quote]</font></p>
<p><font color="#00ccff"></font> </p>
<p><font color="black">最後啟動相關服務</font></p>
<p>[quote]</p>
<p>service mysqld start</p>
<p>service php-fpm start</p>
<p>service nginx start</p>
<p>[/quote]</p>
<p> </p>
<p>這樣就大功告成啦~~</p>
<p> </p>
<p>相關文件參考:</p>
<p><a href="http://www.howtoforge.com/installing-php-5.3-nginx-and-php-fpm-on-ubuntu-debian" target="_blank">http://www.howtoforge.com/installing-php-5.3-nginx-and-php-fpm-on-ubuntu-debian</a><br><a href="http://wangchengtai.blog.hexun.com.tw/42855094_d.html" target="_blank">http://wangchengtai.blog.hexun.com.tw/42855094_d.html</a></p>
<p> </p>
<p>這個裝完已經包含php 的一些常用擴展, PDO,eaccelerator,memcache,tidy等等</p>
<p>本文為 <font color="#00cc99">21andy </font>原创,轉載請以超鏈結方式注明出處 <a href="http://www.21andy.com/blog/20100219/1701.html" target="_blank">http://www.21andy.com</a></p>
<p> </p>
<p>先新建一個 repo</p>
<p>[quote]</p>
<div class="hl-main"># vi /etc/yum.repos.d/centos.21andy.com.repo</div>
<p>[/quote]</p>
<p> </p>
<p>放入如下内容</p>
<p>[quote]</p>
<div class="hl-main">[21Andy.com]<br>name=21Andy.com Packages for Enterprise Linux 5 - $basearch<br>baseurl=http://www.21andy.com/centos/5/$basearch/<br>enabled=1<br>gpgcheck=0<br>protect=1</div>
<p>[/quote]</p>
<p> </p>
<p>啟用 EPEL repo<br>i386 </p>[attach]4958[/attach]<br><p> </p>
<p>x86_64</p>
<p>[quote]</p>
<div class="hl-main"><div class="hl-main">rpm -ihv http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm</div><a href="http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm" target="_blank"></a></div>
<p>[/quote]</p>
<p> </p>
<p>接著導入key</p>
<p>[quote]</p>
<div class="hl-main">rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL</div>
<p>[/quote]</p>
<p> </p>
<p>好了,一鍵安裝</p>
<p>[quote]</p>
<div class="hl-main"># yum install nginx php-fpm mysql-server</div>
<p>[/quote]</p>
<p> </p>
<p>爽吧!</p>
<p>如果 nginx 你要用 0.7.65 最新穩定版,把<br>yum -y install nginx<br>換成<br>yum -y install nginx-stable<br>就可以了</p>
<p> </p>
<p><font color="sienna">更完整的安裝,只要一句</font></p>
<p>[quote]</p>
<div class="hl-main">yum -y install nginx mysql-server php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator</div>
<p>[/quote]</p>
<p> </p>
<p>安裝結果,全自動</p>
<p>[quote]</p>
<blockquote>
<p>Dependencies Resolved</p>
<p>==========================================================<br>Package Arch Version Repository Size<br>==========================================================<br>Installing:<br>mysql x86_64 5.0.89-1.el5 21Andy.com 3.5 M<br>mysql-server x86_64 5.0.89-1.el5 21Andy.com 10 M<br>nginx x86_64 0.8.33-3.el5 21Andy.com 422 k<br>php-cli x86_64 5.3.1-2.el5 21Andy.com 2.4 M<br>php-eaccelerator x86_64 2:0.9.6-1.el5 21Andy.com 118 k<br>php-fpm x86_64 5.3.1-2.el5 21Andy.com 1.2 M<br>php-gd x86_64 5.3.1-2.el5 21Andy.com 110 k<br>php-mbstring x86_64 5.3.1-2.el5 21Andy.com 1.1 M<br>php-mcrypt x86_64 5.3.1-2.el5 21Andy.com 27 k<br>php-mysql x86_64 5.3.1-2.el5 21Andy.com 84 k<br>php-pdo x86_64 5.3.1-2.el5 21Andy.com 91 k<br>php-pear noarch 1:1.9.0-1.el5 21Andy.com 420 k<br>php-pecl-memcache x86_64 2.2.5-3.el5 21Andy.com 44 k<br>php-tidy x86_64 5.3.1-2.el5 21Andy.com 31 k<br>php-xml x86_64 5.3.1-2.el5 21Andy.com 115 k<br>php-xmlrpc x86_64 5.3.1-2.el5 21Andy.com 48 k<br>Installing for dependencies:<br>gmp x86_64 4.1.4-10.el5 base 201 k<br>libXaw x86_64 1.0.2-8.1 base 329 k<br>libXmu x86_64 1.0.2-5 base 63 k<br>libXpm x86_64 3.5.5-3 base 44 k<br>libedit x86_64 2.11-2.20080712cvs.el5 epel 80 k<br>libmcrypt x86_64 2.5.8-4.el5.centos extras 105 k<br>libtidy x86_64 0.99.0-14.20070615.el5 epel 140 k<br>php-common x86_64 5.3.1-2.el5 21Andy.com 554 k<br>sqlite2 x86_64 2.8.17-5.el5 21Andy.com 165 k<br>t1lib x86_64 5.1.1-7.el5 epel 208 k<br>Updating for dependencies:<br>libevent x86_64 1.4.12-1.el5 21Andy.com 129 k</p>
<p>Transaction Summary<br>==========================================================<br>Install 26 Package(s)<br>Update 1 Package(s)<br>Remove 0 Package(s) </p></blockquote>
<p>[/quote]</p>
<p> </p>
<p> </p>
<p>最後只要 yum -y update 一下,全是最新的<br>別忘了開機啟動</p>
<p>[quote]</p>
<div class="hl-main">chkconfig --level 345 mysqld on<br>chkconfig --level 345 php-fpm on<br>chkconfig --level 345 nginx on</div>
<p>[/quote]</p>
<p> </p>
<p><strong><font color="#00ccff">補充:所有的配置文件都在 /etc 目錄下,包括 nginx, php-fpm, mysql 的配置文件,請自行查找設置,以下為我的 nginx 的配置範例</font></strong></p>
<p><strong><font color="#00ccff"></font></strong> </p><font color="black">
<p>網站目錄 /var/www/html<br></p>
<p><font color="#00ccff"># vi /etc/nginx/nginx.conf</font></p></font>
<p><font color="black">[quote]</font></p>
<p>user nobody nobody;<br>worker_processes 10; 啟動進程,若是是256MB的VPS最好設定在4-8之間。<br>worker_rlimit_nofile 100000; 開啟文件數</p>
<p>error_log /var/log/nginx/error.log; 錯誤信息日誌路徑<br>#error_log /var/log/nginx/error.log notice;<br>#error_log /var/log/nginx/error.log info;</p>
<p>pid /var/run/nginx.pid;</p>
<p><br>events {<br> worker_connections 51200; 規定進程的最大連接數<br> use epoll; 利用I/O複用模式<br>}</p>
<p><br>http {<br> include /etc/nginx/mime.types; 定義文件類型<br> default_type application/octet-stream;</p>
<p> </p>
<p> log_format main '$remote_addr - $remote_user [$time_local] "$request" '<br> '$status $body_bytes_sent "$http_referer" '<br> '"$http_user_agent" "$http_x_forwarded_for"';</p>
<p> </p>
<p> access_log /var/log/nginx/access.log main; 設定訪問日誌</p>
<p> server_names_hash_bucket_size 128;<br> client_header_buffer_size 16k;<br> large_client_header_buffers 4 16k;<br> client_max_body_size 8m;</p>
<p> fastcgi_connect_timeout 180;<br> fastcgi_send_timeout 180;<br> fastcgi_read_timeout 180;<br> fastcgi_buffer_size 64k;<br> fastcgi_buffers 8 128k;<br> fastcgi_busy_buffers_size 128k;<br> fastcgi_temp_file_write_size 128k;</p>
<p> </p>
<p> sendfile on; 開啟網路傳輸加快模式</p>
<p> tcp_nopush on; 改進TCP的傳輸速率BSD上的好東西<br> tcp_nodelay on;<br> server_tokens off;<br> gzip on; 啟動Gzip傳輸數據<br> gzip_static on;<br> gzip_comp_level 5;<br> gzip_min_length 1024;<br> keepalive_timeout 60;<br> #limit_zone myzone $binary_remote_addr 10m;</p>
<p> # Load config files from the /etc/nginx/conf.d directory<br> include /etc/nginx/conf.d/*.conf;</p>
<p>}</p>
<p>[/quote]</p>
<p> </p>
<p><font color="#00ccff"># vi /etc/nginx/conf.d/server.conf</font></p>
<p><font color="black">[quote]</font></p>
<p><font color="black">server {<br> listen 80;<br> server_name <a href="http://www.adj.idv.tw/">www.adj.idv.tw</a>;<br> access_log /var/log/nginx/www.adj.idv.tw.access.log;<br> error_log /var/www/html/adj/error.log error;<br> charset utf8;</font></p>
<p>
</p><p><font color="black"></font></p><font color="black"></font>
<p></p>
<p><font color="black">## Default location<br> location / {<br> root /var/www/html/adj;<br> index index.php;<br> }</font></p>
<p><font color="black"></font> </p>
<p><font color="black">## Images and static content is treated different<br> location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|xml)$ {<br> access_log on;<br> expires 30d;<br> root /var/www/html/adj;<br> }</font></p>
<p><font color="black">## Parse all .php file in the /var/www/html/adj directory<br> location ~ .php$ {<br> fastcgi_split_path_info ^(.+\.php)(.*)$;<br> fastcgi_pass 127.0.0.1:9000;<br> fastcgi_index index.php;<br> fastcgi_param SCRIPT_FILENAME /var/www/html/adj$fastcgi_script_name;<br> include fastcgi_params;<br> fastcgi_param QUERY_STRING $query_string;<br> fastcgi_param REQUEST_METHOD $request_method;<br> fastcgi_param CONTENT_TYPE $content_type;<br> fastcgi_param CONTENT_LENGTH $content_length;<br> fastcgi_intercept_errors on;<br> fastcgi_ignore_client_abort off;<br> fastcgi_connect_timeout 120;<br> fastcgi_send_timeout 180;</font></p>
<p> fastcgi_read_timeout 180;<br> fastcgi_buffer_size 256k;<br> fastcgi_buffers 4 256k;<br> fastcgi_busy_buffers_size 256k;<br> fastcgi_temp_file_write_size 256k;</p>
<p>}</p>
<p> </p>
<p>## Disable viewing .htaccess & .htpassword<br> location ~ /\.ht {<br> deny all;<br> }<br>}</p>
<p><font color="black">[/quote]</font></p>
<p><font color="#00ccff"></font> </p>
<p><font color="black">最後啟動相關服務</font></p>
<p>[quote]</p>
<p>service mysqld start</p>
<p>service php-fpm start</p>
<p>service nginx start</p>
<p>[/quote]</p>
<p> </p>
<p>這樣就大功告成啦~~</p>
<p> </p>
<p>相關文件參考:</p>
<p><a href="http://www.howtoforge.com/installing-php-5.3-nginx-and-php-fpm-on-ubuntu-debian" target="_blank">http://www.howtoforge.com/installing-php-5.3-nginx-and-php-fpm-on-ubuntu-debian</a><br><a href="http://wangchengtai.blog.hexun.com.tw/42855094_d.html" target="_blank">http://wangchengtai.blog.hexun.com.tw/42855094_d.html</a></p>
jordan7372 2010-6-23 14:31
:041::041: