CentOS 7 x64 under Apache+MySQL of Mariadb +PHP56 installation tutorial details

  • 2020-05-14 05:47:50
  • OfStack

Each time you build a new server, you have to go back and forth to put these packages again 1, back and forth to do it more than 20 times, the original is based on experience, the configuration process into the pit is inevitable, so write this article to do a note. Although there are integration packages such as xampp, installation through the package management tool is still assured on the production Linux distribution. The newly purchased server this time is CentOS 7(7.2) system, and the relevant configuration is also based on this version. For the convenience of operation, it is directly used root User configuration.

The CentOS 7 source is older, the PHP comes with PHP 5.4, we want PHP 5.6, so we need to execute the following command to add an additional remi source.


rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

When the preparation is complete, execute the following commands:


#yum install httpd
#yum install mariadb mariadb-server
#yum install --enablerepo=remi --enablerepo=remi-php56 php php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit

apache,mysql,php56 will be installed, from the above command you will find no mysql and mysql-server. This is due to copyright issues with mysql, which has been removed from CentOS 7 and replaced by mariadb and mariadb-server, which are designed to be fully compatible with mysql, mysql-server; In addition to php itself, it also installs plug-ins such as mbstring,mcrypt and mysqlnd, which are necessary in most projects. If it is not installed, it may open a blank piece of the website, and there is no error in checking the log.

Now let's look at the configuration of apache. Once apache is installed and ready to use, execute the following command to start it manually and add it to the boot boot.


#systemctl start httpd # Manual start 
#systemctl enable httpd # Add boot 

Execute netstat-tln to check if port 80 is listening. If so, the startup is successful.

Then open apache's default configuration file, located /etc/httpd/conf/httpd.conf To find DocumentRoot So this 1 row, it's usually going to be 1


DocumentRoot "/var/www/html " `

, which means the site root directory is located /var/www/html . Execute in this directory echo "It Works!" > index.html If you already have the file, you don't have to create it yourself. Then execute the following command to test if the site is accessible.


#curl http://127.0.0.1/
It Works! # Output the result representation 1 Cut the normal 

Of course, the tests can also be accessed directly from the browser. It is important to note that if you are accessing from another computer, you should execute first iptables -F Clear down the firewall or you won't be able to access it.

Then let's look at the configuration of PHP. Normally, after installing php56, the corresponding configuration file will be generated under apache. Make sure the following file is generated :/etc/httpd/conf.modules.d/10-php.conf,/etc/httpd/modules/libphp5.so,/etc/httpd/conf.d/php.conf .

Also create the php test file from the site root by executing the following command:


#echo "<?php phpinfo; ?>" > info.php

Access under http: / / localhost info php, can show the configuration information that is said PHP PHP installation is successful, if not, is carried out apachectl restart Try restarting the Apache server, and if that fails, look elsewhere.

Finally, look at the installation and configuration of mysql. Execute the following command to start manually, then add to the boot boot, and then start the initial configuration of the mysql server.


#systemctl start mariadb 
#systemctl enable mariadb
#mysql_secure_installation # complete mysql Initial initialization 

Once you're done, execute

mysql -uroot -p< The password you just set > Log in and see what happens if mysql is configured with OK.

The configuration of the server is now complete.

Additional configuration

Modern PHP development is basically built on top of composer, and it is necessary to execute the following command to install composer.


#yum install --enablerepo=remi --enablerepo=remi-php56 composer

phpMyAdmin is also very convenient for managing MySQL /var/www/html Next, download and unzip it.


wget https://files.phpmyadmin.net/phpMyAdmin/4.6.5.1/phpMyAdmin-4.6.5.1-all-languages.zip
mv phpMyAdmin-4.6.5.1-all-languages phpMyAdmin

It is suggested that phpMyAdmin forbid root to log in, which will be safer. The modification method is: enter /etc/httpd/conf/httpd.conf0 Directory, open libraries/config.default.php Find the following line,


cfg['Servers'][$i]['AllowRoot'] = true;

will true Instead of false Can.


Related articles: