1.搭建一個簡單web即dns服務器
10.10.54.61
[root@gyf html]# vim /etc/named.conf
options {
listen-on port 53 {any; };
listen-on-v6 port 53 { ::1; };
directory "/var/named";
dump-file "/var/named/data/cache_dump.db";
statistics-file "/var/named/data/named_stats.txt";
memstatistics-file "/var/named/data/named_mem_stats.txt";
allow-query {any; };
recursion yes;
zone "." IN {
type hint;
file "named.ca";
};
zone "ssr.com" IN {
type master;
file "named.ssr.com";
};
zone "54.10.10.in-addr.arpa" IN {
type master;
file "named.10.10.54";
[root@gyf html]# /etc/init.d/named restart
[root@gyf named]# vim /var/named/named.ssr.com
$TTL 86400
@ IN SOA ssr.com. root (
2014010802
1H
2M
1W
1D
);
@ IN NS ssr.com.
ssr.com. IN A 10.10.54.61
@ IN MX 3 master.ssr.com #郵箱服務器
master.ssr.com. IN A 10.10.54.61
slaver IN A 10.10.54.64
svn IN A 10.10.54.64
ftp IN CNAME master.ssr.com.
www.ssr.com. IN CNAME ssr.com
bbs.ssr.comIN IN CNAME ssr.com
[root@gyf named]# vim /var/named/named.10.10.54
$TTL 86400
@ IN SOA ssr.com. root (
2014010802
1H
2M
1W
1D
);
@ IN NS ssr.com.
61 IN PTR ssr.com.
61 IN PTR master.ssr.com.
61 IN PTR ftp.ssr.com.
64 IN PTR slaver.ssr.com.
64 IN PTR svn.ssr.com.
61 IN PTR www.ssr.com.
61 IN PTR bbs.ssr.com.
//在本機上解析測試
[root@gyf ~]# dig ssr.com @127.0.0.1
[root@gyf ~]# dig -x 10.10.54.61 @127.0.0.1
在10.10.54.60下測試
vim /etc/resolv.conf
nameserver 10.10.54.61
shell> dig bbs.ssr.com
####################
源碼編譯nginx1.4.5
1.下載
[root@gyf soft]#wget http://nginx.org/download/nginx-1.4.5.tar.gz
[root@gyf soft]# tar xvf nginx-1.4.5.tar.gz
2.編譯
[root@gyf nginx-1.4.5]# ./configure --prefix=/usr/local/nginx --user=apache --group=apache --with-http_stub_status_module --with-http_gzip_static_module --with-http_ssl_module
///
--with-http_stub_status_module enable ngx_http_stub_status_module ---支持監控
--with-http_gzip_static_module enable ngx_http_gzip_static_module ---支持壓縮
3.安裝
[root@gyf nginx-1.4.5]# make && make install
4.啓動
[root@gyf conf]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nginx: [emerg] getpwnam("apache") failed
[root@gyf conf]# useradd apache
[root@gyf conf]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
[root@gyf conf]# netstat -ntlp|grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 1572/httpd
[root@gyf conf]# apachectl stop
[root@gyf conf]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
5.關閉:給父進程發送一個TERM信號,試圖殺死它和它的子進程。
[root@s01 logs]# cat /usr/local/nginx/logs/nginx.pid | xargs kill -TERM
6.重啓
[root@s01 logs]# cat /usr/local/nginx/logs/nginx.pid | xargs kill -HUP
HUP 重啓
TERM,INT 快速中止
USR1 從新打開日誌文件,用於日誌切割
USR2 平滑升級可執行程序
QUIT 從容關閉
WINCH 從容關閉工做進程
//測試配置文件
[root@s01 html]# /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
//nginx配置文件格式:
user apache apache;
worker_processes 2; ---cpu核-1
....
event{}
http{
....
upstream {}
server{}
}
############################
編譯安裝mysql-5.5.30.tar.gz
1.安裝依賴文件
yum install -y cmake.x86_64
2.建立mysql用戶
有:
[root@tech03 softs]# cat /etc/passwd|grep mysql
mysql:x:501:501::/home/mysql:/sbin/nologin
沒有時:
[root@gyf mysql-5.5.30]# groupadd mysql
[root@gyf mysql-5.5.30]# useradd -g mysql mysql
3.編譯參數cmake編譯
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \......自動建立的權限是root
-DMYSQL_DATADIR=/data/dbdata \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock \
-DMYSQL_TCP_PORT=3306 \
-DENABLED_LOCAL_INFILE=1 \
-DWITH_EXTRA_CHARSETS=all \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_SSL=yes
加-D表示當前路徑
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql:MySQL安裝目錄,推薦安裝到此目錄
-DWITH_INNOBASE_STORAGE_ENGINE=1:安裝InnoDB存儲引擎
-DWITH_MYISAM_STORAGE_ENGINE=1:安裝MyISAM存儲引擎
-DWITH_MEMORY_STORAGE_ENGINE=1:安裝內存存儲引擎
-DDEFAULT_CHARSET=utf8:默認編碼設置成utf8
-DDEFAULT_COLLATION=utf8_general_ci:默然校驗規則是utf8_general_ci
-DWITH_EXTRA_CHARSETS=all:支持其餘全部的編碼
-DMYSQL_TCP_PORT=3306:MySQL端口指定爲3306
-DMYSQL_UNIX_ADDR=/tmp/mysql.sock:指定SOCK文件
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
-- MySQL 5.5.30
-- Packaging as: mysql-5.5.30-Linux-x86_64
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH)
CMake Error at cmake/readline.cmake:83 (MESSAGE):
Curses library not found. Please install appropriate package,
清除緩存:rm CMakeCache.txt。。。。編譯後生成的文件
solution:
[root@tech2 mysql-5.1.70]# yum install ncurses-devel.x86_64 -y
[root@tech2 mysql-5.1.70]# yum install bision.x86_64 -y
CMake Error: CMAKE_CXX_COMPILER not set, after EnableLanguage
solution:
yum -y install gcc-c++.x86_64 compat-gcc-34.x86_64
rm CMakeCache.txt
make
make install
4
##.建立目錄
mkdir -p /data/dbdata
chown mysql.mysql /usr/local/mysql -R
級聯修改目錄用戶和用戶組爲mysql
chown mysql.mysql /data/dbdata -R
5.複製mysql配置文件my.cnf
---window配置文件my.ini
cp /soft/mysql-5.5.30/support-files/my-large.cnf /etc/my.cnf
6.複製啓動腳本
cp /soft/mysql-5.5.30/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
7.初始化數據庫文件
[root@tech03 dbdata]# /usr/local/mysql/scripts/mysql_install_db --user=mysql
FATAL ERROR: Could not find ./bin/my_print_defaults
If you compiled from source, you need to run 'make install' to
copy the software into the correct location ready for operation.
If you are using a binary release, you must either be at the top
level of the extracted archive, or pass the --basedir option
pointing to that location.
解決方式:
/usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql/
啓動數據庫
[root@gyf dbdata]# /etc/init.d/mysqld start
err:
Starting MySQL.. ERROR! The server quit without updating PID file (/data/dbdata/gyf.pid).
[root@learn data]# /etc/init.d/mysqld restart
ERROR! MySQL server PID file could not be found!
Starting MySQL.. ERROR! The server quit without updating PID file (/data/dbdata/learn.pid).
[root@learn data]# netstat -ntulp
[root@learn data]# kill -9 1243
[root@gyf dbdata]# vim /etc/my.cnf
[mysqld]
datadir=/data/dbdata
#skip-locking
long_query_time=0.5
slow_query_log
lower_case_table_names=1
[mysql]
prompt = \\u@\\d \\R:\\m>
//在/etc/my.cnf配置文件添加:
[mysqld]
innodb_file_per_table=1
skip-name-resolve
long_query_time=0.5
slow_query_log
lower_case_table_names=1
[mysql]
prompt = \\u@\\d \\R:\\m>
8.修改用戶登陸密碼
/usr/local/mysql/bin/mysqladmin -u root password 'aaa12345'
#################################
編譯 php-5.4.25.tar.gz
1.下載 php-5.4.25.tar.gz
[root@gyf soft]# wget http://cn2.php.net/distributions/php-5.4.25.tar.gz
2.下載安裝libmcrypt php模塊
[root@gyf soft]# wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download
[root@gyf soft]# tar xvf libmcrypt-2.5.8.tar.gz
[root@gyf soft]# cd libmcrypt-2.5.7
[root@gyf soft]# ./configure
[root@gyf soft]# make
[root@gyf php-5.4.25]# cd pear/
[root@gyf pear]# cp /soft/go-pear.php install-pear-nozlib.phar
[root@gyf php-5.4.25]# make install
3.下載mhash php模塊
wget http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2/download
[root@gyf soft]# tar -jxvf mhash-0.9.9.9.tar.bz2
[root@gyf soft]# ./configure
[root@gyf soft]# make && make install
4.下載mcrypt php依賴模塊
[root@gyf soft]#wget http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download
[root@gyf soft]#tar -zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8
./configure
make
錯誤:
configure: error: *** libmcrypt was not found www.2cto.com
爲了的到mcrypt.so庫文件,前後安裝編譯了mhash和libmcrypt,可是到最後編譯mcrypt時報錯:
最後發現是由於環境變量的問題,gcc編譯的時候根據自身定義的變量尋找相關函數庫等文件,
libmcrypt也是剛安裝的,在變量中沒有定義出來,因此手動添加:
[root@gyf mcrypt-2.6.8]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
再次編譯便可。
[root@gyf mcrypt-2.6.8]# make
[root@gyf mcrypt-2.6.8]# make install
安裝依賴:
yum –y install libxml2-devel.x86_64 libcurl-devel.x86_64 libpng-devel.x86_64 openldap-devel.x86_64
5.編譯php
咱們使用nginx調用php的時候使用fpm的方式,在php 5.4中加入了對php-fpm的支持,因此就不須要打補丁了.安裝PHP:
[root@gyf soft]# cd php-5.4.25
[root@gyf php-5.4.25]# vim INSTALL
1. gunzip apache_xxx.tar.gz
2. tar -xvf apache_xxx.tar
3. gunzip php-xxx.tar.gz
4. tar -xvf php-xxx.tar
5. cd apache_xxx
6. ./configure --prefix=/www --enable-module=so
7. make
8. make install
9. cd ../php-xxx
nginx編譯
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-zlib --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --with-curl --with-curlwrappers --enable-fpm --enable-fastcgi --with-mcrypt --with-gd --with-openssl --with-mhash --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc -enable-zip --enable-soap
錯誤:configure: error: Cannot find ldap libraries in /usr/lib
cp -frp /usr/lib64/libldap* /usr/lib/
make
error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory
解決方法:
[root@gyf php-5.4.25]# find / -name 'libmysqlclient.so.18'
/usr/local/mysql/lib/libmysqlclient.so.18
[root@gyf php-5.4.25]# vim /etc/ld.so.conf
/usr/local/mysql/lib
[root@gyf php-5.4.25]# ldconfig
從新編譯
chmod: cannot access `ext/phar/phar.phar': No such file or directory
make: [ext/phar/phar.phar] Error 1 (ignored)
[root@gyf php-5.4.25]# cd ext/phar/
[root@gyf phar]# cp ./phar.php ./phar.phar
從新編譯
[root@gyf php-5.4.25]# cd pear/
[root@gyf pear]# cp /soft/go-pear.php install-pear-nozlib.phar
make install
6.爲php建立配置文件
[root@gyf php-5.4.25]# cp php.ini-production /usr/local/php/php.ini
7.啓動php-fpm
[root@gyf php-5.4.25]# /usr/local/php/sbin/php-fpm
或者
[root@gyf php-5.4.25]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[root@gyf init.d]# chmod +x php-fpm
[root@gyf init.d]# chkconfig --add php-fpm
[root@gyf init.d]# /etc/init.d/php-fpm start
8.配置php-fpm
[root@gyf php-5.4.25]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[root@gyf php-5.4.25]# cd /usr/local/php/etc/php-fpm.conf
:25 pid = run/php-fpm.pid
:148 user = nginx
group = nginx
:159 listen = 127.0.0.1:9000
9.修改nginx配置文件
user nginx nginx;
server {
listen 80;
server_name bbs.ssr.com;
charset utf-8;
access_log logs/bbs.access.log main;
root /var/www/bbs;
location / {
index index.html index.php;
}
ssl off;
# ssl_certificate /usr/local/nginx/conf/.ssl/server.crt;
# ssl_certificate_key /usr/local/nginx/conf/.ssl/server.key;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
include fastcgi.conf;
}
10.測試
[root@gyf conf]# /etc/init.d/nginx test
nginx: [emerg] getpwnam("nginx") failed in /usr/local/nginx/conf/nginx.conf:2
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed
nginx test is error!
[root@gyf conf]# useradd nginx
[root@gyf conf]# /etc/init.d/nginx restart
11.建網站
[root@gyf conf]# mkdir /var/www/bbs
[root@gyf bbs]# unzip Discuz_X3.0_SC_UTF8.zip
[root@gyf bbs]# ls
Discuz_X3.0_SC_UTF8.zip index.html php.php readme upload utility
[root@gyf www]# chown -R nginx.nginx bbs
12.測試網站
[root@gyf bbs]# /etc/init.d/php-fpm restart
[root@gyf bbs]# /etc/init.d/nginx restart
[root@gyf bbs]# /etc/init.d/mysqld restart
在ubuntu10.10.54.60下輸入
http://bbs.ssr.com/upload/
13.受權
root@(none) 21:11>grant all on *.* to root@10.10.54.60 identified by 'aaa12345';
root@(none) 21:12>flush privileges;
php