nginx 編譯安裝方法:html
mkdir -p /home/oldboy/tools mysql
cd /home/oldboy/toolslinux
wget http://nginx.org/download/nginx-1.8.1.tar.gz ########或者 rz 上傳本地的nginx包nginx
2.安裝pcreweb
yum install pcre-devel -y ########依賴包sql
3.安裝openssl數據庫
yum install openssl-devel ########依賴包windows
4.查看yum源centos
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;