How to build a LAMP environment on centos7.2

**1. Apache, php, **mysqlinstallation

1. Install php

**Step-by-step installation: **

Download php: wget http://cn2.php.NET/get/php-7.0.11.tar.gz/from/this/mirror
Unzip: tar -zxvf mirror
Install gcc: yum install -y gcc gcc+ libxml2-devel
Compile: ./configure –prefix=/usr/local/php7 –enable-fpm

There is also a relatively simple yum installation method (online installation, convenient and easy):

yum install -y php wait for the installation to complete

Then enter the following command to install the php component:

yum install -y php-MySQL php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt

To test whether php is installed normally, enter php echo "XXX", if it shows could not open input file echo, it means the installation is successful, or write a php file and execute it

2. Install apache

Need server networking

Installation: yum install -y httpd

Run: /bin/systemctl start httpd.service

After executing the running command, the effect is not visible. At this time, enter the view apache service status command to check whether the service has been started:

View status: service httpd status

Apache start service: systemctl start httpd

Apache stop service: systemctl stop httpd

To test whether the apache service is normally turned on, enter the public network ip of cloud server in our local browser. I will take 118.89.32.6 as an example here

As shown above, it means apache is started normally;

3. Install mysql

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpmrpm -ivh mysql-community-release-el7-5.noarch.rpmyum install mysql-community-server
Restart mysql service after successful installation

service mysqld restart

The first time mysql is installed, there is no password for the root account
Method of setting password:

Enter mysql -uroot to enter the mysql database
mysql> set password for ‘root’@‘localhost’ = password(‘mypasswd’);
mysql> exit

Remote authorization to connect to mysql
mysql>GRANT ALL PRIVILEGES ON . TO'root'@'%' IDENTIFIED BY'The database password you want to set' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;

annotation:

1.RPM: RPM Package Manager (RPM Package Manager), a packaging and installation tool for Internet download packages, which is included in some Linux distributions. It generates files with a .RPM extension. Similar to Dpkg.

**Corresponding command: **

In Terminal, the basic installation instructions are as follows:

rpm -i xv-3.10a-13.i386.rpm

If your Internet connection is fast enough, you can also install the application software directly from the Internet, just add the appropriate URL path before the software file name.

As a software package management tool, RPM manages the information of all RPM program components installed in the system. We can also use RPM to uninstall related applications.

rpm -e xv

The common parameters of RPM also include:

-Vh: display the installation progress;

-U: Upgrade software package;

-Qpl: List the file information in the RPM software package;

-Qpi: List the description information of the RPM software package;

-Qf: Find which RPM software package the specified file belongs to;

-Va: Check all RPM software packages and find missing files;

-Qa: Find the corresponding file, such as rpm -qa mysql

2.YUM: Yum (full name Yellow dog Updater, Modified) is a Shell front-end package manager in Fedora, RedHat and CentOS. Based on RPM package management, it can automatically download and install RPM packages from a designated server, automatically handle dependencies, and install all dependent software packages at one time, without the need for tedious download and installation again and again.

**Corresponding command: **

Install the software (take foo-xxxrpm as an example): yum install foo-xxxrpm

Delete software: yum remove foo-xxxrpm or yum erase foo-xxxrpm

Upgrade software: yum upgrade foo or yum update fo

Query information: yum info foo

Search software (take the foo field as an example): yum search foo

Show package dependencies: yum deplist foo

check-update Check for updateable packages
clearn clear all
clean packages clear temporary package files (files under /var/cache/yum)
clearn headers clear rpm header files
clean oldheaders clean old rpm header files
deplist lists the dependencies of the package
list installable and updateable RPM packages
list installed installed packages
list extras packages that are installed and not in the repository
info Installable and updateable RPM package information
info installed Information about the installed package (-qa parameter is similar)
install[RPM package] Installation package
localinstall installs local RPM packages
update[RPM package] update package
upgrade Upgrade system
search[Keyword] search package
provides[Keyword] Search for specific package file name
reinstall[RPM package] reinstall the package
repolist displays the configuration of the resource library
resolvedep specified dependency
remove[RPM package] uninstall package

3.WGET

wget is a free tool that automatically downloads files from the Internet. It supports downloading through the three most common TCP/IP protocols, HTTP, HTTPS, and FTP, and can use HTTP proxy. The name "wget" comes from the combination of "World Wide Web" and "get".

The so-called automatic download means that wget can continue to execute in the background after the user exits the system until the download task is completed.

If the above two lines of commands are executed successfully and complete is displayed, you can use Navicat or the like to manage Mysqldatabase

Two, configure apache, php

2.1 Configure apache

Use the httpd -V command to view the directory where the Apache configuration file httpd.conf file is located:

As shown in the red circle, the apache configuration file is in the etc/httpd/conf/ directory

Enter the directory, cd /etc/httpd/conf

Content to be modified:

1、 Add #Load PHP processing module

LoadModule php5_module modules/libphp5.so#Add processing of PHP and other suffixes

AddType application/x-httpd-php .php

2、 modify

