本安装内容,基本参考:https://www.cnblogs.com/xuanzhi201111/p/4172604.html
一、安装必备的开发包
yum -y install ntp vim-enhanced gcc gcc-c++ flex bison autoconf automake bzip2-devel ncurses-devel zlib-devel libjpeg-devel libpng-devel libtiff-devel freetype-devel libXpm-devel gettext-devel pam-devel libtool libtool-ltdl openssl openssl-devel fontconfig-devel libxml2-devel curl-devel libicu libicu-devel libmcrypt libmcrypt-devel libmhash libmhash-devel
二、apache安装,版本要2.2及以上
cd /usr/local/src
wget http://archive.apache.org/dist/httpd/httpd-2.2.19.tar.gz
tar xvf httpd-2.2.19.tar.gz
cd httpd-2.2.19
./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-mods-shared=most --sysconfdir=/etc/httpd
make && make install
配置文件在/etc/httpd 目录下,如本机有nginx,则应该修改apache的端口。
添加开机启动:
chkconfig --add httpd
chkconfig httpd on
三、进行PHP安装
首先安装libmcrypt
yum install libmcrypt libmcrypt-devel mcrypt mhash
安装php
wget http://cn2.php.net/distributions/php-5.5.19.tar.gz
tar zxf php-5.5.19.tar.gz
cd php-5.5.19
./configure --prefix=/usr/local/php --mandir=/usr/local/share/man --infodir=/usr/local/share/info --with-apxs2=/usr/local/apache/bin/apxs --enable-cgi --with-mysql=/usr/local/mysql/ --with-config-file-path=/usr/local/php/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --enable-zip --enable-sqlite-utf8 -enable-sockets --enable-soap --enable-pcntl --enable-mbstring --enable-intl --enable-calendar --enable-bcmath --enable-exif --with-mcrypt --with-mhash --with-gd --with-png-dir --with-jpeg-dir --with-freetype-dir --with-libxml-dir --with-curl --with-curlwrappers --with-zlib --with-openssl --with-kerberos=shared --with-gettext=shared --with-xmlrpc=shared
make && make install
#复制配置文件
cp php.ini-production /usr/local/php/etc/php.ini
四、编辑apache配置文件
vi /etc/httpd/httpd.conf
在该行AddType application/x-gzip .gz .tgz,下面添加
AddType application/x-httpd-php .php
将 DirectoryIndex index.html 修改成
DirectoryIndex index.html index.htm index.php
重启apache
/usr/local/apache/bin/apachectl restart
五、MySQL-python
wget http://sourceforge.net/projects/mysql-python/files/mysql-python-test/1.2.3b1/MySQL-python-1.2.3b1.tar.gz/download
六、安装Python
安装bzip2
yum -y install bzip2
#下载
wget http://www.python.org/ftp/python/2.7.2/Python-2.7.2.tar.bz2
#解压
tar -xjf Python-2.7.2.tar.bz2
cd Python-2.7.2
./configure --prefix=/usr/local/Python2.7 --enable-shared
make && make install
mv /usr/bin/python /usr/bin/pythonbak
ln -sf /usr/local/Python2.7/bin/python /usr/bin/python
#可执行,显示版本,则Python安装成功
python -V
注意:
如果python升级到2.7以后出现yum无法使用的情况,错误为No module named yum
#打开文件
vim /usr/bin/yum
#修改版本
#!/usr/bin/python2.6
七、安装MySQLdb for python
cd /usr/local/src/MySQL-python-1.2.3b1
vi site.cfg
#设置mysql_config
mysql_config=/usr/local/mysql/bin/mysql_config
添加完再执行python setup.py
python setup.py build
python setup.py install
八、安装MySQL MTOP系统
创建数据库及账号
create database mysqlmtop default character set utf8;
grant select,insert,update,delete,create,drop on mysqlmtop.* to 'mtop_user'@'localhost' identified by 'password';
flush privileges;
往mysqlmtop 导入数据
source mysqlmtop.sql
source mysqlmtop_data.sql
创建monitor用户
grant select,super,process on *.* to 'monitor'@'localhost' identified by 'monitor';
flush privileges;
下载mysqlmtop2.2
#移动到/usr/local下
mv /usr/local/src/mysqlmtop2.2 /usr/local/mysqlmtop
修改config.ini配置
vi /usr/local/mysqlmtop/mysqlmtop/etc/config.ini
host="localhost"
port=3306
user="monitor"
passwd="monitor"
dbname="mysqlmtop"
授予可执行文件执行权限
cd /usr/local/mysqlmtop/mysqlmtop
chmod +x *.py
chmod +x *.sh
chmod +x mtopctl
ln -s /usr/local/mysqlmtop/mysqlmtop/mtopctl /usr/local/bin/
ln -s /usr/local/mysql-5.7.25-linux-glibc2.12-x86_64/lib/libmysqlclient.so.20 /usr/lib64/libmysqlclient.so.20
测试数据库
./test_mysql.py
#错误:_mysql_exceptions.OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")
ln -s /usr/local/mysql-5.7.25-linux-glibc2.12-x86_64/mysql.sock /tmp/mysql.sock
#如果出现以下字符,则表明成功
MySQLDB OK!
修改 mtopctl
cd /usr/local/mysqlmtop/mysqlmtop
vi mtopctl
basedir=/usr/local/mysqlmtop/mysqlmtop
#启动监控
mtopctl start
mtopctl --help
九、安装WEB管理界面
把/usr/local/mysqlmtop/frontweb下的所有文件传到apache的/usr/local/apache/htdocs/
cp -R frontweb /usr/local/apache/htdocs/
修改 application/config/database.php文件
cd /usr/local/apache/htdocs/frontweb
启动完毕后可以访问
部分页面出现乱码,错误,则修改
Message: date(): It is not safe to rely on the system's timezone settings.
date_default_timezone_set("PRC");