編譯安裝
1·php下載地址:cn2.php.net
- 1.1、安裝:
tar jxvf php-7.0.5.tar.bz2
./configure --prefix=/app/php --with-config-file-path=/app/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic
- 1.2、報錯1:yum install libxml2-devel
configure error xml2-config not found. please check your libxml2 installation
- 1.3、報錯2:yum install openssl-devel openssl.x86_64
error: Cannot find OpenSSL's <evp.h>
yum install db4-devel
error: jpeglib.h not found.
2·nginx下載地址:nginx.org
- 2.1、安裝:
tar -zvxf nginx-1.9.14.tar.gz
./configure --prefix=/app/nginx/(指定路徑)
- 2.2、報錯1:提示是要你安裝PCRE這個包 直接用yum安裝:yum install -y pcre-devel
./configure: error: the HTTP rewrite module requires the PCRE library.You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option.
- 2.3、報錯2:提示你安裝zlib包:yum install -y zlib-devel
./configure: error: the HTTP gzip module requires the zlib library.You can either disable the module by using --without-http_gzip_module option, or install the zlib library into the system, or build the zlib library statically from the source with nginx by using --with-zlib=<path> option.
Paste_Image.png
- 2.4、關(guān)鍵一步:make && make install
成功
- 2.5、系統(tǒng)配置
/xx/nginx/sbin/nginx -h #幫助
/xx/nginx/sbin/nginx -v #顯示版本
/xx/nginx/sbin/nginx -V #顯示版本和配置信息
/xx/nginx/sbin/nginx -t #測試配置
/xx/nginx/sbin/nginx -q #測試配置時,只輸出錯誤信息
/xx/nginx/sbin/nginx -s stop #停止服務(wù)器
/xx/nginx/sbin/nginx -s reload #重新加載配置
/xx/nginx/sbin/nginx -s quit #不知道,估計和stop差不多
/xx/nginx/sbin/nginx -s reopen #不知道,估計和reload類似
/xx/nginx/sbin/nginx -p /nginx/path #默認(rèn)為/usr/local/nginx(nginx安裝路徑),修改后影響log目錄和html目錄
/xx/nginx/sbin/nginx -c /configure/file/path #配置文件路徑,默認(rèn)為conf/nginx.conf,有多個配置文件時很有用,用這個可以啟動多個不同的nginx監(jiān)聽不同端口
3.nginx 開啟監(jiān)控。
- 3.1、效果:
Paste_Image.png
? Active connections: 對后端發(fā)起的活動連接數(shù).
? Server accepts handled requests: Nginx總共處理了5個連接,成功創(chuàng)建5次握手(證明中間沒有失敗的),總共處理了9個請求.? Reading: Nginx 讀取到客戶端的Header信息數(shù).? Writing: Nginx 返回給客戶端的Header信息數(shù).? Waiting: 開啟keep-alive的情況下,這個值等于 active – (reading + writing),意思就是Nginx已經(jīng)處理完成,正在等候下一次請求指令的駐留連接.}
-
3.2、配置前準(zhǔn)備
首先/xx/nginx/sbin/nginx -V 查看nginx是有該模塊。(yum安裝nginx就自己已經(jīng)安裝完畢,編譯安裝就需要手動指定了。)
Paste_Image.png
如果沒有:
重新使用參數(shù)配置一下:
./configure --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module
make
這里只需要make編譯一下 #不需要用make insyall,否則會覆蓋安裝。
- 3.3、第二步
killall nginx
必須執(zhí)行,否則會出現(xiàn) unknown directive "xxxxx"
mv /xx/nginx/sbin/nginx /xx/nginx/sbin/nginx.bak
cp ./objs/nginx /xx/nginx/sbin/
- 3.4、修改nginx-conf配置
server { #添加如下配置,只要是在server下都行
location /nginx_status { #這個location后面 的/nginx_status 就是你訪問地址的后綴,比如:http://地址/nginx_status 這樣才能看到你所想要的效果
stub_status on;
access_log off;
#加入訪問限制
#allow 60.195.252.106;
#allow 60.195.249.83;
#deny all;
}
- 3.5、訪問:
4·mysql下載地址:yum install mysql-server -y 這里直接用yum安裝。
yum安裝后可能會出現(xiàn)個問題就是無法啟動mysql報錯:ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)
這個時候首先你要查看下
/var/lib/mysql/ 這個目錄下是否有mysql.sock 這個文件。
如果沒有 就在/etc /my.cnf中添加socket=/var/lib/mysql/mysql.sock這段 然后使用/etc/init.d/mysqld start 來啟動。
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
卸載:
清空相關(guān)mysql的所有目錄以及文件rm -rf /usr/lib/mysqlrm -rf /usr/share/mysql
rm -rf /usr/lib/mysql
rm -rf /usr/share/mysql
rm -rf /usr/my.cnf