设为首页 收藏本站
查看: 1670|回复: 0

Yum安装LAMP(Centos7.2+Apache2.4+Mariadb5.5.56+PHP7.0.24)

[复制链接]

尚未签到

发表于 2017-10-20 09:17:46 | 显示全部楼层 |阅读模式
一、简介
    最近客户提出需要使用PHP7的需求,第一次是给客户安装的是LNMP-full的集成环境,但是后面不便于添加扩展模块,以及本人对Nginx不是很了解,经协商后改用LAMP,以下内容为真实环境搭建完成后为了方便记忆在虚拟环境中的配置,和真是环境基本一样



二、准备环境

操作系统IP地址相关软件包
Centos7.210.0.0.11php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel
三、实施步骤

1、使用yum安装Apache、Mariadb、PHP等软件包以及相关软件包,我们的Yum使用系统默认Yum源。

yum install httpd httpd-devel mariadb mariadb-server mariadb-libs mariadb-devel -y

2、启动服务并设置开机自启以及查看服务状态
systemctl enable httpd mariadb
systemctl start httpd mariadb

[iyunv@localhost ~]# systemctl status httpd mariadb
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since 五 2017-10-20 04:29:17 CST; 6s ago
     Docs: man:httpd(8)
           man:apachectl(8)
Main PID: 12304 (httpd)
   Status: "Processing requests..."
   CGroup: /system.slice/httpd.service
           ├─12304 /usr/sbin/httpd -DFOREGROUND
           ├─12306 /usr/sbin/httpd -DFOREGROUND
           ├─12307 /usr/sbin/httpd -DFOREGROUND
           ├─12308 /usr/sbin/httpd -DFOREGROUND
           ├─12309 /usr/sbin/httpd -DFOREGROUND
           └─12310 /usr/sbin/httpd -DFOREGROUND

10月 20 04:29:17 localhost systemd[1]: Starting The Apache HT...
10月 20 04:29:17 localhost httpd[12304]: AH00558: httpd: Coul...
10月 20 04:29:17 localhost systemd[1]: Started The Apache HTT...

● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since 五 2017-10-20 04:29:18 CST; 5s ago
  Process: 12354 ExecStartPost=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
  Process: 12313 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera_recovery ] && VAR= ||   VAR=`/usr/bin/galera_recovery`; [ $? -eq 0 ]   && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
  Process: 12305 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Main PID: 12327 (mysqld)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           └─12327 /usr/sbin/mysqld

10月 20 04:29:18 localhost mysqld[12327]: 2017-10-20  4:29:18...
10月 20 04:29:18 localhost mysqld[12327]: 2017-10-20  4:29:18...
10月 20 04:29:18 localhost mysqld[12327]: 2017-10-20  4:29:18...
10月 20 04:29:18 localhost mysqld[12327]: 2017-10-20  4:29:18...
10月 20 04:29:18 localhost mysqld[12327]: 2017-10-20  4:29:18...
10月 20 04:29:18 localhost mysqld[12327]: 2017-10-20  4:29:18...
10月 20 04:29:18 localhost mysqld[12327]: 2017-10-20  4:29:18...
10月 20 04:29:18 localhost mysqld[12327]: 2017-10-20  4:29:18...
10月 20 04:29:18 localhost mysqld[12327]: Version: '10.1.19-M...
10月 20 04:29:18 localhost systemd[1]: Started MariaDB databa...
Hint: Some lines were ellipsized, use -l to show in full.

3、防火墙允许80端口通过

[iyunv@localhost ~]# firewall-cmd --permanent --zone=public  --add-service=http
success
[iyunv@localhost ~]# firewall-cmd --permanent --zone=public  --add-service=https
success
[iyunv@localhost ~]# firewall-cmd --reload
success

4、检查80端口是否被监听
[iyunv@localhost ~]# netstat -tulp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name   
tcp        0      0 0.0.0.0:ssh             0.0.0.0:*               LISTEN      1061/sshd           
tcp        0      0 localhost:smtp          0.0.0.0:*               LISTEN      1813/master         
tcp6       0      0 [::]:mysql              [::]:*                  LISTEN      12327/mysqld        
tcp6       0      0 [::]:http               [::]:*                  LISTEN      12304/httpd         
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN      1061/sshd           
tcp6       0      0 localhost:smtp          [::]:*                  LISTEN      1813/master

