在線下載安裝依賴包
yum -y install gcc gcc-c++ php
yum -y install gcc gcc-c++ ncurses ncurses-devel cmake bison
yum install -y perl-Module-Install.noarchmysql
yum -y install autoconflinux
yum -y install libxml2 libxml2-devel openssl openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel libmcrypt-develnginx
yum -y install unzipc++
mongodb源碼安裝步驟web
1.解壓安裝包
tar -zxvf mongodb-linux-x86_64-rhel70-3.4.10.tgzredis
2.進入安裝目錄
cd mongodb-linux-x86_64-rhel70-3.4.10sql
3.啓動
cd bin/
./mongod
mkdir -p /data/db
./mongodmongodb
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
<?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.gz2.進入解壓後的目錄 cd redis-4.0.13.編譯 make4.建立redis安裝目錄 mkdir /usr/local/redis5.進入src文件並查看 cd srcls6.將redis-cli和redis-server文件複製到/usr/local/redis目錄中 cp redis-cli redis-server /usr/local/redis7.返回上一級目錄,並查看 cd .. ls8.將redis.conf文件複製到/usr/local/redis目錄中 cp redis.conf /usr/local/redis9.進入/usr/local/redis目錄並查看 cd /usr/local/redis ls10.編輯redis.conf文件 vi redis.conf修改參數:daemonize yes11.啓動redis服務器 ./redis-server redis.conf12.啓動redis客戶端 ./redis-cli設置變量 set name zhangsan查看變量 get nameredis刪除 rm -rf /opt/redis-4.0.1 rm -rt /usr/local/redis