Home Backend Development PHP Tutorial How to build a LAMP environment in centos7.2

How to build a LAMP environment in centos7.2

Aug 07, 2017 am 09:26 AM
lamp environment

1. Installation of apache, php and mysql

Installation order: apache/mysql and finally install php. The order of the first two does not matter.

1. Installationapache

Requires server networking

Installation:yum install -y httpd

Run: /bin/systemctl start httpd.service

After executing the run command, you will not see the effect. At this time, enter the check apache service status command to check whether the service has been started:

View status: service httpd status

## Apache Start service: systemctl start httpd

ApacheStop service: systemctl stop httpd

## To test whether the apache service is started normally, enter the public address of the cloud server in our local browser Networkip, I am taking 118.89.32.6 as an example

As shown above, it means

apache is opened normally;

2. Install mysql

  rpm -ivh mysql-community-release-el7-5.noarch.rpm
  yum install mysql-community-server   After successful installation, restart
mysql service

  

  service mysqld restart

Initial installation

mysql is the root account and does not have a password How to set a password
## Enter

mysql -uroot

to enter the mysql database    mysql>
set password for 'root'@'localhost' = password('mypasswd');    mysql>
exit##    If an error is reported: can't find any matching row in the user table Execute the following statement

## mysql> grant all privileges on testDB.* to 'test'@' 1.1.1.1'identified by 'yourpassword';

This time the prompt is executed successfully, but don’t forget to execute it again:

mysql> FLUSH PRIVILEGES; Make changes in time Write grant table

Remote authorization connectionmysql

 

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 is RPM Package ManagerRPMSoftware package manager),A packaging and installation tool for downloading packages from the Internet, which is included in some Linux distribution. It generates files with .RPM extension. Similar to Dpkg.

Corresponding command:

In Terminal, the basic installation instructions are as follows:

 rpm i xv3.10a13. i386.rpm

If your connection speed is fast enough, you can also install the application software directly from the network. You only need to add the appropriate URL# before the file name of the software. ##path.

As a software package management tool, RPM manages the data of all RPM program components that have been installed on the system . We can also use RPM to uninstall related applications.

rpm

e xv

Commonly used parameters of RPM

also include:

                                      -vh:Display installation progress;  -qpl

: List the file information in the

RPM software package;

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

   -qf: Find the specified file Which RPM software package it belongs to;

   -Va: Verify all RPM Software package, find missing files;

   -qa: Find corresponding files, such asrpm -qa mysql 2.

YUM

Yum (full name is Yellow dog Updater, Modified

) Is a

Shell in Fedora and RedHat and CentOS Front-end package manager. Based on RPM package management, it can automatically download RPM packages from the designated server and install them. It can automatically handle dependencies and install all dependent software packages at once, without having to do it again and again. Download and install. Corresponding command:

Installation software(Take foo-x.x.x.rpm

as an example)

yum install foo-x.x.x.rpm

Removal softwareyum remove foo-x.x.x.rpmoryum erase foo-x.x.x.rpm

Upgrade software: yum upgrade foo or yum update fo

Query informationyum info foo

Search software (to include the foo field For example)yum search foo

Display package dependenciesyum deplist foo
  -e Execute silently
  -t Ignore errors
  -R[minutes] Set waiting time
  -y Automatic response yes
   --skip-broken ignore dependency issues
   --nogpgcheck ignoreGPGVerification

  check-update Check for updateable packages
  clearn Clear all
   clean packages Clear temporary package files (files under /var/cache/yum )
   clearn headers clearrpmHeader file
  clean oldheaders Clear the oldrpmHeader file
  deplist List package dependencies
   list Installable and updateableRPMPackage
  list installed Installed package
   list extras Already installed and not in the resource library Package
  info Installable and updateableRPMPackage information
  info installed Information of installed packages(-qa similar parameters)
  install[RPM Package] Installation package
  localinstall Install local RPMPackage
  update[RPMPackage] Update package
  upgrade Upgrade system
  search[Keywords] Search package
   provides[Keywords] Search for a specific package file name
  reinstall[RPMPackage ] Reinstall the package
  repolist Display the configuration of the resource library
  resolvedep Specify dependencies
  remove[RPMPackage] Uninstall package

