Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install lamp-php in Centos environment

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to install lamp-php in Centos environment". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's ideas to study and learn how to install lamp-php in Centos environment.

one。 Environmental preparation

Bridging mode

Can access the external network

# ping www.baidu.com

If you have access to ping, you can access the external network.

Turn off the firewall

# systemctl disable firewalld / / disable firewall # systemctl stop firewalld / / disable firewall

Close selinux

# vim / etc/selinux/config

Change to:

Selinux=disabled

Configure yum Feed

# cd / etc/yum.repos.d/# mkdir repo_bak/ / create backup source folder # mv * .repo repo_bak/ put the source files in the backup folder # wget http://mirrors.aliyun.com/repo/centos-7.repo / / configure Ali source # wget http://mirrors.163.com/.help/centos7-base-163.repo / / configure NetEQ source # ls / / column File out / etc/yum.repos.d/ directory centos-7.repo centos-base-163.repo repo.bak# yum clean all / / clear all yum caches in the system # yum makecache / / generate yum cache # yum list | grep epel-release / / View epel source list # yum install-y epel-release / / install epel source # ls / / epel source installed successfully More than the original epel.repo and epel-testing.repo file centos-7.repo centos-base-163.repo epel.repo epel-testing.repo repo.bak# wget-o / etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo / / download Ali source epel source # lscentos7-base-163.repo centos-7.repo epel-7.repo epel.repo epel-testing.repo repo_bak# Yum clean all / / clear the system yum cache again # yum makecache / / regenerate the new yum cache # yum repolist enabled / / View the yum sources available to the system # yum repolist all / / View all yum sources

Delete the old version

# yum-y remove php

two。 Apache

1. Install apache

# yum install httpd

two。 Configure apache

# vim / etc/httpd/conf/httpd.conf// search # addtype application/x-gzip .gz .tgz / / and then add # addtype application/x-httpd-php .php / / search # ifmodule dir_module// add index.php// under directoryindex to modify # servername www.example.com:80# servername localhost:80

Modify the default web site directory

Find: documentroot "/ var/www/html"

Modify to: documentroot "/ var/www"

Find:

Modified to:

3. Start the apache service

# systemctl start httpd

4. View httpd status

Systemctl status httpd

three。 Php 7.0.7

1. Download the php source code package of the corresponding version of centos

Php-7.0.7.tar.gz

two。 Decompress the source package

# tar zxvf php-7.0.7.tar.gz

3. Go to the unzipped package to compile and install the dependent packages required for php

# yum install-y gcc gcc-c++ make automake autoconf gd file bison patch mlocate flex diffutils zlib zlib-devel pcre pcre-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel libcurl libcurl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers openldap-devellibxslt-devel kernel-devel libtool-libs readline-devel gettext-devel libcap-devel php-mcrypt libmcrypt libmcrypt-devel recode -devel gmp-devel icu libxslt libxslt-devel php-devel# yum-y install libxslt-devel*# yum-y install perl*# yum-y install httpd-devel# find /-name apxs / / the path obtained is: / usr/bin/apxs is used when compiling parameters Is a key parameter for configuring apache to support php

4. Compilation parameters

. / configure\

-- prefix=/usr/local/php\

-- with-config-file-path=/usr/local/php/etc\

-- with-zlib-dir\

-- with-freetype-dir\

-- enable-mbstring\

-- with-libxml-dir=/usr\

-- enable-xmlreader\

-- enable-xmlwriter\

-- enable-soap\

-- enable-calendar\

-- with-curl\

-- with-zlib\

-- with-gd\

-- with-pdo-sqlite\

-- with-pdo-mysql\

-- with-mysqli\

-- with-mysql-sock\

-- enable-mysqlnd\

-- disable-rpath\

-- enable-inline-optimization\

-- with-bz2\

-- with-zlib\

-- enable-sockets\

-- enable-sysvsem\

-- enable-sysvshm\

-- enable-pcntl\

-- enable-mbregex\

-- enable-exif\

-- enable-bcmath\

-- with-mhash\

-- enable-zip\

-- with-pcre-regex\

-- with-jpeg-dir=/usr\

-- with-png-dir=/usr\

-- with-openssl\

-- enable-ftp\

-- with-kerberos\

-- with-gettext\

-- with-xmlrpc\

-- with-xsl\

-- enable-fpm\

-- with-fpm-user=php-fpm\

-- with-fpm-group=php-fpm\

-- with-fpm-systemd\

-- with-apsx2\

-- disable-fileinfo

6. Compile and install

# make & & make install

7. Check the php version after installation

# / usr/local/php/bin/php-v

8. Edit / etc/profil add environment variable

# vim / etc/profil

Add in

Path=$path:/usr/local/php/binexport path

9. Update environment variables

# source / etc/profile

10. View environment variabl

# echo $path

11. View php version

# php-v

twelve。 Configure php profile php-fpm

# cp php.ini-production / etc/php.ini# cp / usr/local/php/etc/php-fpm.conf.default / usr/local/php/etc/php-fpm.conf# cp / usr/local/php/etc/php-fpm.d/www.conf.default / usr/local/php/etc/php-fpm.d/www.conf# cp sapi/fpm/init.d.php-fpm / etc/init.d/php-fpm# chmod + x / etc/init.d/php- Fpm# vim / usr/local/php/etc/php-fpm.conf# configuration error log: # # error_log = / usr/local/php/var/php-fpm.log## configuration pid file: # # pid = / usr/local/php/var/run/php-fpm.pid## save exit # cd / usr/local/src/php-7.2.4# cp. / sapi/fpm/php-fpm.service to / usr/lib/systemd/system/

