Build a PHP7 development and testing environment on CentOS, centosphp7
Recently, the company has added a server for testing. Of course, because it is only for testing, we decided to install everything on a server for our own coding and testing, A little lab, and so on ...... It is easy to use, so I tried to build a complete LAMP development/test environment. Of course, I also stepped on countless pitfalls.
Get started!
Step 1 prepare the server
In the first step, let's get a server first. What is the server? Since it is used for testing, it is easy or not to make money, we recommend that you use AWS or your own machine to build a virtual machine. A development platform such as Vagrant can also be used. Here, we will use AWS, which is free for one year, AWS's advantage is that its access to foreign websites is extremely fast, and its disadvantage is that its access in China is extremely slow. Of course, you can use everything. Here we assume that we already have a CentOS 7 server, and suppose you can remotely connect to this server (such as ssh ).
Setp.2 install and configure LAMP
First, install Apache
Installing Apache is simple. You only need to install Apache through yum.
yum install httpd
After the installation is complete, run the systemctl command to start and set it to automatic start upon startup.
systemctl start httpd.servicesystemctl enable httpd.service
When a problem occurs, you can use systemctl status to check whether the service is correctly started, or view the access log and error log in the/var/log/httpd path to troubleshoot the problem.
The new CentOS has installed FirewallD, so if it is installed, we also need to tell FirewallD to open the firewall.
firewall-cmd --permanent --zone=public --add-service=httpfirewall-cmd --permanent --zone=public --add-service=httpsfirewall-cmd --reload
Install MySQL
First of all, We Need To Know That MySQL is not in the software source library of CentOS 7, and there is a corresponding alternative MariaDB in CentOS 7, because the shell company acquired MySQL, everyone was afraid that MySQL would shut down the source in the future, so they started a branch and started to start MariaDB, here we will manually add the MySQL software source to install MySQL to ensure that it is still the taste.
First, add the MySQL software source.
yum install http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
Next, install the MySQL client and server.
yum install mysql-server mysql-client
After the installation is complete, use mysql_secure_installation to complete the MySQL installation configuration.
You also need to configure a firewall for MySQL.
firewall-cmd --permanent --zone=public --add-service=mysqlfirewall-cmd --reload
Next we will install PHP 7
Similar to MySQL, the software source of the current release package does not contain PHP 7 and only includes PHP 5.x. Therefore, to install PHP 7, we also need to add the software source of PHP 7, according to the experiment in the past few days, the Remi PHP 7 software package and plug-in are relatively complete, so we should first add the Remi software source.
yum install scl-utilsyum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmyum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
After adding the software source, we can install PHP 7 and various common packages.
yum install php70 php70-php-mysqlnd php70-php-curl php70-php-simplexmlyum install php70-php-devel php70-php-gd php70-php-json php70-php-mcryptyum install php70-php-mbstring php70-php-opcache php70-php-pearyum install php70-php-pecl-apcu php70-php-pecl-geoip php70-php-pecl-imagickyum install php70-php-pecl-json-post php70-php-pecl-memcache php70-php-pecl-memcachedyum install php70-php-pecl-xmldiff php70-php-pecl-zip php70-php-pspell php70-php-soapyum install php70-php-tidy php70-php-xml php70-php-xmlrpc
Next, I have not installed PHP 7 to upgrade the server PHP 5.x. Therefore, if your server has installed PHP 5.x, You need to perform a simple upgrade, so here after installing the PHP 7 package, delete PHP 5.x and then install the php70-php package.
yum remove php php-common
Then
yum install php70-php
Then modify the configuration file and restart Apache. Note that the configuration file of PHP 7 is stored in the/etc/opt/remi/php70 path, related PHP 7 files are stored in the/opt/remi/php70/root/lib64/php path.
Okay, so we have a server with PHP 7 installed. You can play freely on it to enjoy the performance of PHP 7.
Setp.3 install SASL and Memcached
First, we all know what Memcached is, so I 'd like to say what SASL is. SASL's full name is Simple Authentication and Security Layer for Security Mechanism verification. To put it Simple, we use this thing to allow our Memcached to verify the user name and password before access, in addition, the Binary interface of Memcached requires SASL verification. Otherwise, the Writing an error: Unknown command error will be output (however, it is normal in PHP 5.x... So I have studied this issue for a while ).
Install SASL first.
yum install cyrus-sasl-plainyum install cyrus-sasl-develyum install cyrus-saslyum install cyrus-sasl-libyum install cyrus-sasl-gssapiyum install cyrus-sasl-md5
After the installation is complete, run the systemctl start saslauthd. service command to start this service. Next, we need to create a user to access Memcached through SASL authentication.
First, we need to modify the SASL configuration to use the user account and password in the current/etc/shadow for verification, therefore, the MECH = shadow in/etc/sysconfig/saslauthd tells SASL to use the account and password of the system for verification. After the modification, the system CTL restart saslauthd. service to restart the SASL process.
The following command can be used to verify whether the user can be correctly verified.
/usr/sbin/testsaslauthd -u username -p password
0: OK "Success. ", note that the username and password here are the usernames and passwords that must be properly logged on to the system, that is, they must be recorded in the/etc/shadow file.
Next we will install the libevent required by Memcached.
yum install libevent libevent-devel
Next, we need to compile and install Memcached through source code, because Memcached in yum does not enable SASL verification by default.
wget http://memcached.googlecode.com/files/memcached-1.4.15.tar.gztar zxvf memcached-1.4.15.tgzcd memcached-1.4.15./configure --enable-sasl --with-php-config=/opt/remi/php70/root/bin/php-configmakemake install
In this way, our Memcached has been compiled and installed. Next, we will add SASL verification and firewall rules for the Memcached service.
Saslpasswd2-a memcached-c [used to access memcached users] firewall-cmd -- permanent -- zone = public -- add-port = 11211/tcpfirewall-cmd -- reload
Next we start Memcached.
/Usr/local/bin/memcached-d-u [user used to access memcached]-p 11211-m 512-c 1024-S
In the above parameter,-S tells memcached that SASL verification must be enabled.
Step. End
At this point, the configuration of the development environment is over. Have a good time to play. You are welcome to throw bricks> _ <