5、使用浏览器测试是否能够访问到Apache服务
浏览器中输入IP地址即可:http://10.0.0.11/
QQ截图20171020091716.png
返回以上内容证明Apache已经搭建成功

6、初始化数据库
[iyunv@localhost ~]# mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
注:这里设置的数据库密码是devops

进入数据库并查看
[iyunv@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \\g.
Your MariaDB connection id is 10
Server version: 10.1.19-MariaDB MariaDB Server

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\\h' for help. Type '\\c' to clear the current input statement.

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| column_stats              |
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| gtid_slave_pos            |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| index_stats               |
| innodb_index_stats        |
| innodb_table_stats        |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| roles_mapping             |
| servers                   |
| slow_log                  |
| table_stats               |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
30 rows in set (0.01 sec)

exit;退出数据库


7、更新Yum源并安装PHP7.0.24
rpm -Uvh https://dl.fedoraproject.org/pub ... latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

使用Yum安装PHP7.0.24
yum install php70w php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel -y

就这一条命令,就可以安装了下面的拓展了!
php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-exif, php-fileinfo, php-filter, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib
激动吧?别急,还有更牛的!使用Yum即可安装需要的扩展
安装包         提供的拓展
php70w          mod_php , php70w-zts
php70w-bcmath      
php70w-cli      php-cgi, php-pcntl, php-readline
php70w-common   php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-exif, php-fileinfo, php-filter, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml   , php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib
php70w-dba      
php70w-devel        
php70w-embedded     php-embedded-devel
php70w-enchant      
php70w-fpm      
php70w-gd      
php70w-imap     
php70w-interbase        php_database, php-firebird
php70w-intl     
php70w-ldap     
php70w-mbstring     
php70w-mcrypt      
php70w-mysql        php-mysqli, php_database
php70w-mysqlnd      php-mysqli, php_database
php70w-odbc     php-pdo_odbc, php_database
php70w-opcache      php70w-pecl-zendopcache
php70w-pdo      php70w-pdo_sqlite, php70w-sqlite3
php70w-pdo_dblib        php70w-mssql
php70w-pear     
php70w-pecl-apcu   
php70w-pecl-imagick
php70w-pecl-memcached   
php70w-pecl-mongodb
php70w-pecl-redis   
php70w-pecl-xdebug  
php70w-pgsql        php-pdo_pgsql, php_database
php70w-phpdbg      
php70w-process      php-posix, php-sysvmsg, php-sysvsem, php-sysvshm
php70w-pspell      
php70w-recode      
php70w-snmp     
php70w-soap     
php70w-tidy     
php70w-xml      php-dom, php-domxml, php-wddx, php-xsl
php70w-xmlrpc   

例如需要安装xml扩展
yum install php70w-xml

8、检验
检验PHP版本
[iyunv@localhost ~]# php -v
PHP 7.0.24 (cli) (built: Sep 30 2017 10:10:28) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.24, Copyright (c) 1999-2017, by Zend Technologies

检验PHP扩展

[iyunv@localhost ~]# php -m
[PHP Modules]
bz2
calendar
Core
ctype
curl
date
dom
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
igbinary
json
libxml
mbstring
memcached
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
redis
Reflection
session
shmop
SimpleXML
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib

[Zend Modules]
Zend OPcache


9、重启Apache并测试
在/var/www/html/创建index.php文件
[iyunv@localhost ~]# cat /var/www/html/index.php

phpinfo();
?>

浏览器中输入http://10.0.0.11/
QQ截图20171020091727.png
搭建成功!!

参考文档:
http://blog.csdn.net/zhezhebie/article/details/73325663
http://www.cnblogs.com/me80/p/7218883.html

小弟入行不久,有不对的地方还请大家指出


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-405644-1-1.html 上篇帖子: CentOS7基于源码编译安装LAMP的wordpress应用的实现 下篇帖子: centos6.5下使用lnmp架构安装nextcloud云盘
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表