计算机教程

linux下nginx+php+mysql 自助环境搭建

22 6月 , 2019  

 

  fastcgi_send_timeout 300;

[html] view plaincopy

  make && make install

  1. yum install libxml2-devel  

 access_log /usr/local/nginx/logs/webaccess.log access;

13>【pcre-8.10】

# vi /usr/local/php/etc/php-fpm.conf 取消以下;分号注释

5>【安装libmcrypt】

   cd nginx-1.0.5

 

ulimit -SHn 65535

14>【安装openssl】

#net.ipv4.tcp_tw_len = 1

  1. yum install gcc  
  2. yum install gcc-c++  

fastcgi_param  REQUEST_URI        $request_uri;

  1. tar -zxvf ncurses-5.6.tar.gz  
  2. cd ncurses-5.6  
  3. ./configure –with-shared –without-debug –without-ada –enable-overwrite  
  4. make  
  5. make install  

      #fastcgi_pass  unix:/tmp/php-cgi.sock;

  1. groupadd www  
  2. useradd -g www www  
  3. tar -zxvf nginx-1.1.8.tar.gz  
  4. cd nginx-1.1.8  
  5. ./configure –user=www –group=www –prefix=/usr/local/nginx –with-openssl=/lamp/src/openssl-1.0.0e –with-http_stub_status_module –with-http_ssl_module   
  6. make  
  7. make install  

