Showing posts with label Centos. Show all posts
Showing posts with label Centos. Show all posts

Thursday, May 19, 2016

CentOS How to open the port in the Server!

  How open a new Port on the VPS!



you can use:

sudo iptables -I INPUT -p tcp -m tcp --dport 38088 -j ACCEPT

but you must know:




所以开放的配置放到红圈里2个规则上面

那2个规则会把上面没匹配的连接全拒绝掉

Error:Unrecognized SSL message, plaintext connection??



Thanks TO:http://stackoverflow.com/questions/6532273/unrecognized-ssl-message-plaintext-connection-exception



How to look cents iptables?

查看可以访问的接口

https://www.digitalocean.com/community/tutorials/how-to-list-and-delete-iptables-firewall-rules

how to config  firewall iptanels:
http://ask.xmodulo.com/open-port-firewall-centos-rhel.html

Wednesday, May 18, 2016

Centos how to config JAVA_HOME

This tutorial describes how to install and configure latest Oracle Java JDK on CentOS 7, 6.5, and 6.4 servers. Although, the steps should work on other RPM based distributions such as RHEL 7, 6.x, Scientific Linux 6.x, and Fedora too.
First of all, update your server.
yum update
Then, search for if any older JDK versions are installed in your system.
rpm -qa | grep -E '^open[jre|jdk]|j[re|dk]'
Sample output:
gobject-introspection-1.36.0-4.el7.x86_64
pygobject3-base-3.8.2-4.el7.x86_64
To check the already installed Java version, enter the following command:
java -version
If Java 1.6 or 1.7 have been installed already, you can uninstall them using the following commands.
yum remove java-1.6.0-openjdk
yum remove java-1.7.0-openjdk

Download And Install Oracle Java JDK

At the time of writing this tutorial, the latest Java JDK version was JDK 8u25. First, let us download the latest Java version.
Go to the Oracle Java download page and download the required version depending upon your distribution architecture.
As I use 64bit CentOS 7 server, I have downloaded the 64bit rpm package.
Then, go to the directory where you’ve downloaded the jdk package, and run the following command to install it.
rpm -ivh jdk-8u25-linux-x64.rpm
Sample output:
Preparing...                          ################################# [100%]
Updating / installing...
   1:jdk1.8.0_25-2000:1.8.0_25-fcs    ################################# [100%]
Unpacking JAR files...
    rt.jar...
    jsse.jar...
    charsets.jar...
    tools.jar...
    localedata.jar...
    jfxrt.jar...

Check Java version

Now, check for the installed JDK version in your system using command:
java -version
Sample output:
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)
As you see above, latest java 1.8 has been installed.

Setup Global Environment Variables

We can easily set the environment variables using the export command as shown below.
export JAVA_HOME=/usr/java/jdk1.8.0_25/
export PATH=$PATH:$JAVA_HOME
Now, let us check for the environment variables using commands:
echo $JAVA_HOME
Sample output:
/usr/java/jdk1.8.0_25/
Or
echo $PATH
Sample output:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:/usr/java/jdk1.8.0_25/
However, the above method is not recommended. Because, the path will be disappeared when the system reboots. To make it permanent, you have to add the paths in the system wide profile.
To do that, create a file called java.sh under /etc/profile.d/ directory.
vi /etc/profile.d/java.sh
Add the following lines:
#!/bin/bash
JAVA_HOME=/usr/java/jdk1.8.0_25/
PATH=$JAVA_HOME/bin:$PATH
export PATH JAVA_HOME
export CLASSPATH=.
Save and close the file. Make it executable using command:
chmod +x /etc/profile.d/java.sh
Then, set the environment variables permanently by running the following command:
source /etc/profile.d/java.sh
That’s it.

What if I didn’t remove the old JDK versions from my system?

