preface
I bought several servers, and then WANTED to configure my own development environment, but every time I installed software, I had to look for tutorials, either Jenkins did not work well or mysql did not work well, so today I am going to write a complete installation and configuration, when I need to read the article, just follow the operation. The pagoda panel smells good and the Docker is good, but it feels like it’s less fun to do it yourself. Let ‘s Go!
To prepare
Tencent cloud, system version: Ubuntu18.04. This article mainly involves installing Nginx, JDK, PHP, Mysql, Jenkins, Node, NPM, PM2, etc.
Since the default login user name of Tencent Cloud is Ubuntu, root permission is required for many operations. In order to directly log in using root account, you need to add a root account as follows:
1. Log in to Ubuntu as user name and run
sudo passwd rootCopy the code
Enter the root password to be set. The password is invisible. Enter the password again to confirm.
2. Modify the SSH configuration
sudo vi /etc/ssh/sshd_configCopy the code
Enter I on the cli to change the value of PermitRootLogin to yes. The value is annotated by default. Press Esc and enter wq + Enter to save the modification.
3. Restart the SSH service to log in as user root
sudo service ssh restartCopy the code
Update the system
After logging in to the server, update the system. Before the recommended automatic login server script, although this many people will write, or direct SSH command login, but still put it, in case someone needs it, script address: github.com/BoWang816/s… After logging in, first update the system:
apt-get updateCopy the code
Nginx installation, configuration, uninstall
Install Nginx
apt-get install nginxCopy the code
If the following information is displayed, Nginx is successfully installed. For example, my address is http://49.235.105.248/ and the default port number is 80.
Uninstall Nginx
1. Delete nginx, -purge including configuration files
sudo apt-get --purgeremove nginx Copy the code
2. Remove all unused software packages
sudo apt-getautoremove Copy the code
3. List nginx-related software and delete it
dpkg--get-selections|grep nginx Copy the code
sudo apt-get --purgeremove nginx Copy the code
sudo apt-get --purgeremove nginx-common Copy the code
sudo apt-get --purgeremove nginx-coreCopy the code
Configure Nginx
For Nginx configuration, in a blog post on tutorial describes in detail, to: bowang816. Making. IO/tags/Nginx /
Uninstall apache2
Tencent Cloud installs Apache by default. To uninstall Apache, run the following command:
sudo apt-get --purge remove apache-common
sudo apt-get --purge remove apache
sudo find /etc -name "apache" |xargs rm -rf
sudo rm -rf /etc/libapache2-mod-jk
dpkg -l |grep apache2|awk '{print $2}'|xargs dpkg -PCopy the code
Jenkins installs, configures, uninstalls
Install the JDK
The first step is to download the JDK package. Although the OpenJDK can automatically install and configure environment variables, you should install it yourself because it is too difficult to find the path to install the OpenJDK. Because the official website now requires an Oracle account to download JDK, so here is one
Account: @qq.com password: 2337594954 Woaifengbeibei12 account from < https://blog.csdn.net/qq_41650354/article/details/82227742 >Copy the code
/usr/local/ Java
mkdir /usr/local/javaCopy the code
2, Decompress the JDK package:
sudo tar -zxvf jdk-8u131-linux-x64.tar.gzCopy the code
Change the name of the decompressed file to JDK, assuming the decompressed folder is jdK-8.131:
The mv JDK - 8.131 JDKCopy the code
/usr/local/ Java /usr/local/ Java /usr/local/ Java /usr/local/ Java
mv jdk /usr/local/javaCopy the code
5, open /etc/environment file, add environment variable:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:$JAVA_HOME/bin"
export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib
export JAVA_HOME=/usr/local/java/jdkCopy the code
#set Java environment
export JAVA_HOME=/usr/local/java/jdk
export JRE_HOME=$JAVA_HOME/jre
export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATHCopy the code
8. Run the source /etc/profile command to make the global environment variable take effect
Add a Java environment to /etc/profile:
6. Run the source /etc/environment command to make the environment variables take effect
Install Jenkins
Installing Jenkins requires a Java environment, so the Java environment is configured first.
- Configure Jenkins source:
Perform first: wget - q - O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | apt - key add - to perform:echo deb http://pkg.jenkins-ci.org/debian binary/ > /etc/apt/sources.list.d/jenkins.list
Copy the code
- Update the source
apt-get updateCopy the code
- Install Jenkins
apt-get install jenkinsCopy the code
Jenkins configuration
Jenkins defaults to port 8080. After the installation is complete, you can access the installation at http://IP:8080. Mine is http://49.235.105.248:8080/, for example, for the first time open the administrator will need to input, through the server
cat /var/lib/jenkins/secrets/initialAdminPasswordCopy the code
You can view the password, input the password and select the plug-in to be installed for installation. The front-end environment may require nodeJS, GitLab, etc., to search for installation. Once installed, you can create a new project for automated deployment, which will be covered in the next article.
Jenkins Default Directory
/etc/default/Jenkins You can configure ports here
/var/lib/Jenkins Default installation path
/var/cache/Jenkins Default cache path
/var/log/Jenkins Default log path
Uninstall Jenkins
sudo apt-get remove jenkins Copy the code
sudo apt-get remove --auto-remove jenkins Copy the code
sudo apt-get purge jenkins
Copy the code
sudo apt-get purge --auto-remove jenkins Copy the code
Node installation, configuration, and uninstallation
Install nodeJS, NPM, and PM2
Install nodeJS. After the installation is complete, run the node -v command to check whether the installation is successful
apt-get install nodejs
Copy the code
Install the NPM. After the installation is complete, run the NPM -v command to check whether the installation is successful
apt-get install npmCopy the code
Install the PM2. After the installation is complete, run the PM2 -v command to check whether the installation is successful
sudo npm install -g pm2Copy the code
The node can be used without configuration after it is successfully installed. To uninstall the node, run the apt-get remove nodejs command.
PHP installation, Nginx configuration PHP
Installing PHP
The default installation of PHP is PHP7.2. After PHP7, the mysql extension has been removed, so you need to install phP-mysql. After the installation is complete, run the following commands to check whether the installation is successful.
sudo apt-get install php php-fpmCopy the code
sudo apt-get install libapache2-mod-phpCopy the code
Sudo apt - get the install php7.2 - mysqlCopy the code
Nginx configuration of PHP
This is just to modify the default configuration file, if you do not want to modify the default configuration file, you can also create a new configuration file to configure, detailed operations in my blog related to Nginx.
Edit the default configuration file:
vim /etc/nginx/sites-enabledCopy the code
The default PHP Settings are commented out and need to be uncommented. Add index. PHP to index to ensure that PHP files can be indexed to:
# Add index.php to the list if you are using PHP
index index.html index.htm index.php index.nginx-debian.html;Copy the code
To open the PHP configuration items, we use php-fpm, so the fastcgi_pass item here only needs to open the first one. Sock: php7.2-fpm. Sock: php7.2-fpm. Sock: php7.2-fpm. Sock: php7.2-fpm. Sock: php7.2-fpm. Sock: php7.2-fpm.
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
# With php-fpm (or other unix sockets):Fastcgi_pass Unix: / var/run/PHP/php7.2 - FPM. The sock.# With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}Copy the code
After the configuration is successful, create a PHP file in /var/www/html, which is the default nginx access directory. If the file can be opened, the configuration is successful.
Mysql installation, configuration, and uninstallation
Installing the mysql service
You can actually buy mysql separately, but it’s a little bit more expensive. You know, if you’re building your own website, you can just install one on your server, but make sure you back it up. After the installation is complete, run the mysql command. If the mysql is displayed, the installation is successful.
sudo apt-get install mysql-serverCopy the code
Configure the mysql root account and password
Mysql > select * from localhost; Run the following command to find bind-address = 127.0.0.1 and comment out this line
sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf
Copy the code
Run the mysql command to enter the mysql database and set the root password to 123456. After setting the password, refresh the configuration: FLUSH PRIVILEGES;
use mysql;
update user set authentication_string=PASSWORD("Enter your password here.") where User='root'; # change password
update user set plugin="mysql_native_password"; # If this line is not present, an error may be reported, so you need to run this line
flush privileges; Update all operation permissions
quit;Copy the code
Then restart the mysql service:
service mysql restartCopy the code
MysqlWorkbench/Navicat/mysqlWorkbench/navicat/mysqlWorkbench/Navicat/mysqlWorkbench/Navicat/mysqlWorkbench/Navicat/mysqlWorkbench
use mysql;
GRANT ALL ON *.* to root@The '%' IDENTIFIED BY '123456';
flush privileges; Update all operation permissions
quit;Copy the code
The last
If the preceding configuration is required, ensure that the port corresponding to the security group of the server is enabled
Nginx: 80,443
Jenkins: 8080
Mysql: 3306
At this point, all services have been installed, if you have any questions, welcome to clap brick.