13. Start php-fpm

Configure Boot Boot php-fpm:

# systemctl enable php-fpm

Start php-fpm

# systemctl start php-fpm

View statu

# systemctl status php-fpm ● php-fpm.service-the php fastcgi process managerloaded: error (reason: invalid argument) active: inactive (dead) dec 13 14:37:27 localhost.localdomain systemd [1]: [/ usr/lib/systemd/system/php-fpm.service:7] not an absolute path, ignoring: ${prefix} / va … Fpm.piddec 13 14:37:27 localhost.localdomain systemd [1]: [/ usr/lib/systemd/system/php-fpm.service:8] executable path is not absolute, ignoring: $... Pm.confdec 13 14:37:27 localhost.localdomain systemd [1]: php-fpm.service lacks both execstart= and execstop= setting. Refusing.dec 13 14:37:27 localhost.localdomain systemd [1]: cannot add dependency job for unit php-fpm.service, ignoring: unit is not loaded properl... Gument.hint: some lines were ellipsized, use-l to show in full.

14. Test the configuration of php-fpm

# Test php-fpm configuration / usr/local/php/sbin/php-fpm-t/usr/local/php/sbin/php-fpm-c / usr/local/php/etc/php.ini-y / usr/local/php/etc/php-fpm.conf-t # launch php-fpm/usr/local/php/sbin/php-fpm/usr/local/php/sbin/php-fpm-c / usr/local/php/etc/php.ini-y / usr/local/php/etc / php-fpm.conf# closes php-fpmkill-int `cat / usr/local/php/var/run/php- fpm.pid` # restart php-fpmkill-usr2 `cat / usr/local/php/var/run/php- fpm.pid`

15. Solution.

# vim / usr/lib/systemd/system/php-fpm.service

Change ${prefix} and ${exec_prefix} to / usr/local/php and save them

/ / restart the system # reboot

16. Restart apache and php-fpm

# systcl restart httpd# systcl restart php-fpm

17. Install the corresponding xdebug

# copy the entire phpinfo.php page content and paste it into https://xdebug.org/wizard.php to determine the xdebug version

Operate and install according to the prompt document

18. Yum install phpmyadmin

# yum install phpmyadmin

Modify the configuration file

# vi / etc/httpd/conf.d/phpmyadmin.conf adddefaultcharset utf-8 # apache 2.4 # require ip 127.0.0.1 # comment out # require ip:: 1 # comment out require all granted # add # apache 2.2 order deny Allow deny from all allow from 127.0.0.1 allow from:: 1 # apache 2.4 # require ip 127.0.0.1 # comment out # require ip:: 1 # comment out require all granted # add # apache 2.2 order deny,allow deny from all allow from 127.0.0.1 allow from:: 1

Modify phpmyadmin configuration file

# vi / etc/phpmyadmin/config.inc.php// modifies the following content: # $cfg ['servers'] [$I] [' host'] = '127.0.0.1 politics # $cfg [' servers'] [$I] ['user'] =' root';# $cfg ['servers'] [$I] [' password'] = '123456'

Restart apache

# systemctl restart httpd

Test after installing mysql

# browser address bar input: server ip/phpmyadmin

four。 Install mysql 5.7

1. Installation source

# rpm-uvh https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm

2. Yum install mysql

# yum install mysql-community-server

3. Start mysql

# systemctl start mysqld# systemctl enable mysqld / / Boot

4. Before changing the root default password, you can turn off the password policy as needed. If the password policy is not turned off, the new password requires a combination of uppercase and lowercase letters, numbers and characters.

# vim / etc/ my.cnf [mysqld] validate_password = off// restart to make the modified password policy effective # systemctl restart mysqld

5. Modify the root default password for mysql

/ / View the default password # grep 'temporary password' / var/log/mysqld.log// default password is:) u4fbpurkwangevf # 2018-12-18 a temporary password is generated for root@localhost:) u4fbpurkwangevf

Run the Security Settings Wizard and change the default password

Mysql_secure_installation// enter the root default password enter password for user root: * / set the new password new password:***re-enter new password:*** / / do you want to change the root password change the password for root? ((press y | y for yes, any other key for no): / / enter directly, indicating whether no// deletes anonymous user remove anonymous users? (press y | y for yes, any other key for no): yUnip / disable root remote login to disallow root login remotely? (press y | y for yes, any other key for no): y remove test database and access to it / delete test database? (press y | y for yes, any other key for no): YUnip / reload permission table reload privilege tables now? (press y | y for yes, any other key for no): uroot / you can also use mysql to change the root password mysql-uroot-palter user 'root'@'localhost' identified by' new password directly; for secure root, you can only log in locally, and you can create a new remote user with administrator privileges, mysql-uroot-password *. * to 'username' @% 'identified by' login password 'with grant option;flush privileges;exit as needed Thank you for reading, the above is the content of "how to install lamp-php in Centos environment". After the study of this article, I believe you have a deeper understanding of how to install lamp-php in Centos environment, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report