Build test environment

Posted by Indersingh on Thu, 03 Mar 2022 13:00:22 +0100

The test environment built this time: PHP (5.5-7.0) + Apache (> 2.0) + MySQL 5 7 (Architecture) → Windows/Linux

The first step is to install the basic software through yum

Installation method: directly use after decompression; rpm file installation; yum online installation;

There is no need to configure the yum source here, because the centos7mini version is equipped with 163 Yum source by default;

yum list
yum install -y wget    #Install wget tool (- y means yes all the way)

1. Check whether there is any required software on this yum source, such as yum list|grep -i mysql

The yum install command is usually used to install the software of linux system online. This method can automatically deal with dependencies and install all dependent packages at one time. Yum source: it can be understood as the server storing the software installation package. The famous Yum sources in China include Tsinghua University, 163 and Ali

2. Since there is no wget tool in CentOS 7mininmal, you need to download it first

wget is a tool for downloading files in Linux. It is used under the command line. It is an essential tool for Linux users, especially for network administrators. They often have to download some software or restore and back up from the remote server to the local server. If we use a virtual host to handle such transactions, we can only download it from the remote server to our computer disk, and then upload it to the server with FTP tool. This is a waste of time and energy. It's not impossible. When it comes to Linux VPS, it can be directly downloaded to the server without uploading. wget tool is small in size but has perfect functions. It supports breakpoint download function, FTP and HTTP download methods, proxy server and settings. It is convenient and simple.

1. Install database mysql5 seven

wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
yum install -y mysql-server --nogpgcheck  #Install mysql5 seven

First use wget to download the file of Yum source path provided by MySQL official website. After rpm installs this file, you can obtain mysql5.0 through yum The download information of 7 is installed online;

yum can automatically download the required packages and install them online

  • Start the database and change the password
service mysqld start  #Start database
grep "password" /var/log/mysqld.log  #Find initial password
mysql -u root -p   
Input password               # Enter database
    
    set password for root@localhost=password('Ab12345678#'); #Set new password
    flush privileges;   # Refresh permissions
    exit    # Exit database

vi /etc/my.cnf   #In my Add the following line of code at the end of the CNF file
	sql_mode = NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION
service mysqld restart   #Restart mysql service

It cannot be returned from the database and can be used; sign out

my.cnf is a mysql configuration file. Here, you need to change the startup mode from strict mode to loose mode, otherwise an error will be reported

2. Install Apache

yum install -y httpd   #install
service httpd start   #start-up
systemctl stop firewalld   #Turn off centos firewall
setenforce 0  #Temporarily disable selinux, which takes effect immediately. selinux will be started again after the machine is restarted

To permanently disable selinux, change the configuration file: vi /etc/selinux/config, and change SELINUX=enforcing to SELINUX=disabled;

SELinux (security enhanced Linux) is a mandatory access control mechanism developed by the National Security Agency (NSA). It is mainly integrated into the Linux kernel. It is a system that controls the permissions of specific processes and specified file resources. It is mainly to enhance the security of the traditional Linux operating system and solve various permission problems in the autonomous access control (DAC) system in the traditional Linux system (such as high root permission). Note that the root user needs to abide by SELinux rules in order to correctly access system resources. In addition, the root user can modify SELinux rules. In other words, users should not only comply with the read, write and execution permissions of the system, but also comply with SELinux rules in order to correctly access system resources.

3. Install PHP

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm # update PHP
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm # update PHP
yum install -y php56w php56w-opcache php56w-fpm php56w-mysql php56w-mysqli php56w-gd php56w-xml php56w-intl php56w-mbstring php56w-exif php56w-mcrypt php56w-openssl --skip-broken   # Installing PHP and related extensions

rpm -qa|grep -i php  #Query whether php installation is successful

The first two commands are to update the PHP version of the local yum source by using the online yum source

The second part deploys the code package and modifies the relevant configuration information

  • Install the decompression tool
yum install -y zip unzip
  • Using ftp tool to transfer code package
cd /var/www/html
unzip tpshop20190928.zip
mv /var/www/html/tpshop20190928/* /var/www/html
mv /var/www/html/tpshop20190928/.htaccess /var/www/html  # Hidden files need to be moved separately
chmod -R 777 /var/www/html/*

Use xftp tool to install tpshop20190928.0 on Windows Zip to / var/www/html. After decompression, you need to move the extracted file to the html directory; If you do not move the files in the code package to the html directory, you need to configure the virtual root directory

  • Modify configuration information [this project]
1,open vi /etc/httpd/conf/httpd.conf
2,Put the inside AllowOverride None Change to AllowOverride All   (There are three items in total. Just change the first two items)
3,service httpd restart  #Restart Apache

The specific operations of step 2 above are as follows:
vi /etc/httpd/conf/httpd.conf
  :125
  Press a Enter edit mode, and  AllowOverride None Change to  AllowOverride All
  Press ESC ,Exit edit mode and return to normal mode
  :151   
  Press a Enter edit mode, and  AllowOverride None Change to  AllowOverride All
  Press ESC ,Exit edit mode and return to normal mode
  :256  
  Press a Enter edit mode, and  AllowOverride None Change to  AllowOverride All
  Press ESC ,Exit edit mode and return to normal mode
  :wq enter

On a Windows computer, open the browser and enter the http: / / virtual machine URL. The next operation is the same as that on windows

Topics: Linux Operation & Maintenance CentOS server Other