码迷,mamicode.com
首页 > 系统相关 > 详细

[Linux]-LNMP Installation steps

时间:2017-09-16 15:56:57      阅读:232      评论:0      收藏:0      [点我收藏+]

标签:code   p12   logs   glib   module   database   run   netstat   source   

------构建Nginx网站平台-----
一、安装Nginx

1、配置IP地址


(略)

2、编译安装Nginx


[root@localhost ~]# yum -y install pcre-devel zlib-devel
[root@localhost ~]# useradd -M -s /sbin/nologin  nginx
[root@localhost ~]# tar -zxvf nginx-1.6.0.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/nginx-1.6.0/
[root@localhost nginx-1.6.0]# ./configure --prefix=/usr/local/nginx --user=nginx -
group=nginx --with-http_stub_status_module
[root@localhost nginx-1.6.0]# make && make install
[root@localhost ~]# ln -s /usr/local/nginx/sbin/* /usr/local/sbin/
[root@localhost ~]# nginx -t
[root@localhost ~]# nginx
[root@localhost ~]# netstat -anpt | grep 80

3、nginx服务的控制


[root@localhost ~]# killall -s HUP nginx
[root@localhost ~]# killall -s QUIT nginx
[root@localhost ~]# nginx

4、创建nginx服务启动脚本


[root@localhost ~]# vim /etc/init.d/nginx
添加:

#!/bin/bash
#### welcome to nginx  ####
# chkconfig: - 99 20
# description: this is nginx server
PROG="/usr/local/nginx/sbin/nginx"
PIDF="/usr/local/nginx/logs/nginx.pid"
case "$1" in
        start)
           $PROG
           ;;
        stop)
           kill -s QUIT $(cat $PIDF)
           ;;
        restart)
           $0 stop
           $0 start
           ;;
        reload)
           kill -s HUP $(cat $PIDF)
           ;;
        *)
          echo "Usage: $0 {start|stop|restart|status}"
          exit 1
          ;;
        esac
        exit 0

 


[root@localhost ~]# chmod +x  /etc/init.d/nginx
[root@localhost ~]# service nginx stop
[root@localhost ~]# service nginx start
[root@localhost ~]# netstat -anpt | grep 80
[root@localhost ~]# chkconfig --add nginx
[root@localhost ~]# chkconfig nginx on

5、验证:


[root@localhost ~]# firefox http://localhost/ &

二、安装MySQL数据库

 

1、安装前准备:


[root@localhost ~]# rpm -e mysql-server --nodeps
[root@localhost ~]# rpm -e mysql --nodeps
[root@localhost ~]# useradd -M -u 39 -s /sbin/nologin mysql

2、安装cmake软件


[root@localhost ~]# tar -zxvf cmake-2.8.6.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/cmake-2.8.6/
[root@localhost cmake-2.8.6]# ./configure && gmake && gmake install

3、安装mysql软件


[root@localhost ~]# tar -zxvf mysql-5.5.22.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/mysql-5.5.22/
[root@localhost mysql-5.5.22]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql
DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DSYSCONFDIR=/etc
DWITH_EXTRA_CHARSETS=all
[root@localhost mysql-5.5.22]# make && make install
[root@localhost ~]# cp /usr/src/mysql-5.5.22/support-files/my-medium.cnf /etc/my.cnf
[root@localhost ~]# cp /usr/src/mysql-5.5.22/support-files/mysql.server /etc/init.d/mysqld
[root@localhost ~]# chmod +x /etc/init.d/mysqld
[root@localhost ~]# chown -R mysql:mysql /usr/local/mysql
[root@localhost ~]# ln -s /usr/local/mysql/bin/* /usr/local/bin/
[root@localhost ~]# /usr/local/mysql/scripts/mysql_install_db --user=mysql -
basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
[root@localhost ~]# service mysqld restart
[root@localhost ~]# chkconfig --add mysqld
[root@localhost ~]# chkconfig mysqld on
验证:
[root@localhost ~]# mysqladmin -u root password ‘123.com‘
[root@localhost ~]# mysql -u root -p123.com

三、安装PHP

 

1、安装php软件


