在线下载安装依赖包
yum -y install gcc gcc-c++
yum -y install gcc gcc-c++ ncurses ncurses-devel cmake bison
yum install -y perl-Module-Install.noarch
yum -y install autoconf
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
yum -y install unzip
mongodb源码安装步骤
1.解压安装包
tar -zxvf mongodb-linux-x86_64-rhel70-3.4.10.tgz
2.进入安装目录
cd mongodb-linux-x86_64-rhel70-3.4.10
3.启动
cd bin/
./mongod
mkdir -p /data/db
./mongod
4.配置文件
需要 手打快捷键 ctrl+c
./mongod --help
cd ..
mkdir conf
cd conf/
vi mongodb.conf
在mongodb.conf内写:
logpath=/home/mongodb/data/log/mongodb.log
logappend=false
dbpath=/home/mongodb/data/db
fork=true
cat mongodb.conf
复制完最后要 摁Esc 在 :wq保存 在进行下一步
5.创建日志路径和mongodb的路径:
mkdir -p /home/mongodb/data/log/
cd /home/mongodb/data/log/
touch mongodb.log
cd ..
mkdir db
6.删除默认安装的mongodb数据,释放空间
rm -rf /data/
7.使用自定义配置文件启动
cd /opt/mongodb-linux-x86_64-rhel70-3.4.10/bin
./mongod -f ../conf/mongodb.conf
8.查看进程是否启动
ps -ef | grep mongodb
删除:
rm -rf /opt/mongodb-linux-x86_64-rhel70-3.4.10
rm -rf /data/db
rm -rf /home/mongodb
1.安装依赖包:pcre-8.36.tar.gz
cd /opt
解压 tar -zxvf pcre-8.36.tar.gz
进入解压后的目录: cd pcre-8.36
配置(预编译) ./configure
编译 make
安装 make install
2.安装主程序:nginx-1.10.0.tar.gz
cd /opt
解压 tar -zxvf nginx-1.10.0.tar.gz
进入解压后的目录 cd nginx-1.10.0
预编译 ./configure --prefix=/usr/local/nginx --without-http_gzip_module
编译 make
安装 make install
启动服务: /usr/local/nginx/sbin/nginx
关闭防火墙: systemctl stop firewalld.service
打开浏览器,输入虚拟机的IP
192.168.246.131
查看nginx服务进程是否启动,ps -aux | grep nginx
nginx删除方法
rm -rf /opt/pcre-8.36
rm -rf /opt/nginx-1.10.0
rm -rf /usr/local/nginx
mysql
1.安装依赖包:
yum -y install gcc gcc-c++ ncurses ncurses-devel cmake bison
yum install -y perl-Module-Install.noarch
注意:第一步只需执行一次
2.上传工具包
cd /opt
3.解压工具包
tar -xvf mysql-5.6.29.tar.gz
4.新建MySQL用户和组
groupadd -r mysql && useradd -r -g mysql -s /sbin/nologin -M mysql
5.新建MySQL数据库目录
mkdir -p /data/mysql
6.修改权限
chown -R mysql /data
7.进入MySQL解压后的工具包
cd mysql-5.6.29
8.编译 mysql
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \
-DMYSQL_DATADIR=/data/mysql \
-DWITH_BOOST=../boost_1_59_0 \
-DSYSCONFDIR=/etc \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_PARTITION_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_MYISAM_STORAGE_ENGINE=1 \
-DENABLED_LOCAL_INFILE=1 \
-DENABLE_DTRACE=0 \
-DDEFAULT_CHARSET=utf8mb4 \
-DDEFAULT_COLLATION=utf8mb4_general_ci \
-DWITH_EMBEDDED_SERVER=1
make -j `grep processor /proc/cpuinfo | wc -l`
9. 安装
make install
10. 设置启动脚本,开机自动启动:
ls -lrt /usr/local/mysql
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld
systemctl enable mysqld
11.配置文件
vi /etc/my.cnf
[client]
port = 3306
socket = /dev/shm/mysql.sock
[mysqld]
port = 3306
socket = /dev/shm/mysql.sock
basedir = /usr/local/mysql
datadir = /data/mysql/data
pid-file = /data/mysql/mysql.pid
user = mysql
bind-address = 0.0.0.0
server-id = 1
init-connect = 'SET NAMES utf8mb4'
character-set-server = utf8mb4
#skip-name-resolve
#skip-networking
back_log = 300
max_connections = 1000
max_connect_errors = 6000
open_files_limit = 65535
table_open_cache = 128
max_allowed_packet = 4M
binlog_cache_size = 1M
max_heap_table_size = 8M
tmp_table_size = 16M
read_buffer_size = 2M
read_rnd_buffer_size = 8M
sort_buffer_size = 8M
join_buffer_size = 8M
key_buffer_size = 4M
thread_cache_size = 8
query_cache_type = 1
query_cache_size = 8M
query_cache_limit = 2M
ft_min_word_len = 4
log_bin = mysql-bin
binlog_format = mixed
expire_logs_days = 30
log_error = /data/mysql/mysql-error.log
slow_query_log = 1
long_query_time = 1
slow_query_log_file = /data/mysql/mysql-slow.log
performance_schema = 0
explicit_defaults_for_timestamp
#lower_case_table_names = 1
skip-external-locking
default_storage_engine = InnoDB
#default-storage-engine = MyISAM
innodb_file_per_table = 1
innodb_open_files = 500
innodb_buffer_pool_size = 64M
innodb_write_io_threads = 4
innodb_read_io_threads = 4
innodb_thread_concurrency = 0
innodb_purge_threads = 1
innodb_flush_log_at_trx_commit = 2
innodb_log_buffer_size = 2M
innodb_log_file_size = 32M
innodb_log_files_in_group = 3
innodb_max_dirty_pages_pct = 90
innodb_lock_wait_timeout = 120
bulk_insert_buffer_size = 8M
myisam_sort_buffer_size = 8M
myisam_max_sort_file_size = 10G
myisam_repair_threads = 1
interactive_timeout = 28800
wait_timeout = 28800
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M
read_buffer = 4M
write_buffer = 4M
12. 添加环境变量:
echo -e '\n\nexport PATH=/usr/local/mysql/bin:$PATH\n' >> /etc/profile && source /etc/profile
13. 初始化数据库、启动mysqld服务:
mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql
14.
cd /usr/local/mysql/scripts/
./mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql/data
15.启动数据库
systemctl start mysqld 或者service mysqld start
mysql
mysql删除方法
rm -rf /opt/mysql-5.6.29
rm -rf /data/mysql/data
rm -rf /usr/local.mysql
Apache源码安装
1. yum install gcc-c++
2.将软件包上传
cd /opt
3.压缩工具
unzip web-server.zip
在unzip里输入大写A
4.进入web-server
cd web-server
5.进入apache
cd apache
6.移动pcre到当前文件夹
mv ../nginx\ 源码/pcre-8.36.tar.gz .
7.解压apac工具包和依赖包
tar -zxvf httpd-2.4.20.tar.gz
tar -zxvf pcre-8.36.tar.gz
tar -zxvf apr-1.5.2.tar.gz
tar -zxvf apr-util-1.5.4.tar.gz
重命令
mv apr-1.5.2 apr
mv apr-util-1.5.4 apr-util
移动
mv apr httpd-2.4.20/srclib/
mv apr-util httpd-2.4.20/srclib/
确认是否解压到指定位置
8.进入文件夹pcre-8.63
cd pcre-8.36/
9.安装依赖包(安装位置: /usr/local/软件名)
(1)配置安装文件
./configure --prefix=/usr/local/pcre-8.36
(2)编译并安装
make && make install
(3)清除make产生的文件
make clean
10.进入父级的
cd ../httpd-2.4.20
11.配置安装文件
./configure --prefix=/usr/local/apache -with-pcre=/usr/local/pcre-8.36/bin/pcre-config -with-included-apr
12.编译安装
make && make install
13.配置httpd.conf
vi /usr/local/apache/conf/httpd.conf
Listen值改为9080
ServerName值改为localhost:9080
14.启动
cd /usr/local/apache/bin/
./apachectl -k start
systemctl stop firewalld.service
apache删除方法
rm -rf /opt/web-server
rm -rf /opt/__MACOSX
rm -rf /usr/local/apache
rm -rf /usr/local/pcre-8.36
PHP源码安装
1.创建PHP用户和用户组
groupadd -r php && useradd -r -g php -s /bin/false -d /usr/local/php7 -M php
2.解压
unzip -q php7-src-master.zip && cd php-src-master
3.解决依赖
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-devel
4.生成配置文件
./buildconf
//buildconf: checking installation...
//buildconf: autoconf version 2.69 (ok)
//rebuilding aclocal.m4
//rebuilding configure
//rebuilding main/php_config.h.in
5.开始配置
./configure \
--prefix=/usr/local/php7 \
--exec-prefix=/usr/local/php7 \
--bindir=/usr/local/php7/bin \
--sbindir=/usr/local/php7/sbin \
--includedir=/usr/local/php7/include \
--libdir=/usr/local/php7/lib/php \
--mandir=/usr/local/php7/php/man \
--with-config-file-path=/usr/local/php7/etc \
--with-mysql-sock=/var/run/mysql/mysql.sock \
--with-mcrypt=/usr/include \
--with-mhash \
--with-openssl \
--with-mysql=shared,mysqlnd \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-opcache \
--enable-fpm \
--enable-fastcgi \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--without-gdbm \
--disable-fileinfo
6.编译安装
make clean && make && make install
//7.执行命令(非必须步骤)
make test
保存wq
8.产看编译安装后的php7目录
ls -lrt /usr/local/php7/lib/php/extensions/no-debug-non-zts-20170718/
9.设置php的启动文件
cp php.ini-production /usr/local/php7/etc/php.ini
cp /opt/php-src-master/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf
cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf
10.添加环境变量
echo -e '\nexport PATH=/usr/local/php7/bin:/usr/local/php7/sbin:$PATH\n'>> /etc/profile && source /etc/profile
11.设置进程文件目录
mkdir -p /var/log/php-fpm/ && mkdir -p /var/run/php-fpm && cd /var/run/ && chown -R nginx:nginx php-fpm
修改session的目录配置
mkdir -p /var/lib/php/session
chown -R nginx:nginx /var/lib/php
12.设置php文件开机启动及测试配置文件是否正确
chmod +x /etc/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
php-fpm -t
//显示结果
NOTICE: configuration file /usr/local/php7/etc/php-fpm.conf test is
successful
13.启动php服务器
service php-fpm start Starting php-fpm done
14.查看版本信息
php -v
vi hello.php
echo "hello php";
php hello.php
php删除
rm -rf /opt/php7-src-master
rm -rf /opt/php-src-master
rm -rf /usr/local/php7
redis安装
1.解压redis
tar -zxvf redis-4.0.1.tar.gz
2.进入解压后的目录
cd redis-4.0.1
3.编译
make
4.创建redis安装目录
mkdir /usr/local/redis
5.进入src文件并查看
cd src
ls
6.将redis-cli和redis-server文件复制到/usr/local/redis目录中
cp redis-cli redis-server /usr/local/redis
7.返回上一级目录,并查看
cd ..
ls
8.将redis.conf文件复制到/usr/local/redis目录中
cp redis.conf /usr/local/redis
9.进入/usr/local/redis目录并查看
cd /usr/local/redis
ls
10.编辑redis.conf文件
vi redis.conf
修改参数:daemonize yes
11.启动redis服务器
./redis-server redis.conf
12.启动redis客户端
./redis-cli
设置变量
set name zhangsan
查看变量
get name
redis删除
rm -rf /opt/redis-4.0.1
rm -rt /usr/local/redis