As I mentioned before, make sure you have removed all old JDK versions from your system. If you didn’t remove the older versions from your server before installing latest JDK version, you should tell your system from where java should be executed.
By default, the JDK 1.8.x will be installed in /usr/java/jdk1.8.0_25/ location. In order to tell our system, from where java should be executed, we need to run the following commands one by one.
alternatives --install /usr/bin/java java /usr/java/jdk1.8.0_25/jre/bin/java 20000
alternatives --install /usr/bin/jar jar /usr/java/jdk1.8.0_25/bin/jar 20000
alternatives --install /usr/bin/javac javac /usr/java/jdk1.8.0_25/bin/javac 20000
alternatives --install /usr/bin/javaws javaws /usr/java/jdk1.8.0_25/jre/bin/javaws 20000
alternatives --set java /usr/java/jdk1.8.0_25/jre/bin/java
alternatives --set jar /usr/java/jdk1.8.0_25/bin/jar
alternatives --set javac /usr/java/jdk1.8.0_25/bin/javac 
alternatives --set javaws /usr/java/jdk1.8.0_25/jre/bin/javaws
All done. Let us check the alternatives.
ls -lA /etc/alternatives/
Sample output:
lrwxrwxrwx. 1 root root 29 Dec  2 16:24 jar -> /usr/java/jdk1.8.0_25/bin/jar
lrwxrwxrwx. 1 root root 34 Dec  2 16:24 java -> /usr/java/jdk1.8.0_25/jre/bin/java
lrwxrwxrwx. 1 root root 31 Dec  2 16:24 javac -> /usr/java/jdk1.8.0_25/bin/javac
lrwxrwxrwx. 1 root root 36 Dec  2 16:24 javaws -> /usr/java/jdk1.8.0_25/jre/bin/javaws
[...]
That’s it. Now check for the java version using command:
java -version
Sample output:
java version "1.8.0_25"
Java(TM) SE Runtime Environment (build 1.8.0_25-b17)
Java HotSpot(TM) 64-Bit Server VM (build 25.25-b02, mixed mode)





Thanks To:
http://www.unixmen.com/install-oracle-java-jdk-8-centos-76-56-4/

Tuesday, May 17, 2016

CentOS how to install Artifactory and Config Artifactory?

第一步:
如何在 Centos 上安装 Artifactory

1 download  Artifactory.zip

mkdir /home/tool/artifactory


cd this path, you use following command

wget --output-document=artifactory-4.4.1.zip "http://bit.ly/Hqv9aj"

---------------------------- 2016-09-14 ----------------------------

FAQ:
之前 这个源http://bit.ly/Hqv9aj是没有问题的。
但是,现在是无法获取的数据的,可能是那个哥们的服务器换地址了。那个建议你去下载一个 到你的本地。


下面教你如何将本地的文件上传到 Centos VPS

进入你下载的文件的目录里面 使用bash

scp fileName root@ip:[port]/home/root/tool/artifactory

OK, 接下里你就而已使用下面的命令了!

---------------------------- 2016-09-14 ----------------------------
mkdir artifactory


unzip artifactory-4.4.1.zip  -d artifactory

cd artifactory 
cd tomcat/conf

vim server.conf

You can do nothings. If you want to change port or else, you can
change the data!

you can find  artifactory/bin
cd bin

just input this command:
./installService.sh


Now we just change config information.


cd /etc/opt/jfrog/artifactory
vim default


you can see the path is right. If it is right you do nothings to it.
if you find wrong, just alter it for right!


Now  start Artifactory:

when I use this command, I meet this error:


# sudo service artifactory start




error info:
no java
Starting Artifactory tomcat as user artifactory...
Max number of open files: 32000
Using ARTIFACTORY_HOME: /home/tool/artifactory/artifactory/artifactory-oss-4.7.7
Using ARTIFACTORY_PID: /home/tool/artifactory/artifactory/artifactory-oss-4.7.7/run/artifactory.pid
Neither the JAVA_HOME nor the JRE_HOME environment variable is defined
At least one of these environment variable is needed to run this program

** ERROR: Artifactory Tomcat server did not start. Please check the logs


I forget to config Java.
So I install java and config JAVA_HOME

yum install java
it will download the java it is so fast!

Now we config JAVA_HOME

cd ~
vim .bash_profile
add this string like this:

$JAVA_HOME=/use/lib/java-1.8.0
export $JAVA_HOME

and use this command:
source .bash_profile.

Ok , you can visit your VPS Artifactory!

just in the Browser, input  
IP:8081

Because it is first login, So it so slowly, you wait one minutes, you can get you want like this:


account:  admin
password:  password

this is default,  when you login in ,you can change it!



第二步:
如何将自己的代码发布到Artifactory

Now Our VPS has Artifactory, We can publish our code to Artifactory Repo.

