How to build a LAMP environment in centos7.2

炎欲天舞
Release: 2023-03-14 18:00:01
Original
1376 people have browsed it

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!

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template