安裝完libevent之後
[root@wang nginx-1.6.0]# ./configure --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --with-pcre
[root@wang nginx-1.6.0]# make && mkae install
[root@wang nginx-1.6.0]# vim /etc/profile 加入路徑
[root@wang nginx-1.6.0]# . /etc/profile
[root@wang nginx-1.6.0]# nginx -t 測試缺少文件
[root@wang nginx-1.6.0]# mkdir -pv /var/tmp/nginx/client/
[root@wang nginx-1.6.0]# nginx -t
[root@wang nginx-1.6.0]# nginx
[root@wang nginx-1.6.0]# netstat -tupln |grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 27414/nginx
控制腳本寫入
[root@wang mysql]# cd /etc/init.d/
[root@wang init.d]# vim nginxd
[root@wang init.d]# chmod a+x nginxd 加入可執行權限
prog=/usr/local/nginx/sbin/nginx
lockfile=/var/lock/nginx.lock
# description: the nginx web server
# chkconfig: 2345 88 44
. /etc/init.d/functions
start(){
if [ -e $lockfile ];then
echo "the nginx web server is started"
else
echo -n "the nginx web server is starting....."
sleep 1
$prog && echo "ok" && touch $lockfile || echo "failer"
fi
}
stop(){
if [ ! -e $lockfile ];then
echo "the nginx web server is stoped"
else
echo -n "the nginx web server is stoping....."
killproc nginx && echo "ok" && rm -rf $lockfile || echo "failer"
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage: start|stop|restart"
;;
esac
編輯腳本如此,保存退出
進行測試
[root@wang init.d]# pkill -9 nginx 殺死進程
[root@wang init.d]# chkconfig --add nginxd 加入啓動
[root@wang init.d]# chkconfig --list |grep nginx 差看
[root@wang init.d]# service nginxd start
Nginx與php進行結合
[root@wang php-5.5.8]# vim /etc/nginx/nginx.conf
將這些打開修改
[root@wang php-5.5.8]# cd /usr/local/nginx/html/ 進入目錄做個網頁測試
[root@wang html]# vim index.php
[root@wang html]# nginx -t 語法測試
利用源碼進行apache mysql php安裝
先下載mysql源碼,
然後解壓進行安裝
在之前先建個mysql賬號mysql組(有了則不需要建立)
[root@wang Packages]# yum --disablerepo=\* --enablerepo=c6-media install gcc* gcc-c++* autoconf* automake* zlib* libxml* ncurses-devel* libmcrypt* libtool* -y 安裝
[root@wang ~]# groupadd mysql
[root@wang ~]# useradd -r -g mysql mysql
[root@wang ~]# rpm -qa |grep mysql 查看之前安裝 與mysql想關的包,刪除
[root@wang ~]# yum --disablerepo=\* --enablerepo=c6-media remove mysql-libs 軟件包移除
[root@wang ~]# tar -zxvf mysql-5.5.15-linux2.6-i686.tar.gz -C /usr/local 進行解壓
[root@wang ~]# cd /usr/local/src
cmake ./ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DSYSCONFDIR=/etc -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock -DMYSQL_TCP_PORT=3306 -DENABLED_LOCAL_INFILE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci 進行編譯
make && make install 編譯安裝
[root@wang local]# ln -s mysql-5.5.15-linux2.6-i686/ mysql 做個鏈接
[root@wang local]# cd mysql
[root@wang mysql]# vim INSTALL-BINARY 可以查看幫助文件進行安裝
shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
[root@wang mysql]# chown -R mysql:mysql . 改變當前目錄所有者與所有組爲mysql
[root@wang mysql]# ./scripts/mysql_install_db --user=mysql 進行安裝
如果出現這樣的錯誤就需要安裝libaio
[root@wang mysql]# yum --disablerepo=\* --enablerepo=c6-media install libaio libaio-devel -y 進行安裝
[root@wang mysql]# ./scripts/mysql_install_db --user=mysql 重新安裝
[root@wang mysql]# cd data/
[root@wang data]# ll mysql/ 查看mysql目錄下是否有數據,有數據的話表明安裝成功
[root@wang data]# cd .. 進入mysql目錄 、
[root@wang mysql]# chown -R root . 改變當前所有用戶爲管理員
[root@wang mysql]# chown -R mysql data/ 將data用戶改爲mysql
[root@wang mysql]# cp my.cnf /etc/ copy文件到my.cnf
[root@wang mysql]# cd support-files/
[root@wang support-files]# cp -p mysql.server /etc/init.d/mysqld 複製mysql文件到mysqld下
[root@wang support-files]# service mysqld start 測試是否能夠啓動
[root@wang mysql]# vim /etc/profile 修改配置文件
PATH=$PATH:/usr/local/mysql/bin 添加此語句
[root@wang mysql]# . /etc/profile 重新讀取
[root@wang mysql]# mysql 進入mysql
[root@wang mysql]# mysqladmin -u root -p password '123' 設置mysql密碼
[root@wang mysql]# chkconfig --add mysql 啓動系統啓動
[root@wang mysql]# chkconfig mysqld on
[root@wang mysql]# vim /etc/ld.so.conf.d/mysql.conf 編輯mysql配置文件
寫入此路徑
[root@wang mysql]# ldconfig 刷新緩存
[root@wang mysql]# ldconfig -pv |grep mysql 查看結果
[root@wang mysql]# cd /usr/include/ 進入目錄
[root@wang include]# ln -s /usr/local/mysql/include/ mysql 做一個鏈接
[root@wang mysql]# vim /etc/man.config 處理man手冊
MANPATH /usr/local/mysql/man 加入即可
[root@wang mysql]# man mysql 進行測試
Mysql處理成功
Php安裝
需要安裝的包
[root@wang ~]# yum --disablerepo=\* --enablerepo=c6-media install libcm12-devel libjpeg-turbo-devel libpng-devel freetype-devel -y
root@wang ~]# tar -jxvf php-5.5.8.tar.bz2 -C /usr/local/src/ 解壓軟件包
[root@wang ~]# cd /usr/local/src/php-5.5.8/
[root@wang php-5.5.8]# ./configure \
> --prefix=/usr/local/php \
> --enable-fpm \
> --enable-sockets \
> --with-mysql=/usr/local/mysql \
> --with-pdo-mysql=/usr/local/mysql \
> --with-mysqli=/usr/local/mysql/bin/mysql_config \
> --enable-mbstring \
> --enable-xml \
> --with-png-dir \
> --with-gd \
> --with-jpeg-dir \
> --with-zlib \
> --with-freetype-dir \
> --with-config-file-path=/etc/php \
> --with-config-file-scan-dir=/etc/php5.d 配置安裝
出現
需要安裝[root@wang Packages]# yum --disablerepo=\* --enablerepo=c6-media install libjpeg* -y
出現
需要安裝[root@wang Packages]# yum --disablerepo=\* --enablerepo=c6-media install libpng-devel -y
出現
需要安裝 [root@wang Packages]# yum --disablerepo=\* --enablerepo=c6-media install freetype* -y
出現什麼就 rpm -qa |grep 包名 找到包安裝其devel包即可
接下來需要make && make isntall 因爲時間比較長,睡眠的時候可能連接斷開所以需要screen來實現安裝
[root@wang ~]# yum --disablerepo=\* --enablerepo=c6-media install screen -y 安裝screen
[root@wang php-5.5.8]# screen 使用screen
又打開了一個窗口 ctrl+a+d可以離開 screen -ls可以查看
恢復的話 screen -r 編號
[root@wang php-5.5.8]# make && make install 然後進行後臺配置安裝
因爲要把php座位單獨的服務器,所以需要
[root@wang php-5.5.8]# cd sapi/
[root@wang sapi]# cd fpm/
[root@wang fpm]# grep -E "start|stop|restart" * 查找哪個文件是配置文件
[root@wang fpm]# cp init.d.php-fpm /etc/init.d/php-fpm 將配置文件拷貝到php-fpm目錄
[root@wang fpm]# chmod a+x /etc/init.d/php-fpm 給予可執行權限
[root@wang fpm]# service php-fpm start 嘗試啓動下
顯示缺少配置文件
[root@wang fpm]# cd /usr/local/php/
[root@wang php]# cd etc/ 進入安裝目錄
[root@wang etc]# cp php-fpm.conf.default php-fpm.conf 將默認配置文件拷貝成正式的配置文件
[root@wang etc]# service php-fpm start 再次重啓下
[root@wang etc]# netstat -tupln|grep php
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 8885/php-fpm
查找php-fpm進程是9000.端口說明正確安裝
[root@wang etc]# chkconfig --add php-fpm 加入指定啓動陣列
[root@wang etc]# chkconfig php-fpm on 加入開機啓動
[root@wang etc]# mkdir /etc/php /etc/php5.d 創建2個目錄
[root@wang etc]# cd /usr/local/src/php-5.5.8/ 進入php源碼目錄
[root@wang php-5.5.8]# ll |grep ini 查找是否有與ini相關的文件
[root@wang php-5.5.8]# cp php.ini-production /etc/php/php.ini 將文件拷貝到php目錄下
[root@wang php-5.5.8]# service php-fpm restart 重新啓動php-fpm
總測試:
[root@wang html]# service iptables stop
[root@wang html]# setenforce 0
成功訪問
查看能否訪問數據庫
[root@wang html]# vim index.php 修改網頁文件
成功
進行壓力測試
[root@wang html]# vim index.php 修改網頁文件
[root@wang html]# yum --disablerepo=\* --enablerepo=c6-media install httpd-tools -y 安裝壓力測試工具
[root@wang html]# ab -n 10000 -c 1000 http://127.0.0.1/index.php
使用xcache實現緩存,加大抗壓能力
[root@wang ~]# tar -zxvf xcache-3.1.0.tar.gz -C /usr/local/src/
[root@wang ~]# cd /usr/local/src/xcache-3.1.0/
[root@wang xcache-3.1.0]# /usr/local/php/bin/phpize 使用php工具實現php擴展
[root@wang xcache-3.1.0]# ./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config 進行配置
[root@wang xcache-3.1.0]# make && make install 配置安裝
[root@wang xcache-3.1.0]# cp /usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/xcache.so /etc/php5.d/ 拷貝模塊
[root@wang xcache-3.1.0]# cp xcache.ini /etc/php5.d/
[root@wang xcache-3.1.0]# service php-fpm restart 重啓php
有了xcache模塊
在進行壓力測試
[root@wang html]# ab -n 10000 -c 1000 http://127.0.0.1/index.php
速度明顯加快