工作原理,讲你的library 项目打包成 .aar 文件,让后将你的项目上传到 私有的Artifactory 项目中。
当你用的时候,只需要关联一下你的私有服务器的地址,导入你想使用的jar 包,即可!
个人感觉,仓库简直是开源世界的地位,就像是 git 的价值一样! 个人非常的庆幸,最先接触的是Android!

下面,我们开始创建的自己私有的 第三方库


Artifactory 是管理 Maven仓库的工具
为什么使用Artifactory?

  1. 清晰且有吸引力的用户界面
  2. 超快速配置
  3. Gradle插件
  4. 用户访问控制
  5. 自由和开放来源


你先 创建一个新的项目

  这个项目就是你要封装的私有的插件库代码。

在project 下的 build.grade

like this:


// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.1.0'
        //2  artifactory (制定版本)        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:3.1.1"        // NOTE: Do not place your application dependencies here; they belong        // in the individual module build.gradle files    }
}

allprojects {
    repositories {
        //1  自己私有服务器的依赖库  (如果你用本地的可以不用写的)        maven { url "IP/artifactory/libs-release-local" }
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir}

然后,到你的 module的 (也就是 app目录下面的)build.gradle

在文件的顶部如下配置:

我们将需要两个新的插件:
一个准备Maven artifact maven-publish,
另一个上传archives到artifactory com.jfrog.artifactory:


apply plugin: 'com.android.library'apply plugin: 'com.jfrog.artifactory'apply plugin: 'maven-publish'

每一个Maven artifact都由以下三个参数确定:
* artifactId:库的名称
* groupId:通常库的包名
* version:区别同一artifact的不同版本

一般的,我们将在build.gradle文件顶部定义这两个变量(便于修改!)
def packageName = 'com.chow.ui'def libraryVersion = '1.0.2-release'

artifactId需要和assemblerelease任务输出的文件名相匹配。因此我们要重命名库模块或指定输出文件名。我个人比较喜欢第一种方法,可以通过下面这种方式得到artifactId:

一般可以自己定义,可以使用 project.getName()


如何发布呢?
我们需要配置  maven-publish

我们需要配置 Maven-publish,  这样就知道哪一个artifactory 将要发布到的Artifactory.
我们引用和使用的时候,应用的是 ***-release.aar 文件,他是有 assembleRelease 任务生成。请注意,我们可以通过更改 库项目的名称来修改这个名字!是可以自己配置的。


个人建议,如果不是稳定的版本,建议使用debug 作为后缀包名。 如果版本比较的稳定了,使用release 作为后缀包名!

publishing {
    publications {
        aar(MavenPublication) {
            groupId packageName
            version = libraryVersion
            artifactId project.getName()

            // Tell maven to prepare the generated "* .aar" file for publishing
            artifact("$buildDir/outputs/aar/${project.getName()}-release.aar")
      }
    }
}

最后: 
    我们需要配置 com.jorg.artifactory 插件, 来指定 artifactory 发布到那个 仓库的管理器(因为,你可能使用本地的仓库,你也可以使用不同的服务器的地址,自己指定)。
配置如下:


artifactory {
    contextUrl = 'IP//artifactory'    publish {
        repository {
            // The Artifactory repository key to publish to            repoKey = libraryVersion.endsWith('SNAPSHOT') ? 'libs-snapshot-local' : 'libs-release-local'
            username = artifactory_username            password = artifactory_password        }
        defaults {
            // Tell the Artifactory Plugin which artifacts should be published to Artifactory.            publications('aar')
            publishArtifacts = true
            // Properties to be attached to the published artifacts.            properties = ['qa.level': 'basic', 'dev.team': 'core']
            // Publish generated POM files to Artifactory (true by default)            publishPom = true        }
    }
}


注意:这里的
username = artifactory_username
password = artifactory_password

artifactory_username 
artifactory_password
这两个字段在  gradle.propertice  中
就是你登录 Artifactory的 用户名和密码,注意你的用户的权限奥.上传一般没什么问题!



最后一步;  部署 Artifactory

就一句命令行,很简单的。
gradle assembleRelease artifactoryPublish

如果在你的 服务器上看到:



恭喜你,成功了~





我们的私有的第三方的库,已经弄好了。下面,我们来看看怎么使用呢?

只需要两步:

在项目的 build.gradle
allprojects {
    repositories {
        maven { url "http://localhost:8081/artifactory/libs-release-local" }
    }
}

在 module   build.grade
dependencies {
    compile 'com.jeroenmols.awesomelibrary:1.0.0'
}

compile    包名:项目名:版本号码


     大功告成,现在你可以做自己的私有的服务器仓库了。哈哈。屌屌的,很开心,终于可以开始自己愉快的玩耍了。刚开始接触的时候,我并不了解Artifactory. 而且搞了几周,各种资源不足,那个时候的我,只是搭载了一个本地的。 因为没有自己的服务器,尽管搭好了Artiactory. 但是,不会用Gradle将项目上传到 Artifactory  Maven 仓库,也是白费。
   后来,我有了一些资本。自己的VPS, 更深的了解了,Gradle!
我发现了,当你遇到一个不懂的技术的时候,一定要去搞。不要害怕,一开始,你不可能完全的弄明白。但是,你只要搞了,你就会了解的更多,在此来接触的时候,你就有可能搞明白了!就是这个样子!
  我们只是对自己的无知,感到恐惧!



Thanks To:
http://geekhades.blogspot.com/2016/05/cents-how-to-install-artifactory.html



http://blog.strive-ltd.com/2016/03/308-install-artifactory-on-centos-7/



30分钟搭建一个android的私有Maven仓库






FAQ:
1  因为我的VPS使用了SSH认证,因为SSH  对于权限的问题比较敏感

如果,
当你使用:sudo service artifactory start
你遇到这种问题的时候:


你可以进图 artifactory/Tomcat dir  自己手动的开启 startup.sh  shutdown.sh


2  还有,你在卸载的时候,你可能忘记把Tomcat给Stop掉。

没有使用  sudo service artifactory stop

这个时候,当你使用 sudo service artifactory stop
是有问题的。因为Tomcat  PID 是错的,所以无法调用Tomcat stop.













How to use Linode?

Today, I Buy linode VPS

But, I before login, I change the VPS OS and login it again.
I see this error info:


how to resolve it?

in your PC

cd .ssh
rm -rf known_hosts
touch known_hosts

Now you can use 
ssh root@ip
login it !

======================================

Centos 7 how to start FireWall?

Enable Firewalld
To enable firewalld, run the following command as root:
systemctl enable firewalld
Start Firewalld
To start firewalld, run the following command as root:
systemctl start firewalld
Check the Status of Firewalld
To check the status of firewalld, run the following command as root:
systemctl status firewalld
Ok  it works for me!



Thanks to:
https://www.digitalocean.com/community/questions/warning-remote-host-identification-has-changed

how to start firewall in Centos 7
http://www.liquidweb.com/kb/how-to-start-and-enable-firewalld-on-centos-7/

Friday, May 13, 2016

Cents how to install Artifactory?




第一步:  如何在Centos  Ubuntu to install Artifactory?


http://blog.strive-ltd.com/2016/03/308-install-artifactory-on-centos-7/


第二步: 如何将代码上传到  Artifactory?

http://www.devtf.cn/?p=1079

现在,我只能用管理员的账号上传,我要修改一下权限?

发布你的libraray:
gradle assembleRelease artifactoryPublish


======================================


Thanks to :
Need to clean:

how look contos version
cat /etc/centos-release


how to config yum ?
https://wiki.centos.org/TipsAndTricks/BrokenVserver

Friday, March 4, 2016

How To Install Wordpress with nginx on CentOS 6

About Wordpress

Wordpress is a free and open source website and blogging tool that uses php and MySQL. It was created in 2003 and has since then expanded to manage 22% of all the new websites created and has over 20,000 plugins to customize its functionality.

Setup

The steps in this tutorial require the user to have root privileges on your virtual private server. You can see how to set that up here in steps 3 and 4.
Before working with wordpress, you need to have LEMP installed on your VPS. If you don't have the Linux, nginx, MySQL, PHP stack on your server, you can find the tutorial for setting it up here.
Once you have the user and required software, you can start installing wordpress!

Step One—Download WordPress

We can download Wordpress straight from their website:
wget http://wordpress.org/latest.tar.gz
This command will download the zipped wordpress package straight to your user's home directory. You can unzip it the the next line:
tar -xzvf latest.tar.gz 

Step Two—Create the WordPress Database and User

After we unzip the wordpress files, they will be in a directory called wordpress in the home directory.
Now we need to switch gears for a moment and create a new MySQL directory for wordpress.
Go ahead and log into the MySQL Shell:
mysql -u root -p
Login using your MySQL root password, and then we need to create a wordpress database, a user in that database, and give that user a new password. Keep in mind that all MySQL commands must end with semi-colon.
First, let's make the database (I'm calling mine wordpress for simplicity's sake; feel free to give it whatever name you choose):
CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)
Then we need to create the new user. You can replace the database, name, and password, with whatever you prefer:
CREATE USER wordpressuser@localhost;
Query OK, 0 rows affected (0.00 sec)
Set the password for your new user:
SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password");
Query OK, 0 rows affected (0.00 sec)
Finish up by granting all privileges to the new user. Without this command, the wordpress installer will not be able to start up:
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)
Then refresh MySQL:
FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.00 sec)
Exit out of the MySQL shell:
exit

