nginx 编译安装方法:

mkdir -p /home/oldboy/tools 

cd /home/oldboy/tools

wget http://nginx.org/download/nginx-1.8.1.tar.gz    ########或者 rz 上传本地的nginx包

2.安装pcre

yum install pcre-devel -y                      ########依赖包

3.安装openssl

yum install openssl-devel                       ########依赖包

4.查看yum源

yum repolist

5.yum源的安装网址

http://mirrors.aliyun.com/help/centos

6.解压nginx压缩包

tar xf nginx                            ########解压nginx包

7.创建用户和目录

useradd -s /sbin/nologin -M www           ########创建用户和目录

mkdir -p /application

8.进入/home/oldboy/tools

cd /home/oldboy/tools

9.进入nginx目录执行脚本

/configure --user=www --group=www --with-http_stub_status_module  --with-http_ssl_module --prefix=/application/nginx-1.8.1 

10.执行编译

make 

11.执行编译安装

make install

12.nginx是否成功安装

/application/nginx-1.8.1/sbin/nginx 

2)浏览器打开web服务器ip   10.0.0.8      ########打开后为nginx页面

13.进入/application目录

14.创建一个软链接

ln -s /application/nginx-1.8.1/ /application/nginx

15.启动nginx

/application/nginx/sbin/nginx

15.检测nginx是否启动

ss -lntup|grep nginx

16.查看nginx的编译信息

/application/nginx/sbin/nginx -V


 ######## /application/nginx/sbin/nginx  -t  检查语法

  ########/application/nginx/sbin/nginx  -s  reload  平滑重启

  

  

  ##Nginx主配置文件

  

  先备份   cp /application/nginx/conf/nginx.conf{,.bak}    ****************************************

cat >/application/nginx/conf/nginx.conf<<EOF

worker_processes  1;


error_log  logs/error.log error;

pid        logs/nginx.pid;


events {

    worker_connections  1024;

}


http {

    include       mime.types;

    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    log_format  main  '\$remote_addr - \$remote_user [\$time_local] "\$request" '

                      '\$status \$body_bytes_sent "\$http_referer" '

                      '"\$http_user_agent" "\$http_x_forwarded_for"';

    include extra/*.conf;

}


EOF


mkdir -p /application/nginx/conf/extra    ############创建一个目录


##www配置文件

cat >/application/nginx/conf/extra/www.conf<<EOF

    server {

        listen       80;

        server_name  etiantian.org;

        rewrite ^/(.*)$ http://www.etiantian.org/$1 permanent;

    }


    server {

        listen       80;

        server_name  www.etiantian.org;

        location / {

            root   html/www;

            index  index.html index.htm;

        }

        access_log logs/www_access.log main;

    }

EOF


##bbs配置文件

cat >/application/nginx/conf/extra/bbs.conf<<EOF

    server {

        listen       80;

        server_name  bbs.etiantian.org;

        location / {

            root   html/bbs;

            index  index.html index.htm;

        }

        access_log logs/bbs_access.log main;

    }

EOF


##blog配置文件

cat >/application/nginx/conf/extra/blog.conf<<EOF

    server {

        listen       80;

        server_name  blog.etiantian.org;

        location / {

            root   html/blog;

            index  index.html index.htm;

        }

        access_log logs/blog_access.log main;

    }

EOF


##status配置文件

cat >/application/nginx/conf/extra/status.conf<<EOF

    server{

        listen  80;

        server_name status.etiantian.org;

        location / {

            stub_status on;

            access_log off;

        }

    }

EOF



mkdir /application/nginx/html/{www,bbs,blog}

echo www > /application/nginx/html/www/index.html

echo bbs > /application/nginx/html/bbs/index.html

echo blog > /application/nginx/html/blog/index.html

使用for循环:

for n in www bbs blog ;do echo web01 $n >/application/nginx/html/$n/index.html ;done

/application/nginx/sbin/nginx -t

/application/nginx/sbin/nginx -s reload

/application/nginx/sbin/nginx -s stop

/application/nginx/sbin/nginx



#####################################       mysql的部署             #############################



mysql安装过程:


1.进入/home/oldboy/tools 执行上传mysql数据库指令并创建一个mysql用户

cd /home/oldboy/tools 

rz -E 选择windows mysql数据库进行上传、

###创建mysql用户####

useradd -s /sbin/nologin  -M mysql

2.去mysql软件存放路径并解压:

cd /home/oldboy/tools

tar xf mysql-5.5.49-linux2.6-x86_64.tar.gz

3.移动解压出来的mysql目录到指定目录

mv mysql-5.6.35-linux-glibc2.5-x86_64 /application/mysql-5.6.35

4.给mysql创建一个软链接

ln -s /application/mysql-5.6.35/ /application/mysql

5.赋予mysql安装目录中mysql软件的所属者

chown -R mysql.mysql /application/mysql/

6.(关键)执行mysql脚本

/application/mysql/scripts/mysql_install_db --basedir=/application/mysql --datadir=/application/mysql/data --user=mysql

7.复制mysql安装目录下的脚本去linux系统服务

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

8.给脚本x执行权限

chmod +x /etc/init.d/mysqld 

9.替换配置文件

sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld

10.覆盖原来的配置文件。

\cp /application/mysql/support-files/my-default.cnf /etc/my.cnf

11.启动mysql服务:

/etc/init.d/mysqld start

12.给mysql植入命令路径

echo 'export PATH=/application/mysql/bin:$PATH' >>/etc/profile

source /etc/profile

which mysql

13.加入开机自启动

chkconfig --add mysqld 

chkconfig mysqld on

14.给mysql root设置用户密码

/application/mysql/bin/mysqladmin -u root password 'oldboy123'

密码为123

15.测试密码是否生效:(登录mysql)

mysql -uroot-poldboy123

16.查询mysql里所有的数据库

show databases;

17.创建数据库

create database oldboy;

18.删除一个数据库

drop database oldboy;

19.查看系统的用户

select uesr,host from mysql.user;