lnmp环境搭建

php 2.4  mysql 5.5  nignx 1.4.7

   一、安装mysql

yum install  gcc-c++ cmake ncurses-devel bison perl -y

useradd  -s  /sbin/nologin  mysql 

mkdir  -p  /data/mysql

chown  -R  mysql.mysql  /data/mysql

tar -zxvf mysql-5.5.44.tar.gz;cd  mysql-5.5.44

cmake  -DCMAKE_INSTALL_PREFIX=/usr/local/mysql

-DMYSQL_DATADIR=/data/mysql

 -DWITH_MYISAM_STORAGE_ENGINE=1  

     -DWITH_INNOBASE_STORAGE_ENGINE=1  

-DWITH_READLINE=1 

-DMYSQL_TCP_PORT=3306 

     -DENABLED_LOCAL_INFILE=1 

-DWITH_PARTITION_STORAGE_ENGINE=1  

-DEXTRA_CHARSETS=all  

-DDEFAULT_CHARSET=utf8  

      -DDEFAULT_COLLATION=utf8_general_ci

-DWITH_DEBUG=0 

-DMYSQL_USER=mysql 

-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock

       make -j2 && make install

                         

cp  support-files/my-medium.cnf   /etc/my.cnf

cp support-files/mysql.server  /etc/init.d/mysqld

chmod  755  /etc/init.d/mysqld

/usr/local/mysql/scripts/mysql_install_db  --basedir=/usr/local/mysql--datadir=/data/mysql  --user=mysql

/etc/init.d/mysqld  start

chkconfig --add mysqld

echo "PATH=$PATH:/usr/local/mysql/bin">>/etc/profile

source  /etc/profile

 

     二、安装php

cd   php-5.4

yum  install  -y libxml2-devel  libcurl-devel  openjpeg-devel  libjpeg-turbo-devel libpng-devel  freetype-devel

./configure  --prefix=/usr/local/php  --enable-fpm  --enable-debug --with-gd --with-jpeg-dir --with-png-dir  --with-freetype-dir  --enable-mbstring  --with-curl --with-mysql=/usr/local/mysql

make   &&  make  install

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

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

cp php.ini.development  /usr/local/php/lib/php.ini

/etc/init.d/php-fpm   ##启动php-fpm


      三、安装nginx

下载nginx  wget  http://nginx.org/download/nginx-1.4.7.tar.gz

tar �Czxvf nginx-1.4.7.tar.gz

cd nginx-1.4.7

yum install  pcre-devel  -y 安装pcre库,支持rewrite 重写

注:安装源码的pcre时,指定pcre路径为解压的路径,而不是编译后的路径,否则会报错

yum install  -y openssl-devel

useradd -s /sbin/nologing   -M  www

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

make  &&  make  install

 

      四、nginx整合php

编辑nginx配置文件 nginx.conf,在server 字段里加入:

location ~ \.php$ {

           root           html;

           fastcgi_pass   127.0.0.1:9000;

           fastcgi_index  index.php;

           fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;

           include        fastcgi_params;

        }


wKiom1XddLajZqOxAABZLnidG90754.jpg

改为:

wKioL1XddtzgFrPSAABau-s_j3g291.jpg


你可能感兴趣的:(环境搭建,LNMP)