DirectoryIndex index.html

Change to

DirectoryIndex index.php index.html

3、 Modify the default access path

Documentroot = “/var/www”

For convenience, all subsequent directories are modified to /var/www

After modifying all the configurations, click the esc key and hold down shift+; enter the bottom row mode, enter wq to save and exit.

2.2 Configure php.ini

**1、 Enter the php -ini command to view the php.ini file path: here is no longer the above picture, too. **

2、 Find the place with the most extensions, remove the previous; to enable PHP to support mysql, and specify the value of –with-mysql when configuring. If it was not configured during the previous installation, you need to reconfigure, compile, and install

; extension=php_mysql.dll

To use phpmyadmin or mysqli function to open, and specify the value of –with-mysqli when configuring. If it was not configured during the previous installation, you need to reconfigure, compile, and install

; extension=php_mysqli.dll

To PHP support png, jpg, gif, etc. (phpcmsV9 must) open

; extension=php_gd2.dll

Large character set, support conversion between multiple character sets

; extension=php_mbstring.dll

php5 default The time difference is eight hours from Beijing time (eight hours less)

Why? The PHP5 series version has a new time zone setting. The default is Greenwich Mean Time, which is exactly 8 hours away from the East 8 District where China is located. Find

; date.timezone =

Remove; and modify it to date.timezone = PRC

Except E_NOTICE type errors (Notice) are not reported, all others are reported, find error_reporting = E_ALL

Change to error_reporting = E_ALL & ~E_NOTICE

3、 Find extension_dir

Remove the semicolon in front and modify it to extension_dir = "your php installation directory/ext"

Php installation directory view:

**4、 Enter rpm -ql php in linux to view the php installation directory: **

After modifying all the configurations, restart apache:

systemctl stop httpd

systemctl start httpd

or:

systemctl restart httpd

Three, one-click installation: (convenient and save trouble^_^)

A one-click installation package is required. I am using the installation package provided by Alibaba Cloud:

Open xshell and enter the xftp interface: drag the local installation package into the root directory of the remote server:

Switch to the xshell window and enter the root directory: cd /root

Type the following commands in sequence to install:

chmod -R 777 sh-1.5.5

cd sh-1.5.5

. /install.sh

The remaining configuration steps are the same as above, and the specific directories are as follows:

After that, you can upload your project to the root directory of the website via xftp.

The specific operation method of the above centos7.2 to build a LAMP environment is all the content shared by the editor. I hope to give you a reference.

Recommended Posts

How to build a LAMP environment on centos7.2
Build a LAMP development environment on Ubuntu 16.04
(1) Centos7 installation to build a cluster environment
How to install jdk1.8 on centOS7
How to install MySQL on CentOS 8
How to install Memcached on CentOS 8
How to install R on CentOS 8
How to install Virtualbox on CentOS 8
How to install TensorFlow on CentOS 8
How to install TeamViewer on CentOS 8
How to install Perl 5 on CentOS
How to install Git on CentOS 8
How to install Gradle on CentOS 8
How to install Elasticsearch on CentOS 8
How to install Java on CentOS 8
How to install Go on CentOS 8
How to install GCC on CentOS 8
How to install Yarn on CentOS 8
How to install Nginx on CentOS 8
How to install Asterisk on CentOS 7
How to install Jenkins on CentOS 8
How to install Vagrant on CentOS 8
How to install Python 3.8 on CentOS 8
How to install Tomcat 9 on CentOS 8
How to install Webmin on CentOS 8
How to install Ruby on CentOS 8
How to install Skype on CentOS 8
How to install htop on CentOS 8
How to install Elasticsearch on CentOS 8
Build Nginx environment on Linux (CentOS)
How to install Postgresql on CentOS 8
How to install Wordpress on Centos
How to install TeamViewer on CentOS 8
How to add swap on CentOS 7
How to install MongoDB on CentOS 7
How to install Odoo 13 on CentOS 8
How to install Apache on CentOS 8
How to disable SELinux on CentOS 8
How to install OpenCV on CentOS 8
How to install PHP on CentOS 8
How to install MongoDB on CentOS 8
First try to build a Ceph storage cluster on Centos7
How to set up a Masterless Puppet environment on Ubuntu 14.04
How to build nfs service on ubuntu16.04
How to increase swap space on CentOS 8
How to install Apache Maven on CentOS 8
How to install Apache Kafka on CentOS 7
[Graphic] How to install tomcat on centos
R&D: How To Install Python 3 on CentOS 7
How to install GCC compiler on CentOS 7
How to modify the hostname on CentOS 8
How to install offline JDK1.8 on centos7.0
How to establish a multi-node Elastic stack cluster on RHEL8 /CentOS8
Build k8s1.9.9 on centos7
How to install and configure Elasticsearch on CentOS 7
How to install Visual Studio Code on CentOS 8
How to install and use Docker on CentOS 7
CentOS6.7 build LNMP environment
How to quickly build Nginx server under CentOS
How to install RPM packages on CentOS Linux
Centos7.6 build LNMP environment