[root@localhost ~]#yum -y install gd libxml2-devel libjpeg-devel libpng-devel
[root@localhost ~]#tar -zxvf php-5.3.28.tar.gz -C /usr/src/
[root@localhost ~]#cd /usr/src/php-5.3.28/
[root@localhost php-5.3.28]#./configure --prefix=/usr/local/php --with-gd --with-zlib --with
mysql=/usr/local/mysql/ --with-config-file-path=/usr/local/php --enable-mbstring --enable-fpm
--with-jpeg-dir=/usr/lib
[root@localhost ~]#make && make install
注意:编译php时报错:make ZEND_EXTRA_LIBS=‘-liconv‘
[root@localhost ~]# cp /usr/src/php-5.3.28/php.ini-development /usr/local/php/php.ini
[root@localhost ~]# vim /usr/local/php/php.ini
添加:
 

default_charset = "utf-8"
 short_open_tag = On

 


[root@localhost ~]# ln -s /usr/local/php/bin/* /usr/local/bin/
[root@localhost ~]# ln -s /usr/local/php/sbin/* /usr/local/sbin/

2、添加优化模块


[root@localhost ~]# tar -zxvf  ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C
/usr/src/
[root@localhost ~]# cp /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php
5.3.x/ZendGuardLoader.so /usr/local/php/lib/php/
[root@localhost ~]# vim /usr/local/php/php.ini
末尾添加:

zend_extension=/usr/local/php/lib/php/ZendGuardLoader.so
zend_loader.enable=1

 

 

3、创建php-fpm.conf


[root@localhost etc]# useradd -M -u 40 -s /sbin/nologin php
[root@localhost ~]# cd /usr/local/php/etc/
[root@localhost etc]# cp php-fpm.conf.default php-fpm.conf
[root@localhost etc]# vim php-fpm.conf
可以找到的修改:

pid = run/php-fpm.pid
user = php
group = php
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35 

 


[root@localhost etc]# /usr/local/sbin/php-fpm
[root@localhost etc]# netstat -anpt | grep  php-fpm
[root@localhost etc]# cp /usr/src/php-5.3.28/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@localhost etc]# chmod +x /etc/init.d/php-fpm
[root@localhost etc]# service php-fpm stop
[root@localhost etc]# service php-fpm start
[root@localhost etc]# chkconfig --add php-fpm
[root@localhost etc]# chkconfig php-fpm on
[root@www php-5.4.35]#vim /usr/local/nginx/conf/nginx.conf
修改:

location / {
            root   html;
            index  index.php index.html index.htm;
        }
location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;  #!!!
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            include        fastcgi.conf;    #!!!
        }

 


[root@localhost php-5.4.35]#service nginx stop
[root@localhost php-5.4.35]#service nginx start
[root@localhost php-5.4.35]#netstat -anpt | grep 80
验证:

1、验证PHP与Nginx


[root@localhost ~]#vim /usr/local/nginx/html/index1.php
添加:

<?php
phpinfo( );
?>

 


[root@localhost ~]#links http://192.168.1.1/ &

2、验证PHP与MySQL


[root@localhost ~]#vim /usr/local/nginx/html/index2.php
添加:

<?php
$link=mysql_connect(‘localhost‘,‘root‘,‘123.com‘);                
if($link) echo "数据库连接,我觉得OK";                   
mysql_close();                                                   
?>

 


[root@localhost ~]#links http://192.168.1.1/ &

四、部署SKYUC(电影)


1、设置SKYUC网站
[root@localhost ~]#yum -y install unzip
[root@localhost ~]#unzip SKYUC.v3.4.2.SOURCE.zip
[root@localhost ~]# cp -r SKYUC.v3.4.2.SOURCE/wwwroot/ /usr/local/nginx/html/skyuc
[root@localhost ~]# chown -R php:php /usr/local/nginx/html/skyuc/admincp/
[root@localhost ~]# chown -R php:php /usr/local/nginx/html/skyuc/data/
[root@localhost ~]# chown -R php:php /usr/local/nginx/html/skyuc/upload/
[root@localhost ~]# chown -R php:php /usr/local/nginx/html/skyuc/templates/
2、创建数据库
[root@localhost ~]# mysql -u root -p123.com

mysql> create database skyucdb;
mysql> grant all on skyucdb.* to admin@localhost identified by 123.com;

 


3、安装:
[root@localhost ~]# firefox http://192.168.1.1/skyuc/install/index.php &
4、使用:
[root@localhost ~]# firefox http://192.168.1.1/skyuc/
5、后台管理
http://192.168.1.1/SKYUC/admincp/index.php

[Linux]-LNMP Installation steps

标签:code   p12   logs   glib   module   database   run   netstat   source   

原文地址:http://www.cnblogs.com/chenwz/p/7531357.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!