3. WGET

 wget is a free tool that automatically downloads files from the Internet and supports HTTPHTTPSFTP The three most common TCP/IP Protocol Download, and can use HTTP proxy. "wget" This name comes from "World Wide Web" and "get" # The combination of ##.

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, then is OK Use Navicat and the like to manage Mysqldatabase

##3. Install php

Step-by-step installation:

Download php
Decompression: tar -zxvf mirror
## Install gcc: yum install -y gcc gcc+ libxml2-devel

Compilation: ./configure --prefix=/usr/local/php7 --enable-fpm

There is also a relatively simple yum installation method

(online installation , convenient and trouble-free)

    Yum install -y php

Wait for the installation to be completed

                                                             dedgenegene in us in it in phoenix ethyl etherate ethyl ethyl ether ethyl ether inline Installation:

 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## Test whether php is installed normally, enter php echo

XXX, if could not open input file echo is displayed, it means the installation has been successful, or you can write a php file and execute it 二、

Configuration

apachephp##2.1Configuration

apache

Use the httpd -V

command to view the configuration file of

apachehttpd.conf The directory where the file is located:

As shown in the red circle, apache

configuration The file is in the

etc/httpd/conf/ directory. Enter the directory, cd /etc/httpd/conf

Content to be modified:

1

,

Add

#Load PHPProcessing moduleLoadModule php5_module modules/libphp5.so#Add

PHP

and other suffix processing AddType application/x-httpd-php .php2

Modify

DirectoryIndex index.html

Change to

DirectoryIndex index.php index.html3

, modify the default access path

Documentroot = "/var/www"

For convenience, all subsequent

Directory

are changed to

/var/www

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

2.2Configurationphp.ini

 1, input php --iniCommand to view php.iniFile path: The picture above is no longer here, too motor.

 2, find the place with the most extension, remove the preceding ; PHP supports mysql, and must be specified during configuration --with-mysql The value, if it was not configured during previous installation, needs to be reconfigured, compiled and installed

 ;extension=php_mysql.dll

 To usephpmyadmin Or mysqli function is opened, and the value of --with-mysqli must be specified when configuring. If it was not configured during previous installation, it is required Reconfigure, compile, install

;extension=php_mysqli.dll

Requires PHP supportpng, jpg, gif, etc.(phpcmsV9must)Open

;extension=php_gd2.dll

Large character set,Support multiple character sets Open the conversion

 ;extension=php_mbstring.dll

php5DefaultThe time is eight hours different 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 the same as the East 88 hours,find

 ;date.timezone =

 will; Remove it and modify it to date.timezone = PRC

Except for errors of type E_NOTICE(Notice )Do not report, others will report,Searcherror_reporting = E_ALL

Change Intoerror_reporting = E_ALL & ~E_NOTICE

  3, findextension_dir

Remove the semicolon in front and change it to extension_dir = “Your php installation directory/ext

Php Check the installation directory:

4, enter rpm -ql php in linux ViewphpInstallation directory:

## After modifying all configurationsRestartapache

Systemctl stop httpd

systemctl start httpd

 

Or:

systemctl restart httpd

3. One-click installation: (convenient and easy ^_^)

## 

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

Open

xshell,Enter the xftp interface: will Drag the local installation package into the remote server root directory:

Switch to the

xshell window and enter the root directory: cd /root

in sequence Type the following command to install

:

##chmod -R 777 sh-1.5.5
  1. cd sh-1.5.5
  2. ./install.sh

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

After that, you can use xftp Upload your project to the root directory of the website.

The above is the detailed content of How to build a LAMP environment in centos7.2. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Unable to boot into Windows recovery environment Unable to boot into Windows recovery environment Feb 19, 2024 pm 11:12 PM

Windows Recovery Environment (WinRE) is an environment used to repair Windows operating system errors. After entering WinRE, you can perform system restore, factory reset, uninstall updates, etc. If you are unable to boot into WinRE, this article will guide you through fixes to resolve the issue. Unable to boot into the Windows Recovery Environment If you cannot boot into the Windows Recovery Environment, use the fixes provided below: Check the status of the Windows Recovery Environment Use other methods to enter the Windows Recovery Environment Did you accidentally delete the Windows Recovery Partition? Perform an in-place upgrade or clean installation of Windows below, we have explained all these fixes in detail. 1] Check Wi