fastcgi_param  QUERY_STRING       $query_string;

 

  (如果不安装,make gd时报错`AM_ICONV’not found in library )

 

  F.jpeg6安装

[html] view plaincopy

  keepalive_timeout 60;

[html] view plaincopy

fastcgi_param  CONTENT_TYPE       $content_type;

[html] view plaincopy

1 ;pid = run/php-fpm.pid

 

   ./configure

  1. tar -zxvf libpng-1.2.31.tar.gz  
  2. cd libpng-1.2.31  
  3. ./configure –prefix=/usr/local/libpng/  
  4. make  
  5. make install  

 

12>【安装gd】

  ./configure

#带url重写(zend framework)

eaccelerator.optimizer=”1″

 

net.ipv4.tcp_tw_recycle = 1

 

fastcgi_param  SERVER_SOFTWARE    nginx;

 

更改expose_php = on 为expose_php = off (在curl中隐藏php版本号)

20>【nginx虚拟主机配置】

    ./configure –prefix=/usr/local/curl

[html] view plaincopy

net.core.netdev_max_backlog =  32768

 

3 ;pm.min_spare_servers = 5

 

eaccelerator.shm_prune_period=”0″

18>【安装php】

vi /usr/local/php/etc/php.ini

  1. tar -zxvf libmcrypt-2.5.8.tar.gz  
  2. cd libmcrypt-2.5.8  
  3. ./configure –prefix=/usr/local/libmcrypt/ –enable-ltdl-install  
  4. make  
  5. make install  

在/usr/local/webserver/nginx/conf/目录中创建fcgi.conf文件:

 

      expires      30d;

11>【安装autoconf】

   make && make install

 

net.ipv4.ip_local_port_range = 1024  65535

 

fastcgi_param  REQUEST_METHOD     $request_method;

17>【安装mysql】

   ./configure –prefix=/usr/local/libxml2

[html] view plaincopy

net.ipv4.tcp_mem = 94500000 915000000 927000000

15>【安装nginx】

tar -jxvf eaccelerator-0\[1\].9.6.1.tar.bz2

 

  gzip_vary on;

 

  J 安装fontconfig

  1. tar -zxvf php-5.2.6.tar.gz  
  2. gzip -cd php-5.2.6-fpm-0.5.8.diff.gz | patch -d php-5.2.6 -p1  
  3.   
  4. cd php-5.2.6  
  5. ./configure –prefix=/usr/local/php/ –with-config-file-path=/usr/local/php/etc/ –with-mysql=/usr/local/mysql/ –with-libxml-dir=/usr/local/libxml2/ –with-jpeg-dir=/usr/local/jpeg6/ –with-freetype-dir=/usr/local/freetype/ –with-gd=/usr/local/gd2/ –with-mcrypt=/usr/local/libmcrypt/ –with-mysqli=/usr/local/mysql/bin/mysql_config –enable-soap –enable-mbstring=all –enable-sockets –enable-fastcgi –enable-fpm  
  6. make  
  7. make install  
  8. cp php.ini-dist /usr/local/php/etc/php.ini  
  9. #修改php-fpm.conf  
  10. vi /usr/local/php/etc/php-fpm.conf  
  11. #查找63,66行将注释去掉  
  12. <value name=”user”>nobody</value>  
  13. <value name=”group”>nobody</value>  
  14. #启动php  
  15. /usr/local/php/sbin/php-fpm start  

   tar -zxvf libxml2-2.6.19.tar.gz

[html] view plaincopy

              ‘$status $body_bytes_sent “$http_referer” ‘

  1. tar -zxvf libxml2-2.6.30.tar.gz  
  2. cd libxml2-2.6.30  
  3. ./configure –prefix=/usr/local/libxml2/  
  4. make   
  5. make install  

  cd gzip-1.3.5

[html] view plaincopy

   mkdir -p /usr/local/jpeg6/include

2>【开放80、3306、22端口】

#net.ipv4.tcp_keepalive_time = 120

10>【安装freetype】

# cp php.ini-production  /usr/local/php/etc/php.ini

 

  ./configure –prefix=/usr/local/expat

 

    {

  1. tar -zxvf pcre-8.10.tar.gz  
  2. cd pcre-8.10  
  3. ./configure  
  4. make  
  5. make install  

 worker_connections 51200;

[html] view plaincopy

# chkconfig –add php-fpm

7>【安装zlib】

  tcp_nodelay on;

[html] view plaincopy

error_log logs/error.log crit;

  1. groupadd mysql  
  2. useradd -g mysql mysql  
  3. tar -zxvf mysql-5.1.59.tar.gz  
  4. cd mysql-5.1.59  
  5. ./configure –prefix=/usr/local/mysql/ –with-extra-charsets=all  
  6. make  
  7. make install  
  8.   
  9. cp support-files/my-medium.cnf /etc/my.cnf  
  10. /usr/local/mysql/bin/mysql_install_db –user=mysql  
  11. chown -R root /usr/local/mysql  
  12. chown -R mysql /usr/local/mysql/var  
  13. chgrp -R mysql /usr/local/mysql  
  14.   
  15. /usr/local/mysql/bin/mysqld_safe  –user=mysql &  
  16. cp /lamp/src/mysql-5.1.59/support-files/mysql.server /etc/rc.d/init.d/mysqld  
  17. chown root.root /etc/rc.d/init.d/mysqld  
  18. chmod 755 /etc/rc.d/init.d/mysqld  
  19. chkconfig –add mysqld  
  20. chkconfig –list mysqld  
  21. chkconfig –levels 245 mysqld off  
  22.   
  23. #配置mysql  
  24. cd /usr/local/mysql  
  25. #简单的测试  
  26. bin/mysqladmin version  
  27. #查看所有mysql参数  
  28. bin/mysqladmin Variables  
  29. #没有密码可以直接登录本机服务器  
  30. bin/mysql -uroot  
  31. DELETE FROM mysql.user WHERE Host=’localhost’ AND User=”;  
  32. FLUSH PRIVILEGES;  
  33. #设置root密码为123456  
  34. SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘123456’);  
  35. #配置可远程连接mysql  
  36. use mysql  
  37. SELECT user,password,host FROM user;  
  38. DELETE FROM user WHERE host=’localhsot.localdomain’  
  39. DELETE FROM user WHERE host=’127.0.0.1′;  
  40. UPDATE user SET host=’%’ WHERE user=’root’;  
  41. #重启mysql  
  42. service mysqld restart  

启动nginx并加入/etc/rc.d/rc.local开机自启动

  1. server {    
  2.     listen 80 default;    
  3.     server_name dev.localhost;    
  4.     access_log logs/dev.access.log;    
  5.   
  6.   
  7.     root /var/www/html/dev;    
  8.   
  9.   
  10.     server_name_in_redirect off;    
  11.   
  12.   
  13.     location / {    
  14.         index index.html index.php;  
  15.     }    
  16.   
  17.   
  18.     location ~ \.php$ {  
  19.         fastcgi_pass   127.0.0.1:9000;  
  20.         fastcgi_index  index.php;  
  21.         fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;  
  22.         include        fastcgi_params;  
  23.     }  
  24. }    

net.ipv4.tcp_synack_retries = 2

6>【安装libxml2-devel】

7.测试配置文件

[html] view plaincopy

   ./configure –user=nginx –group=nginx –prefix=/usr/local/nginx
–with-http_stub_status_module –with-http_ssl_module

[html] view plaincopy

     cd curl-7.15.0

 

           }

  1. tar -zxvf openssl-1.0.0e.tar.gz  
  2. cd openssl-1.0.0e  
  3. ./config –prefix=/usr/local/openssl  
  4. make  
  5. make install  

  cd fontconfig-2.4.2

  1. mkdir /usr/local/jpeg6  
  2. mkdir /usr/local/jpeg6/bin  
  3. mkdir /usr/local/jpeg6/lib  
  4. mkdir /usr/local/jpeg6/include  
  5. mkdir -p /usr/local/jpeg6/man/man1  
  6.   
  7. tar -zxvf jpegsrc.v6b.tar.gz  
  8. cd jpeg-6b  
  9. ./configure –prefix=/usr/local/jpeg6/ –enable-shared –enable-static  
  10. make  
  11. make install  

/sbin/sysctl -p

  1. tar -zxvf autoconf-2.61.tar.gz  
  2. cd autoconf-2.61  
  3. ./configure  
  4. make  
  5. make install  

  make && make install

  1. vi /usr/local/nginx/conf/nginx.conf  
  2. #在server下找到location / 修改解析PHP文件存放的路径, 修改为:  
  3. location / {  
  4.         root   /var/www/html;  
  5.         index  index.html index.htm index.php;  
  6. }  
  7. #root表示虚拟目录设置为/var/www/html,增加默认解析index.php  
  8. #在server下找到location ~ /.php$ 修改php解释器FastCGI配置,修改为:  
  9. location ~ \.php$ {  
  10.             root           /var/www/html;  
  11.             fastcgi_pass   127.0.0.1:9000;  
  12.             fastcgi_index  index.php;  
  13.             fastcgi_param  SCRIPT_FILENAME  /var/www/html$fastcgi_script_name;  
  14.             include        fastcgi_params;  
  15. }  
  16. #将nginx添加到自启动中  
  17. echo “/usr/local/nginx/sbin/nginx” >> /etc/rc.d/rc.local  
  18. #将php添加到自启动中  
  19. echo “/usr/local/php/sbin/php-fpm start” >> /etc/rc.d/rc.local  

cd eaccelerator-0.9.6.1/

++++++++++++++++++++++++++++++++++++++++++++++
Linux下nginx+php+mysql环境搭建
++++++++++++++++++++++++++++++++++++++++++++++
操作系统    : [CentOS6.0]
服务器     : [nginx-1.1.8]
PHP      : [php-5.2.6]
数据库     : [mysql-5.1.59]
++++++++++++++++++++++++++++++++++++++++++++++
准备安装软件(download)
 1>[nginx-1.1.8]
      http://nginx.org/download/nginx-1.1.8.tar.gz
 2>[php-5.2.6]
      http://museum.php.net/php5/php-5.2.6.tar.gz
 3>[php-5.2.6-fpm-0.5.8.diff.gz]
      http://php-fpm.org/downloads/php-5.2.6-fpm-0.5.8.diff.gz
 4>[mysql-5.1.59]
   
  http://downloads.mysql.com/archives/mysql-5.1/mysql-5.1.59.tar.gz
 5>[libxml2-2.6.30]
   
  http://download.chinaunix.net/down.php?id=28491&ResourceID=6095&site=1
 6>[libmcrypt-2.5.8]
   
  http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
 7>[zlib-1.2.3]
   
  http://sourceforge.net/projects/libpng/files/zlib/1.2.3/zlib-1.2.3.tar.gz/download
 8>[libpng-1.2.31]
   
  http://files.directadmin.com/services/custombuild/libpng-1.2.31.tar.gz
 9>[jpegsrc.v6b]
   
  http://download.chinaunix.net/down.php?id=10021&ResourceID=5095&site=1
10>[freetype-2.3.5]
     
 http://nongnu.ask[Apache](http://www.jikexueyuan.com/course/apache/).com/freetype/freetype-2.3.5.tar.gz
11>[autoconf-2.61]
       http://ftp.gnu.org/gnu/autoconf/autoconf-2.61.tar.gz
12>[gd-2.0.35]
     
 http://code.google.com/p/google-desktop-for-linux-mirror/downloads/detail?name=gd-2.0.35.tar.gz&can=2&q=
13>[ncurses-5.6]
       http://ftp.gnu.org/gnu/ncurses/ncurses-5.6.tar.gz
14>[pcre-8.10]
     
 http://sourceforge.net/projects/pcre/files/pcre/8.10/pcre-8.10.tar.gz/download
15>[openssl-1.0.0e]
       http://www.openssl.org/source/openssl-1.0.0e.tar.gz
+++++++++++++++++++++++++++++++++++++++++++++
1>【安装gcc, gcc-c++】

worker_rlimit_nofile 65535;

[html] view plaincopy

   ./configure –prefix=/usr/local/jpeg6/ –enable-shared
–enable-static

19>【nginx配置】

# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

 

   tar -zvxf freetype-2.3.5.tar.gz

  1. tar -zxvf gd-2.0.35.tar.gz  
  2. cd gd-2.0.35  
  3. ./configure –prefix=/usr/local/gd2/ –with-jpeg=/usr/local/jpeg6/ –with-freetype=/usr/local/freetype/  
  4. make  
  5. make install  

mkdir -p /data/web  上传index.php(附件提供下载) 到/data/web下,
在浏览器里输入http://192.168.1.101/index.php看看效果吧

[html] view plaincopy

fastcgi_param  CONTENT_LENGTH     $content_length;

[html] view plaincopy

  fastcgi_read_timeout 300;

9>【安装jpegsrc.v6b】

6 整合php和nginx

 

  gzip_min_length  1k;

[html] view plaincopy

net.core.wmem_max = 16777216

 

  }

[html] view plaincopy

net.ipv4.tcp_syn_retries = 2

[html] view plaincopy

4 ;pm.max_spare_servers = 35

 

  cd expat-2.0.1

[html] view plaincopy

  make && make install

vi /usr/local/nginx/conf/nginx.conf
#在http最后一行加入
include    /usr/local/nginx/conf/vhost/dev_localhost.config;
#不带url重写

  H 安装freetype

[html] view plaincopy

10 测试

16>【安装ncurses】

环境:操作系统:centos 5.5 32位 服务器地址:192.168.1.101

3>【建立lamp/src目录, 将源码包上传】
4>【安装libxml2】

make install


      expires      1h;

[html] view plaincopy

9.安装eaccelerator 优化php

 

4 安装php准备工作

  1. #关闭防火墙  
  2. service iptables stop  
  3. vi /etc/sysconfig/iptables  
  4. #添加  
  5. -A INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT  
  6. -A INPUT -m state –state NEW -m tcp -p tcp –dport 3306 -j ACCEPT  
  7. -A INPUT -m state –state NEW -m tcp -p tcp –dport 22 -j ACCEPT  
  8. #重启防火墙  
  9. service iptables restart  

执行下面两个命令,以防编译php报错

  1. tar -zxvf freetype-2.3.5.tar.gz  
  2. cd freetype-2.3.5  
  3. ./configure –prefix=/usr/local/freetype/  
  4. make  
  5. make install  

# service php-fpm start

  1. #重启nginx  
  2. /usr/local/nginx/sbin/nginx -s reload  
  3. #重启php  
  4. /usr/local/php/sbin/php-fpm restart  

  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$

  1. server {  
  2.     listen 80;  
  3.     server_name dev.localhost;  
  4.     access_log logs/dev.access.log;    
  5.           
  6.     root   /var/www/html/dev/code/html;  
  7.     location / {  
  8.         index index.html index.php;  
  9.   
  10.   
  11.         if (-e $request_filename ) {  
  12.             break;  
  13.         }  
  14.               
  15.         if ( $request_filename ~* \.(js|ico|gif|jpg|jpeg|xml|swf|txt|png|css|html|htm)$ ) {  
  16.             return 404;  
  17.         }  
  18.               
  19.         rewrite .* index.php;  
  20.     }  
  21.     location ~ .*\.php$ {  
  22.         include fastcgi_params;  
  23.         fastcgi_param  SCRIPT_FILENAME    $document_root/index.php;  
  24.         #fastcgi_param REQUEST_URI $document_uri?$query_string;  
  25.         fastcgi_read_timeout 120;  
  26.         fastcgi_pass  127.0.0.1:9000;  
  27.         fastcgi_index index.php;  
  28.     }  
  29. }  

   ./configure

8>【安装libpng】

    }

 

/usr/local/php/bin/phpize

  1. tar -zxvf zlib-1.2.3.tar.gz  
  2. cd zlib-1.2.3  
  3. ./configure  
  4. make  
  5. make install  

fastcgi_param  DOCUMENT_ROOT      $document_root;

建立文件夹

    {

# cp /usr/local/php/etc/php-fpm.conf.default
/usr/local/php/etc/php-fpm.conf

    server_name 192.168.1.101;

  #charset  gb2312;

service php-fpm restart

更改short_open_tag = Off 为short_open_tag = On (开启短格式支持)

extension=”/usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so”

fastcgi_param  SERVER_PORT        $server_port;

eaccelerator.cache_dir=”/tmp/eaccelerator”

   make && make install

http://www.bkjia.com/Linuxjc/556541.htmlwww.bkjia.comtruehttp://www.bkjia.com/Linuxjc/556541.htmlTechArticle环境:操作系统:centos 5.5 32位
服务器地址:192.168.1.101 软件版本:pcre-8.12.zip nginx-1.0.5.tar.gz
mysql-5.1.55.tar.gz php-5.3.6.tar.gz 1 安装pcre unzip pcre-…

   mkdir -p /usr/local/jpeg6/man

  gzip on;

    cd pcre-8.12

  location ~ .*\.(php|php5)?$

events

   mkdir -p /usr/local/jpeg6/man/man1

      include fcgi.conf;

eaccelerator.shm_ttl=”0″

  use epoll;

    index index.html index.htm index.php;

   yum -y install gettext gettext-devel

eaccelerator.filter=””

  E.zlib安装

}

./configure –prefix=/usr/local/php
–with-config-file-path=/usr/local/php/etc –with-gd=/usr/local/gd 
–with-mysql=/usr/local/mysql/
–with-mysqli=/usr/local/mysql/bin/mysql_config
–with-jpeg-dir=/usr/local/jpeg6/ –with-zlib-dir –enable-mbstring=all
–with-pdo-mysql –with-freetype-dir=/usr/local/freetype –with-mcrypt
–enable-sockets –enable-mbstring –enable-fpm

  ./configure –prefix=/usr/local/fontconfig  
–with-freetype-config=/usr/local/freetype/bin/freetype-config

  fastcgi_busy_buffers_size 128k;

   location /nginxstatus {

    location ~ .*\.(js|css)?$

user nginx nginx;

   ./configure –prefix=/usr/local/gzip

   tar -zxvf nginx-1.0.5.tar.gz

mkdir /tmp/eaccelerator

2 安装nginx

  server_names_hash_bucket_size 128;

eaccelerator.enable=”1″

   make && make install

   mkdir -p /usr/local/jpeg6/bin

  tar -zxvf gzip-1.3.5.tar.gz

# chmod 755 /etc/init.d/php-fpm

fastcgi_param  SERVER_PROTOCOL    $server_protocol;

   cd jpeg-6b


相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图