您好,登錄后才能下訂單哦!
nginx搭建命令
cd /home/oldboy/tools 安裝存放軟件包路徑
yum install openssl openssl-devel -y 安裝Nginx所需的庫、和加密協議
yum install pcre pcre-devel -y 安裝Nginx所需的庫、和加密協議
rpm -qa openssl-devel pcre-devel openssl openssl-devel 檢查是否安裝好
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz 下載軟件包
useradd www -s /sbin/nologin -M 創建用戶
tar xf nginx-1.6.3.tar.gz 解壓軟件
cd nginx-1.6.3
./configure --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --prefix=/application/nginx-1.6.3/ 編譯安裝
make
make install
ln -s /application/nginx-1.6.3/ /application/nginx
/application/nginx/sbin/nginx 開啟服務
ps -ef|grep nginx 檢查
創建網頁目錄
[root@web02 html]# mkdir {www,bbs,blog} -p
[root@web02 www]# echo "www.etiantian.org" >index.html
修改主配置文件
添加access日志及虛擬主機目錄
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
#nginx vhosts config
include extra/www.conf;
include extra/bbs.conf;
include extra/blog.conf;
創建存放虛擬主機的目錄
[root@web02 conf]# mkdir extra
[root@web02 extra]# touch www.conf
[root@web02 extra]# touch bbs.conf
[root@web02 extra]# touch blog.conf
修改每個虛擬主機的conf目錄
server {
listen 80;
server_name www.etiantian.org etiantian.org;
location / {
root html/www;
index index.html index.htm;
}
access_log logs/access_www.log main;
}
設置開機啟動
[root@web02 oldboy]# echo "/application/nginx/sbin/nginx " >>/etc/rc.local
[root@web02 oldboy]# tail -1 /etc/rc.local
/application/nginx/sbin/nginx
MySQL搭建命令
安裝MySQL
上傳MySQL
ls mysql-5.5.49-linux2.6-x86_64.tar.gz
tar xf mysql-5.5.49-linux2.6-x86_64.tar.gz
mkdir /application -p
mv mysql-5.5.49-linux2.6-x86_64 /application/mysql-5.5.49
ln -s /application/mysql-5.5.49 /application/mysql
useradd mysql -s /sbin/nologin -M 創建用戶和授權目錄
chown -R mysql.mysql /application/mysql/ 創建用戶和授權目錄
cd /application/mysql
./scripts/mysql_install_db --user=mysql --basedir=/application/mysql --datadir=/application/mysql/data/ 初始化時數據庫
ll data/
\cp support-files/my-small.cnf /etc/my.cnf 創建基本需求
cp support-files/mysql.server /etc/init.d/mysqld 創建基本需求
chmod +x /etc/init.d/mysqld 給執行權限
sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe /etc/init.d/mysqld 修改配置文件
/etc/init.d/mysqld start 開啟服務、
netstat -lntup|grep mysql 檢查
echo "PATH="/application/mysql/bin:$PATH"" >>/etc/profile
chkconfig --add mysqld 開啟服務
chkconfig mysqld on 開啟服務
cp -a /application/mysql/bin/* /usr/local/sbin/
ln -s /application/mysql/bin/* /usr/local/sbin/
mysql
1、安裝PHP基礎庫
yum install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel -y
yum install freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel libxslt-devel -y
rpm -qa zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel libxslt-devel
需要先安裝支持的軟件包
cd /home/oldboy/tools
wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make install
cd ../
2、PHP相關擴展庫
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum -y install libmcrypt-devel
yum -y install mhash
yum -y install mcrypt
rpm -qa libmcrypt-devel mhash mcrypt
解壓php安裝包,編輯
上傳PHP包
tar xf php-5.5.32.tar.gz 解壓php安裝包
./configure \
--prefix=/application/php5.5.32 \
--with-mysql=/application/mysql/ \
--with-pdo-mysql=mysqlnd \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--enable-short-tags \
--enable-static \
--with-xsl \
--with-fpm-user=www \
--with-fpm-group=www \
--enable-ftp \
--enable-opcache=no
ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
touch ext/phar/phar.phar
make
make install
ln -s /application/php5.5.32/ /application/php
ls /application/php/
cp php.ini-production /application/php/lib/php.ini
配置php解析文件
cp php.ini-production /application/php/lib/php.ini
配置php-fpm配置文件
cp php-fpm.conf.default php-fpm.conf
啟動php-fpm
/application/php/sbin/php-fpm
lsof -i :9000
ps -ef|grep php-fpm
root@web01 extra]# cat blog.conf
server {
listen 80;
server_name blog.etiantian.org;
location / {
root html/blog;
index index.html index.htm;
}
location ~ .*\.(php|php5)?$ {
root html/blog;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi.conf;
}
}
[root@web01 extra]# ../../sbin/nginx -t
nginx: the configuration file /application/nginx-1.6.3//conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.3//conf/nginx.conf test is successful
[root@web01 extra]# ../../sbin/nginx -s reload
[root@web01 blog]# cat test_mysql.php
<?php
$link_id=mysql_connect('localhost','root','oldboy123') or mysql_error();
if($link_id){
echo "mysql successful by oldboy !";
}else{
echo mysql_error();
}
?>
搭建blog命令
mysql -uroot -poldboy123
create database wordpress;
show databases;
grant all on wordpress.* to wordpress@'localhost' identified by '123456';
select user,host from mysql.user;
show grants for wordpress@'localhost';
flush privileges;
下載博客安裝
wget https://cn.wordpress.org/wordpress-4.5.1-zh_CN.tar.gz
ll
tar xf wordpress-4.5.1-zh_CN.tar.gz
ls wordpress
cp -a wordpress/* /application/nginx/html/blog/
ls /application/nginx/html/blog/
chown -R www.www /application/nginx/html/blog/
ls /application/nginx/html/blog/
ls /application/nginx/html/blog/ -l
history
分離命令
wed命令
mysqldump -uroot -poldboy123 wordpress -B |gzip>bak.sql.gz
scp bak.sql.gz root@10.0.0.51:/tmp
數據庫MySQL命令
cd /tmp
gzip xf bak.sql.tar.gz
mysql -uroot -poldboy123 -e "show databases like 'wordpress';"
mysql -uroot -poldboy123 -e "use wordpress;show tables;"
mysql -uroot -poldboy123
grant all on wordpress.* to wordpress@'172.16.1.%' identified by '123456';
flush privileges;
select user,host from mysql.user;
更改.8配置文件 wp-config.php
32 define('DB_HOST', '172.16.1.51');
關閉本地數據庫
/etc/init.d/mysqld stop
chkconfig mysqld off
成功。
2、將blog的資源文件遷移到NFS
[root@web01 blog]# tree wp-content/uploads/
資源目錄為:wp-content/uploads/
nfs命令
echo "/uploads 172.16.1.0/24(rw,sync)" /etc/exports
MySQL數據庫命令
mount -t nfs 172.16.1.31:/uploads /application/nginx/html/blog/
根據老男孩老師的講解,和實際操作搭建出來
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。