What are the differences between Python and Anaconda? What are the differences between Python and Anaconda? Sep 06, 2023 pm 08:37 PM

In this article, we will learn about the differences between Python and Anaconda. What is Python? Python is an open source language that places great emphasis on making the code easy to read and understand by indenting lines and providing whitespace. Python's flexibility and ease of use make it ideal for a variety of applications, including but not limited to scientific computing, artificial intelligence, and data science, as well as creating and developing online applications. When Python is tested, it is immediately translated into machine language because it is an interpreted language. Some languages, such as C++, require compilation to be understood. Proficiency in Python is an important advantage because it is very easy to understand, develop, execute and read. This makes Python

11 Ways to Set Environment Variables on Windows 3 11 Ways to Set Environment Variables on Windows 3 Sep 15, 2023 pm 12:21 PM

Setting environment variables on Windows 11 can help you customize your system, run scripts, and configure applications. In this guide, we'll discuss three methods along with step-by-step instructions so you can configure your system to your liking. There are three types of environment variables System environment variables – Global variables are the lowest priority and are accessible to all users and applications on Windows and are typically used to define system-wide settings. User Environment Variables – Higher priority, these variables only apply to the current user and process running under that account, and are set by the user or application running under that account. Process environment variables – have the highest priority, they are temporary and apply to the current process and its sub-processes, providing the program

What are the PHP integrated environment packages? What are the PHP integrated environment packages? Jul 24, 2023 am 09:36 AM

PHP integrated environment packages include: 1. PhpStorm, a powerful PHP integrated environment; 2. Eclipse, an open source integrated development environment; 3. Visual Studio Code, a lightweight open source code editor; 4. Sublime Text, a A popular text editor, widely used in various programming languages; 5. NetBeans, an integrated development environment developed by the Apache Software Foundation; 6. Zend Studio, an integrated development environment designed for PHP developers.

Common problems and solutions for Laravel environment configuration file .env Common problems and solutions for Laravel environment configuration file .env Mar 10, 2024 pm 12:51 PM

Common problems and solutions for Laravel environment configuration file .env When using the Laravel framework to develop projects, the environment configuration file .env is very important. It contains key configuration information of the project, such as database connection information, application keys, etc. However, sometimes there are some common problems when configuring the .env file. This article will introduce these problems and provide solutions, and attach specific code examples for reference. Problem 1: Unable to read the .env file when we have configured the .env file

Easily delete the Conda environment: Tips for efficiently cleaning up useless environments Easily delete the Conda environment: Tips for efficiently cleaning up useless environments Jan 04, 2024 am 08:15 AM

Deleting Conda Environments with One Click: Tips for Quickly Cleaning Up Useless Environments With the rapid development of data science and machine learning, the need to use Python for development and analysis is becoming stronger and stronger. Conda, as a popular Python package manager and environment management tool, is widely used in project development and environment configuration. However, over time, we often leave many useless Conda environments on the computer, which not only wastes disk space, but may also lead to environment clutter and unnecessary trouble. This article will introduce

How to configure the go language environment How to configure the go language environment Jan 06, 2021 am 11:37 AM

Go language environment configuration method: 1. Download the go language compiler and double-click to run the installation program; 2. Accept the license agreement and click next; 3. Set the installation directory and click OK; 4. After the installation is completed, change the go installation directory Just add the bin directory to the environment variable.

Explore the similarities and differences between pipenv environments and virtual environments Explore the similarities and differences between pipenv environments and virtual environments Jan 16, 2024 am 08:50 AM

The difference and connection between the pipenv environment and the virtual environment requires specific code examples. With the increasing popularity of Python, more and more developers are using virtual environments in Python projects to isolate the dependent libraries of different projects. The virtual environment can ensure that the Python libraries and their versions that the project depends on are properly managed to avoid various conflicts and version inconsistencies. However, in the past, using virtual environments required third-party libraries such as virtualenv and virtualenvwrapper. soon

See all articles