linux基本项目环境搭建
文章目錄
- linux基本項目環(huán)境搭建
- java環(huán)境搭建
- 獲取java源碼包
- 解壓
- 配置環(huán)境變量
- 使配置文件生效
- 驗證
- nginx安裝
- 下載(java也可用此方法下載)
- 解壓
- 配置(configure)
- 編譯和安裝
- 啟動
- php安裝
- 下載
- 解壓
- 配置,編譯和安裝
- 創(chuàng)建配置文件
- 啟動
- git安裝
- 位置
- 配置
linux基本項目環(huán)境搭建
java環(huán)境搭建
獲取java源碼包
將本地jdk-8u144-linux-x64.tar.gz通過xftp上傳到ECS的指定目錄下(一般為/usr/local/java)
解壓
tar zxvf jdk-8u144-linux-x64.tar.gz
z:調(diào)用gzip命令在文件打包過程中壓縮/解壓文件
x:打包文檔中還原出文件
v:顯示命令執(zhí)行過程
f:指定備份文件
配置環(huán)境變量
vim /etc/profile
在文件末尾加上
使配置文件生效
source /etc/profile
驗證
[root@iZwz9938t1plpkhn7ajjkrZ java]# java -version java version "1.8.0_144" Java(TM) SE Runtime Environment (build 1.8.0_144-b01) Java HotSpot(TM) 64-Bit Server VM (build 25.144-b01, mixed mode)nginx安裝
下載(java也可用此方法下載)
[root@hostname nginx]# ll total 0 [root@hostname nginx]# wget http://nginx.org/download/nginx-1.12.2.tar.gz --2019-03-04 21:51:00-- http://nginx.org/download/nginx-1.12.2.tar.gz Resolving nginx.org (nginx.org)... 95.211.80.227, 62.210.92.35, 2001:1af8:4060:a004:21::e3 Connecting to nginx.org (nginx.org)|95.211.80.227|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 981687 (959K) [application/octet-stream] Saving to: ‘nginx-1.12.2.tar.gz’100%[========================================================================================================================>] 981,687 151KB/s in 6.5s 2019-03-04 21:51:07 (148 KB/s) - ‘nginx-1.12.2.tar.gz’ saved [981687/981687][root@iZwz9ezkmfgg9sw1ujpt5zZ nginx]# ll total 960 -rw-r--r-- 1 root root 981687 Oct 17 2017 nginx-1.12.2.tar.gz解壓
tar -zxvf nginx-1.12.2.tar.gz
[root@hostname nginx-1.12.2]# ll total 724 drwxr-xr-x 6 1001 1001 4096 Mar 4 21:54 auto -rw-r--r-- 1 1001 1001 278202 Oct 17 2017 CHANGES -rw-r--r-- 1 1001 1001 423948 Oct 17 2017 CHANGES.ru drwxr-xr-x 2 1001 1001 4096 Mar 4 21:54 conf -rwxr-xr-x 1 1001 1001 2481 Oct 17 2017 configure drwxr-xr-x 4 1001 1001 4096 Mar 4 21:54 contrib drwxr-xr-x 2 1001 1001 4096 Mar 4 21:54 html -rw-r--r-- 1 1001 1001 1397 Oct 17 2017 LICENSE drwxr-xr-x 2 1001 1001 4096 Mar 4 21:54 man -rw-r--r-- 1 1001 1001 49 Oct 17 2017 README drwxr-xr-x 9 1001 1001 4096 Mar 4 21:54 src配置(configure)
引用 http://blog.sina.com.cn/s/blog_406127500101dsmy.html
源碼的安裝一般由3個步驟組成:配置(configure)、編譯(make)、安裝(make install)。
Configure是一個可執(zhí)行腳本,它有很多選項,在待安裝的源碼路徑下使用命令./configure –help輸出詳細的選項列表。
其中–prefix選項是配置安裝的路徑,如果不配置該選項,安裝后可執(zhí)行文件默認放在/usr /local/bin,庫文件默認放在/usr/local/lib,配置文件默認放在/usr/local/etc,其它的資源文件放在/usr /local/share,比較凌亂。
如果配置–prefix,如:
./configure --prefix=/usr/local/test
可以把所有資源文件放在/usr/local/test的路徑中,不會雜亂。
用了—prefix選項的另一個好處是卸載軟件或移植軟件。當(dāng)某個安裝的軟件不再需要時,只須簡單的刪除該安裝目錄,就可以把軟件卸載得干干凈凈;移植軟件只需拷貝整個目錄到另外一個機器即可(相同的操作系統(tǒng))。
當(dāng)然要卸載程序,也可以在原來的make目錄下用一次make uninstall,但前提是make文件指定過uninstall。
[root@iZwz9ezkmfgg9sw1ujpt5zZ nginx-1.12.2]# ./configure --prefix=/usr/local/nginx/ checking for OS+ Linux 3.10.0-693.2.2.el7.x86_64 x86_64 checking for C compiler ... found+ using GNU C compiler+ gcc version: 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC) ...checking for PCRE library in /usr/include/pcre/ ... not found checking for PCRE library in /usr/pkg/ ... not found checking for PCRE library in /opt/local/ ... not found./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.缺少PCRE library,正則表達式庫,nginx中l(wèi)ocation匹配要用到的一種。
安裝 正則表達式庫
可以安裝的標志
Configuration summary+ using system PCRE library+ OpenSSL library is not used+ using system zlib librarynginx path prefix: "/usr/local/nginx/"nginx binary file: "/usr/local/nginx//sbin/nginx"nginx modules path: "/usr/local/nginx//modules"nginx configuration prefix: "/usr/local/nginx//conf"nginx configuration file: "/usr/local/nginx//conf/nginx.conf"nginx pid file: "/usr/local/nginx//logs/nginx.pid"nginx error log file: "/usr/local/nginx//logs/error.log"nginx http access log file: "/usr/local/nginx//logs/access.log"nginx http client request body temporary files: "client_body_temp"nginx http proxy temporary files: "proxy_temp"nginx http fastcgi temporary files: "fastcgi_temp"nginx http uwsgi temporary files: "uwsgi_temp"nginx http scgi temporary files: "scgi_temp"[root@iZwz9ezkmfgg9sw1ujpt5zZ nginx-1.12.2]#編譯和安裝
[root@iZwz9ezkmfgg9sw1ujpt5zZ nginx-1.12.2]# make && make install make -f objs/Makefile make[1]: Entering directory `/usr/local/nginx/nginx-1.12.2' cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \-o objs/src/core/nginx.o \src/core/nginx.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \-o objs/src/core/ngx_log.o \src/core/ngx_log.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \-o objs/src/core/ngx_palloc.o \src/core/ngx_palloc.c cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \-o objs/src/core/ngx_array.o \src/core/ngx_array.c . . . cp conf/scgi_params \'/usr/local/nginx//conf/scgi_params.default' test -f '/usr/local/nginx//conf/nginx.conf' \|| cp conf/nginx.conf '/usr/local/nginx//conf/nginx.conf' cp conf/nginx.conf '/usr/local/nginx//conf/nginx.conf.default' test -d '/usr/local/nginx//logs' \|| mkdir -p '/usr/local/nginx//logs' test -d '/usr/local/nginx//logs' \|| mkdir -p '/usr/local/nginx//logs' test -d '/usr/local/nginx//html' \|| cp -R html '/usr/local/nginx/' test -d '/usr/local/nginx//logs' \|| mkdir -p '/usr/local/nginx//logs' make[1]: Leaving directory `/usr/local/nginx/nginx-1.12.2' [root@iZwz9ezkmfgg9sw1ujpt5zZ nginx-1.12.2]# ll啟動
[root@iZwz9ezkmfgg9sw1ujpt5zZ nginx]# ./sbin/nginx [root@iZwz9ezkmfgg9sw1ujpt5zZ nginx]# ps -aux | grep nginx root 26422 0.0 0.0 20492 612 ? Ss 09:08 0:00 nginx: master process ./sbin/nginx nobody 26423 0.0 0.0 20936 1336 ? S 09:08 0:00 nginx: worker process root 26431 0.0 0.0 112660 964 pts/0 S+ 09:08 0:00 grep --color=auto nginx [root@iZwz9ezkmfgg9sw1ujpt5zZ nginx]# netstat -ant Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 172.18.45.156:39316 100.100.30.25:80 ESTABLISHED tcp 0 52 172.18.45.156:22 59.68.29.48:48314 ESTABLISHED [root@iZwz9ezkmfgg9sw1ujpt5zZ nginx]#php安裝
下載
下載頁面:http://cn2.php.net/get/php-7.1.6.tar.gz/from/a/mirror
下載連接:http://cn2.php.net/get/php-7.1.6.tar.gz/from/this/mirror
解壓
tar -zxvf php-7.1.6.tar.gz
[root@iZwz9ezkmfgg9sw1ujpt5zZ php-7.1.6]# ll total 4276 -rw-rw-r-- 1 1000 1000 82506 Jun 7 2017 acinclude.m4 -rw-rw-r-- 1 1000 1000 312883 Jun 7 2017 aclocal.m4 drwxrwxr-x 2 1000 1000 4096 Jun 7 2017 appveyor drwxrwxr-x 2 1000 1000 4096 Jun 7 2017 build -rwxrwxr-x 1 1000 1000 772 Jun 7 2017 buildconf -rw-rw-r-- 1 1000 1000 334 Jun 7 2017 buildconf.bat -rw-rw-r-- 1 1000 1000 11982 Jun 7 2017 CODING_STANDARDS -rw-rw-r-- 1 1000 1000 42938 Jun 7 2017 config.guess -rw-rw-r-- 1 1000 1000 35987 Jun 7 2017 config.sub -rwxrwxr-x 1 1000 1000 2759190 Jun 7 2017 configure -rw-rw-r-- 1 1000 1000 46774 Jun 7 2017 configure.in -rw-rw-r-- 1 1000 1000 3163 Jun 7 2017 CONTRIBUTING.md -rw-rw-r-- 1 1000 1000 91 Jun 7 2017 CREDITS drwxrwxr-x 75 1000 1000 4096 Jun 7 2017 ext -rw-rw-r-- 1 1000 1000 20917 Jun 7 2017 EXTENSIONS -rw-rw-r-- 1 1000 1000 137 Jun 7 2017 footer -rw-rw-r-- 1 1000 1000 1776 Jun 7 2017 generated_lists -rwxrwxr-x 1 1000 1000 581 Jun 7 2017 genfiles -rw-rw-r-- 1 1000 1000 1143 Jun 7 2017 header -rw-rw-r-- 1 1000 1000 87836 Jun 7 2017 INSTALL -rw-rw-r-- 1 1000 1000 0 Jun 7 2017 install-sh -rw-rw-r-- 1 1000 1000 3218 Jun 7 2017 LICENSE -rw-rw-r-- 1 1000 1000 199728 Jun 7 2017 ltmain.sh drwxrwxr-x 3 1000 1000 4096 Jun 7 2017 main -rwxrwxr-x 1 1000 1000 4129 Jun 7 2017 makedist -rw-rw-r-- 1 1000 1000 1088 Jun 7 2017 Makefile.frag -rw-rw-r-- 1 1000 1000 2485 Jun 7 2017 Makefile.gcov -rw-rw-r-- 1 1000 1000 7236 Jun 7 2017 Makefile.global -rw-rw-r-- 1 1000 1000 5317 Jun 7 2017 makerpm -rw-rw-r-- 1 1000 1000 0 Jun 7 2017 missing -rw-rw-r-- 1 1000 1000 0 Jun 7 2017 mkinstalldirs drwxrwxr-x 2 1000 1000 4096 Jun 7 2017 netware -rw-rw-r-- 1 1000 1000 135093 Jun 7 2017 NEWS drwxrwxr-x 2 1000 1000 4096 Jun 7 2017 pear -rw-rw-r-- 1 1000 1000 1489 Jun 7 2017 php7.spec.in -rw-rw-r-- 1 1000 1000 2523 Jun 7 2017 php.gif -rw-rw-r-- 1 1000 1000 71064 Jun 7 2017 php.ini-development -rw-rw-r-- 1 1000 1000 71096 Jun 7 2017 php.ini-production -rw-rw-r-- 1 1000 1000 7010 Jun 7 2017 README.EXT_SKEL -rw-rw-r-- 1 1000 1000 5026 Jun 7 2017 README.GIT-RULES -rw-rw-r-- 1 1000 1000 5417 Jun 7 2017 README.input_filter -rw-rw-r-- 1 1000 1000 3426 Jun 7 2017 README.MAILINGLIST_RULES -rw-rw-r-- 1 1000 1000 1608 Jun 7 2017 README.md -rw-rw-r-- 1 1000 1000 6040 Jun 7 2017 README.namespaces -rw-rw-r-- 1 1000 1000 5237 Jun 7 2017 README.NEW-OUTPUT-API -rw-rw-r-- 1 1000 1000 7528 Jun 7 2017 README.PARAMETER_PARSING_API -rw-rw-r-- 1 1000 1000 19766 Jun 7 2017 README.REDIST.BINS -rw-rw-r-- 1 1000 1000 12934 Jun 7 2017 README.RELEASE_PROCESS -rw-rw-r-- 1 1000 1000 5086 Jun 7 2017 README.SELF-CONTAINED-EXTENSIONS -rw-rw-r-- 1 1000 1000 15355 Jun 7 2017 README.STREAMS -rw-rw-r-- 1 1000 1000 8126 Jun 7 2017 README.SUBMITTING_PATCH -rw-rw-r-- 1 1000 1000 6695 Jun 7 2017 README.TESTING -rw-rw-r-- 1 1000 1000 4958 Jun 7 2017 README.TESTING2 -rw-rw-r-- 1 1000 1000 4261 Jun 7 2017 README.UNIX-BUILD-SYSTEM -rw-rw-r-- 1 1000 1000 109 Jun 7 2017 README.WIN32-BUILD-SYSTEM -rwxrwxr-x 1 1000 1000 82234 Jun 7 2017 run-tests.php drwxrwxr-x 10 1000 1000 4096 Jun 7 2017 sapi drwxrwxr-x 4 1000 1000 4096 Jun 7 2017 scripts -rwxrwxr-x 1 1000 1000 2104 Jun 7 2017 server-tests-config.php -rwxrwxr-x 1 1000 1000 52726 Jun 7 2017 server-tests.php -rwxrwxr-x 1 1000 1000 108 Jun 7 2017 snapshot -rw-rw-r-- 1 1000 1000 10 Jun 7 2017 stamp-h.in -rw-rw-r-- 1 1000 1000 1 Jun 7 2017 stub.c drwxrwxr-x 10 1000 1000 4096 Jun 7 2017 tests drwxrwxr-x 3 1000 1000 4096 Jun 7 2017 travis drwxrwxr-x 3 1000 1000 4096 Jun 7 2017 TSRM -rw-rw-r-- 1 1000 1000 23356 Jun 7 2017 UPGRADING -rw-rw-r-- 1 1000 1000 3418 Jun 7 2017 UPGRADING.INTERNALS -rwxrwxr-x 1 1000 1000 159 Jun 7 2017 vcsclean drwxrwxr-x 3 1000 1000 4096 Jun 7 2017 win32 drwxrwxr-x 4 1000 1000 4096 Jun 7 2017 Zend配置,編譯和安裝
官網(wǎng)配置:http://php.net/manual/zh/install.unix.nginx.php
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-config-file-path=/usr/local/lib --with-pdo-mysql=/usr/local/mysql --with-zlib-dir=/usr/lib ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd/bin/apxs --with-config-file-path=/usr/local/lib --with-pdo-mysql=/usr/local/mysql --with-zlib-dir=/usr/lib--with-apxs2=/usr/sbin/apxs --with-apxs2=/usr/sbin/apxs --with-mysql=/usr --with-mysqli=/usr/bin/mysql_config [root@iZwz9ezkmfgg9sw1ujpt5zZ php-7.1.6]# make install Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20160303/ Installing PHP CLI binary: /usr/local/php/bin/ 。。。 nstalling PEAR environment: /usr/local/php/lib/php/ [PEAR] Archive_Tar - installed: 1.4.2 [PEAR] Console_Getopt - installed: 1.4.1 [PEAR] Structures_Graph- installed: 1.1.1 [PEAR] XML_Util - installed: 1.4.2 [PEAR] PEAR - installed: 1.10.4 Wrote PEAR system config file at: /usr/local/php/etc/pear.conf You may want to add: /usr/local/php/lib/php to your php.ini include_path /usr/local/php/php-7.1.6/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin ln -s -f phar.phar /usr/local/php/bin/phar Installing PDO headers: /usr/local/php/include/php/ext/pdo/ [root@iZwz9ezkmfgg9sw1ujpt5zZ php-7.1.6]#創(chuàng)建配置文件
[root@iZwz9ezkmfgg9sw1ujpt5zZ php-7.1.6]# cp php.ini-development /usr/local/php/php.ini [root@iZwz9ezkmfgg9sw1ujpt5zZ etc]# ll total 16 -rw-r--r-- 1 root root 1233 Mar 5 11:23 pear.conf -rw-r--r-- 1 root root 4463 Mar 5 11:22 php-fpm.conf.default drwxr-xr-x 2 root root 4096 Mar 5 11:22 php-fpm.d [root@iZwz9ezkmfgg9sw1ujpt5zZ etc]# cp php-fpm.conf.default php-fpm.conf[root@iZwz9ezkmfgg9sw1ujpt5zZ etc]# cd php-fpm.d [root@iZwz9ezkmfgg9sw1ujpt5zZ php-fpm.d]# ll total 20 -rw-r--r-- 1 root root 18517 Mar 5 11:22 www.conf.default [root@iZwz9ezkmfgg9sw1ujpt5zZ php-fpm.d]# cp www.conf.default www.conf啟動
[root@iZwz9ezkmfgg9sw1ujpt5zZ php]# ps -ef|grep php root 13603 1 0 14:48 ? 00:00:00 php-fpm: master process (/usr/local/php/etc/php-fpm.conf) nobody 13604 13603 0 14:48 ? 00:00:00 php-fpm: pool www nobody 13605 13603 0 14:48 ? 00:00:00 php-fpm: pool www root 13608 10402 0 14:49 pts/0 00:00:00 grep --color=auto phpgit安裝
[root@iZwz9938t1plpkhn7ajjkrZ local]# yum install git Loaded plugins: fastestmirror base | 3.6 kB 00:00:00 epel | 4.7 kB 00:00:00 extras | 3.4 kB 00:00:00 updates | 3.4 kB 00:00:00 (1/7): base/7/x86_64/group_gz | 166 kB 00:00:00 ... Installed:git.x86_64 0:1.8.3.1-20.el7 Dependency Installed:perl-Error.noarch 1:0.17020-2.el7 perl-Git.noarch 0:1.8.3.1-20.el7 perl-TermReadKey.x86_64 0:2.30-20.el7 rsync.x86_64 0:3.1.2-4.el7 Complete! [root@iZwz9938t1plpkhn7ajjkrZ local]# git --version git version 1.8.3.1位置
[root@iZwz9938t1plpkhn7ajjkrZ git-core]# pwd /usr/libexec/git-core [root@iZwz9938t1plpkhn7ajjkrZ git-core]# ll total 176032 -rwxr-xr-x 113 root root 1523792 Nov 20 00:06 git -rwxr-xr-x 113 root root 1523792 Nov 20 00:06 git-add -rwxr-xr-x 1 root root 36655 Nov 20 00:06 git-add--interactive -rwxr-xr-x 1 root root 22361 Nov 20 00:05 git-am ... -rwxr-xr-x 113 root root 1523792 Nov 20 00:06 git-verify-tag -rwxr-xr-x 1 root root 4215 Nov 20 00:05 git-web--browse -rwxr-xr-x 113 root root 1523792 Nov 20 00:06 git-whatchanged -rwxr-xr-x 113 root root 1523792 Nov 20 00:06 git-write-tree drwxr-xr-x 2 root root 4096 Mar 6 09:49 mergetools [root@iZwz9938t1plpkhn7ajjkrZ git-core]#配置
配置用戶名與郵箱,僅僅作為提交用戶身份證(待測試)
[root@izwz91rl2qyews1sgkymi9z ~]# git config --global user.name "設(shè)置一個用戶名,字符串A" [root@izwz91rl2qyews1sgkymi9z ~]# git config --global user.email "你的郵箱,字符串B"查看
進入$HOME(/root,可用echo輸出驗證),會有一個.gitconfig文件。
生成SSH公鑰
將生成的公鑰放在GitHub上面
這個是已經(jīng)生成ssh的,重新生成的過程。
[root@izwz91rl2qyews1sgkymi9z ~]# ssh-keygen -t rsa -C "new_thread@yeah.net" Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/id_rsa already exists. Overwrite (y/n)? [root@izwz91rl2qyews1sgkymi9z ~]#總結(jié)
以上是生活随笔為你收集整理的linux基本项目环境搭建的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: GitHub基本使用
- 下一篇: Linux系统磁盘满了