CentOS7 server configuration
Creating a New user
#Add userAdduser user name#Change the passwordPasswd usernameCopy the code
authorization
chmod 740 /etc/sudoers
vim /etc/sudoers
#Add the item under the ALLow root to run any Commands anywher lineUsername ALL=(ALL) ALL chmod 440 /etc/sudoersCopy the code
Example Modify the SSH configuration file
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
vim /etc/ssh/sshd_config
#Modify the itemPermitRootLogin No # Prohibit root login StrictModes Yes # Strict matching mode ServerKeyBits 1024 # Key number of the server RSAAuthentication Yes # RSA authentication PubkeyAuthentication yes # use public key authentication PermitEmptyPasswords no # prohibit empty password login PasswordAuthentication no # prohibit PasswordAuthentication AllowUsers user name 1 user 2 Allow the specified user to log inCopy the code
Creating an SSH Key
ssh-keygen -t rsa
#Then press Enter, optionally enter the password
cd .ssh
mv id_rsa.pub authorized_keys
chmod 600 authorized_keys
#Copy id_RSA to a local PC. The format must be converted for puttyService SSHD restart # Restart SSH serverCopy the code
Install the Apache
#Install the apache
yum install httpd
#Set the server to start automatically upon startup
systemctl enable httpd.service
#Verify whether the startup is automatic
systemctl is-enabled httpd.service
#Start the apache
systemctl start httpd.service
#Restart the apache
systemctl restart httpd.service
#Stop apache
systemctl stop httpd.service
Copy the code
The root directory of the apache default website is /var/www/html
The default master configuration file/etc/HTTPD/conf/HTTPD. Conf
Configure the directory stored in /etc/httpd/conf.d/
Firewall Settings
#Checking the Firewall Status
systemctl status firewalld
#Enabling the Firewall
systemctl start firewalld
#Disabling the Firewall
systemctl stop firewalld
#View opened ports
firewall-cmd --list-ports
#Set port
firewall-cmd --zone=public --add-port=80/tcp --permanent
#Command meaning--zone # scope --add-port=80/ TCP # Add port. Format: port/protocol --permanent#Restarting the Firewall
firewall-cmd --reload
#Checking the Firewall Status
firewall-cmd --state
Copy the code
Ali Cloud server security group configuration
Server Instance List > Operation > More > Security Group Configuration > Configuration Rules > Add Security Group Rule
MySQL installation
#Check whether mysql has been installed
yum list installed | grep mysql
#Download the mysql installation package
rpm -ivh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
#Mysql installation
yum install mysql-community-server
#Setting boot
systemctl enable mysqld.service
#Check whether startup automatically starts
systemctl list-unit-files | grep mysqld
#Start the service
systemctl start mysqld.service
#Viewing the Default Password
grep 'temporary password' /var/log/mysqld.log
#Log on to the mysql
mysql -u root -p
#Change the passwordUpdate set password= password (' new password ') where user='root';#Enable remote login and authorize root to log in remotelyGRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'new password' WITH GRANT OPTION;#Effective immediately
flush privileges;
#Configure the security group of the Ali Cloud server. Enable port 3306 and configure the firewall port
#Reset if you forget your password
#Close the service
systemctl stop mysqld.service
#Modify the /etc/my.cnf file
vim /etc/my.cnf
#Add item: Add under the [mysqld] line
skip-grant-tables
#Restart the service, log in, and change the password
#Restore the my.cnf configuration
Copy the code
Install PHP7
#Setting the Installation Source
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
#To view
yum search php71w
#Install extensions as required
## php7.1
yum install php71w php71w-fpm php71w-cli php71w-common php71w-devel php71w-gd php71w-pdo php71w-mysql php71w-mbstring php71w-bcmath
## php7.2
yum -y install php72w php72w-cli php72w-fpm php72w-common php72w-devel php72w-embedded php72w-gd php72w-mbstring php72w-mysqlnd php72w-opcache php72w-pdo php72w-xml
#Start the service
service php-fpm start
#Set automatic startup upon startup
systemctl enable php-fpm.service
#To test PHP, create a phpInfo () file in /var/www/html/
#Restarting the Apache Service
Copy the code
Apache configures multiple sites
#Create the vhosts.conf file in the /etc/httpd/conf.d/ directory
#Add item
<VirtualHost *:80>
DocumentRoot "D:\workspace\php\htdocs"
ServerName www.example.com
ServerAlias
<Directory "D:\workspace\php\htdocs">
Options FollowSymLinks ExecCGI
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
#Changing the directory ownerChown apache: indicates the apache-r directoryCopy the code