今晚心血來潮,來加加班,想起還有一個博客,索性來寫寫,步驟會比較清楚,畢竟我有輕微強迫症... 聲明下,用的是centos6 的系統環境,預設root許可權,部署過程中iptables關閉,之後根據需求配置策略,selinux也是預設關閉的, 關閉iptables : /etc/init.d/ipta ...
今晚心血來潮,來加加班,想起還有一個博客,索性來寫寫,步驟會比較清楚,畢竟我有輕微強迫症... 聲明下,用的是centos6 的系統環境,預設root許可權,部署過程中iptables關閉,之後根據需求配置策略,selinux也是預設關閉的,
關閉iptables : /etc/init.d/iptables stop, 先暫時關閉selinux:setenforce 0
首先是Lnmp環境,畢竟zabbix_server需要php和資料庫支持,先放軟體包的下載地址,全部可以通過wget 進行下載
php http://cn2.php.net/distributions/php-5.6.32.tar.gz
mysql https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.38.tar.gz
nginx http://nginx.org/download/nginx-1.10.3.tar.gz
軟體下載完先解壓,tar zxf php-5.6.32.tar.gz 、 tar zxf mysql-5.6.38.tar.gz 、 tar zxf nginx-1.10.3.tar.gz 、
然後yum一波依賴,我一般用得aliyun的yum,下麵三行代碼看需求,線上環境的話具體對待,
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
yum clean all && yum makecache
開始yum,
yum -y install automake autoconf cmake gcc gcc-c++ openssl openssl-devel pcre pcre-devel libaio libaio-devel ncurses ncurses-devel net-snmp-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libpng libpng-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel curl curl-devel gdbm-devel db4-devel libXpm-devel libX11-devel gd-devel
先nginx吧:
groupadd nginx
useradd nginx -g nginx -M -s /sbin/nologin
cd nginx-1.10.3/
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-pcre --user=nginx --group=nginx
make && make install
然後是mysql: [PS:mysql是預設安裝位位置/usr/localmysql,數據的存貯位置為 /data/mysql]
groupadd mysql
useradd mysql -g mysql -M -s /sbin/nologin
mkdir -p /data/mysql
chown -R mysql.mysql /data/mysql
cd mysql-5.6.38/
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DWITH_INNOBASE_STORAGE_engine=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DMYSQL_DATADIR=/data/mysql \
-DMYSQL_TCP_PORT=3306 \
-DENABLE_DOWNLOADS=1
make && make install
cp /usr/local/mysql/support-files/mysql.server /etc/inint.d/mysql
chmod 755 /etc/init.d/mysql
初始化資料庫先:
/usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/data/mysql
cp /usr/local/mysql/my.cnf /etc/my.cnf
然後修改 /etc/my.cnf 中的
basedir = /usr/local/mysql
datadir = /data/mysql
user = mysql
修改完保存退出
/etc/init.d/mysql start
如果不出意外,mysql就正常啟動了
最後是php。
cd php-5.6.32/
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-bz2 --with-curl --enable-sockets
--with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --with-iconv-dir --enable-mbstring
--enable-calendar --with-gettext --with-libxml-dir --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-
mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
make && make install
配置php:
cp php.ini-production /usr/local/php/etc/php.ini
mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod 755 /etc/init.d/php-fpm
修改nginx支持php,把下麵7行代碼加入nginx的配置文件的,server段裡面 ,然後保存退出。
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
啟動服務:
/usr/local/nginx/sbin/nginx
/etc/init.d/pfp-fpm start
放置php探針 :
echo -e "<?php \nphpinfo();" > /usr/local/nginx/html/info.php
curl 127.0.0.1/info.php |grep php-fpm
如果有類似於 <td class="e">php-fpm </td> 這樣的輸出,證明已經支持了。
lnmp環境就已經搭好了