Step Three—Setup the WordPress Configuration

The first step to is to copy the sample WordPress configuration file, located in the WordPress directory, into a new file which we will edit, creating a new usable WordPress config:
cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php
Then open the wordpress config:
sudo nano ~/wordpress/wp-config.php
Find the section that contains the field below and substitute in the correct name for your database, username, and password:
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpressuser');

/** MySQL database password */
define('DB_PASSWORD', 'password');
Save and Exit.

Step Four—Copy the Files

We are almost done uploading Wordpress to the server. We need to create the directory where we will keep the wordpress files:
sudo mkdir -p /var/www/wordpress
The final move that remains is to transfer the unzipped WordPress files to the website's root directory.
sudo cp -r ~/wordpress/* /var/www/wordpress
We can modify the permissions of /var/www to allow future automatic updating of Wordpress plugins and file editing with SFTP. If these steps aren't taken, you may get a "To perform the requested action, connection information is required" error message when attempting either task.
First, switch in to the web directory:
cd /var/www/
Give ownership of the directory to the nginx user, replacing the "username" with the name of your server user.
sudo chown nginx:nginx * -R
sudo usermod -a -G nginx username

Step Five—Set Up Nginx Server Blocks

Now we need to set up the WordPress virtual host. Although Wordpress has an extra step in its installation, the nginx website gives us an easy configuration file:
Open up the default nginx default hosts file:
sudo vi /etc/nginx/conf.d/default.conf
The configuration should include the changes below (the details of the changes are under the config information):
#
# The default server
#
server {
    listen       80;
    server_name  _;

    #charset koi8-r;

    #access_log  logs/host.access.log  main;

    location / {
        root   /var/www/wordpress;
        index index.php  index.html index.htm;
    }

    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html;
    }

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ \.php$ {
        root           /var/www/wordpress;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}
  • Here are the details of the changes—you may have some of these in effect already:
  • Add index.php within the index line.
  • Change the root to /var/www/wordpress;
  • Uncomment the section beginning with "location ~ \.php$ {",
  • Change the root to access the actual document root, /var/www/wordpress;
  • Change the fastcgi_param line to help the PHP interpreter find the PHP script that we stored in the document root home.
Save, exit, and restart nginx for the changes to take effect:
sudo service nginx restart

Step Six—RESULTS: Access the WordPress Installation

Once that is all done, the wordpress online installation page is up and waiting for you:
Access the page by visiting your site's domain or your Virtual Private Server's IP address (eg. example.com) and fill out the short online form (it should look like this).

See More

Once Wordpress is installed, you have a strong base for building your site.
If you want to encrypt the information on your site, you can Install an SSL Certificate

Sunday, December 13, 2015

linux下修改root密码以及找回root密码

参考链接:
linux下修改root密码以及找回root密码

Mac how to use Iterm to connect the VPS ?

mac 通过 终端 ssh 远程连接 centos 服务器
在终端下输入
ssh -l root 204.74.*.*      就可以连接了,这是端口没变的情况,还是原来的22


ssh -p 448(你改变的端口) -l root(连接用户名) 204.74.*.*      这个是端口改变后的连接


======================================
Mac-4a0002833f10:~ Hades$ ssh -p 27417 -l root  45.78.17.86
root@45.78.17.86's password: