Configure the latest LAMP environment and the latest lamp Environment

Source: Internet
Author: User
Tags install perl

Configure the latest LAMP environment and the latest lamp Environment

 

This article explains how to configure Apache2.4 + MySQL5.7 + PHP7.1.8 in centos7.3.


I. Apache

 

1. Check whether the httpd package is available
Yum list | grep httpd

 

2. install Apache
Yum install httpd

 

3. Configure servername
Vi/etc/httpd/conf/httpd. conf
Modify this line: ServerName localhost: 80

 

4. Start
Systemctl start httpd

If the startup fails, please pay attention to the error message. Generally, the newly installed software will start successfully. After the startup fails, I use the ps-aux | grep httpd command to find that the process is occupied, so the kill-9 Process the httpd process is killed and then started.

 

5. Set startup
Chkconfig httpd on

 


Ii. MySQL

1. Install MySQL Source
Yum localinstall http://dev.mysql.com/get/mysql57-community-release-el7-7.noarch.rpm

 

2. Install MySQL
Yum install mysql-community-server

 

3. Start MySQL
Systemctl start mysqld

 

4. Get the password
Grep 'temporary password'/var/log/mysqld. log
Get this line A temporary password is generated for root @ localhost: Jqqskhz1Wr (? The password after the colon

 

5. Enter MySQL
Mysql-uroot-p

 

6. Change the password
Alter user 'root' @ 'localhost' identified by *********** (enclose the password in quotation marks. Note that the MySQL password must be complex and not complex, and an error is reported)

 

7. Open Remote Access Permissions
Use mysql;
Update user set host = '%' where user = 'root ';
The percent sign is equivalent to the asterisk (*), indicating that all connections are allowed. You can change it to an IP address to allow only connections from this IP address, or set it to 192.168. %. % or 192.168.0.1/9 indicates that one ip segment is allowed for connection, or you can add a few more data entries to set different ip addresses to allow connection.

 

8. MySQL permission management. (Write dry goods only. If you don't understand it, Google it yourself)

 

Create user 'myqiutianc' @ '%' identified '*********';
Create a user named myqiutian. Because % is used, any IP address can be logged on, but the database cannot be seen after logon. All new user permissions are disabled by default.

 

Please use this line for lazy people:
Grant all on *. * to myqiutian; grant all permissions to all the tables in the user's database.

 

Grant select on Database A. * to myqiutian;
Authorize myqiutian to view all tables in database A, but only for database.

 

Grant insert on Database A. user to myqiutian;
Authorize the myqiutian user to perform insert operations on the user table in database A, but only for the user table and select and insert operations.

 

Revoke permissions
Revoke insert on Database A. user from myqiutian;
Note: Before revoking permissions, you 'd better use show grants for myqiutian. This SQL statement checks the permissions that the user has and the permissions that are added, and the insert statement you add cannot revoke all permissions.

 

MySQL permission workflow:
---------> Connect to MySQL
---------> Query the user table and check the account password. Check whether the host field allows your ip address to be connected.
---------> If the value of other permission fields in the user table is Y, the user has the permission for all fields in all databases. If the value is N, go down.
---------> Query the database table database permission control table to obtain the permissions that the user has on which databases. A record in this table represents a database.
---------> Query the tables_priv table to obtain the table control permission of the user. If the user in the db table has the insert permission on Database A, no matter how the table is set in Table s_priv, The isnert permission of the user is not affected, if the single table permission in the tables_priv table is not all, continue
---------> To query columns_priv table field control, you can set the table field control permission.

 

 

The four tables are user db tables_priv columns_priv in sequence.

 

Note:
If all the user tables are Y, the following table is not queried.
When select is N in the user table, you can specify which databases can be viewed by the user in the db table.
However, whether it is table control or field control, the select field of the upper-level permission table (except the user table) must be Y.
If other permissions are set in the upper-level table, the lower-level table is not used.


For specific permission fields, refer to the official manual:
Http://www.yesky.com/imagesnew/software/mysql/manual_Privilege_system.html#Privileges_provided


8. The refresh permission takes effect immediately.
Flush privileges;


Don't forget that there is a configuration file cat/etc/my. cnf to view the stored data and log location.

 


Iii. PHP7

1. Upload the php source package to Linux through ftp, or download it online through wget. I didn't find the latest version of 7.1.8, so I went to the official website to download it for use on Linux,
Put the package in/usr/local and cd it. (Ftp content please view my previous article, PHP 7 Package please click the sharing link to download: http://pan.baidu.com/s/1dEYQjoX)

 

2. Extract
Tar-zxvf php-7.1.8.tar.gz

 

 

3. Enter the decompressed package to install some necessary dependencies.
Yum-y install libjpeg-devel libpng-devel freetype-devel libxml2 libxml2-devel zlib-devel curl-devel openssl-devel

 

4. Install gcc
Yum install gcc

 

5. Install
Yum-y install libxslt-devel *
Yum-y install perl *
Yum-y install httpd-devel
Find/-name apxs:/usr/bin/apxs
So the -- with-apsx2 path is/usr/bin/apxs

 

5. Configuration
. /Configure -- prefix =/usr/local/php7 -- with-curl -- with-freetype-dir -- with-gd -- with-gettext -- with-iconv-dir -- with-kerberos -- with-libdir = lib64 -- with-libxml-dir -- with-mysqli -- with-openssl -- with-pcre-regex -- with-pdo-mysql -- with-pdo-sqlite --- pear -- with-png-dir -- with-xmlrpc -- with-xsl -- with-zlib -- enable-fpm -- enable-bcmath-enable-inline-optimization -- enable-gd-native- ttf -- enable-mbregex -- enable-mbstring -- enable-opcache -- enable-pcntl -- enable-shmop -- enable-soap -- enable-sockets -- enable-sysvsem -- enable-xml -- enable- zip -- enable-pcntl -- with-curl -- with-fpm-user = nginx -- enable-ftp -- enable-session -- enable-xml-with-apxs2 =/usr/bin/apxs


6. Compile
Make

 

7. Check this blog for compilation errors:
Http://www.cnblogs.com/sweetXiaoma/p/5855732.html
I would like to thank the bloggers for sharing their experiences to benefit scholars.

 

8. Compile check
Make test
This step can be skipped, because it always prompts errors, but does not provide error information. If there is a problem, the compilation may fail. Since the compilation is successful, you can install the SDK directly.

 

9. Installation
Make install

 

10. Add Environment Variables
Vi/etc/profile
Add at the end:
PATH = $ PATH:/usr/local/php7/bin
Export PATH

 

11. Make changes take effect immediately
Source/etc/profile

 

12. View php version
Php-v
(If any problem occurs, check whether the added environment variable is the bin directory in the PHP installation directory)


13. generate necessary files
Cp php. ini-production/usr/local/php7/etc/php. ini
Cp sapi/fpm/php-fpm/usr/local/php7/etc/php-fpm
Cp/usr/local/php7/etc/php-fpm.conf.default/usr/local/php7/etc/php-fpm.conf
Cp/usr/local/php7/etc/php-fpm.d/www. conf. default/usr/local/php7/etc/php-fpm.d/www. conf

 


14. Configuration
If an error is reported, you can click this line to check which file has the following error:
Systemctl status httpd. service

 

Modify the default welcome page of Apache:
Vi/etc/httpd/conf. d/welcome. conf
Change/usr/share/httpd/noindex to/var/www

 

Modify Apache configuration:
Vi/etc/httpd/conf/httpd. conf

DocumentRoot "/var/www /"
(Note that the path/var/www is custom. There are several paths in the configuration file. If you change the path, you can change it by searching globally)

Find
AddType application/x-compress. Z
AddType application/x-gzip. gz. tgz
Add
AddType application/x-httpd-php. php
AddType application/x-httpd-php-source. php7

Search for the following part of <IfModule dir_module> and add index. php.
<IfModule dir_module>
DirectoryIndex index.html index. php
</IfModule>

Search for the following line:
LoadModule php7_module modules/libphp7.so
If not, manually add the file. Otherwise, the PHP file becomes downloaded.

 

Configure the domain name at the bottom
<VirtualHost *: 80>
DocumentRoot/var/www
ServerName www. Your Domain Name. com
ServerAlias your domain name. com
<Directory/phpstudy/www>
Options + Indexes + FollowSymLinks + ExecCGI
AllowOverride All
Order Deny, Allow
Allow from all
</Directory>
</VirtualHost>


15. Test
Create index. php In the www directory
Add <? Php phpinfo ();?>
Access: www. Your Domain Name. com

 


Thanks for reading

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.