Centos安装LAMP环境

1, cent6: lamp (yum安装)

在这里插入图片描述

a, 软件包安装: httpd2.2, mysql5.1, php5.3

##### 使用更高版本的php( 比如zabbix要求最低php5.4) : 
##### rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
##### yum -y install  $(yum list |grep php55w |awk '{print  $1}') --skip-broken #56w,70w,71w

### 1, 准备环境
yum -y install httpd mysql-server mysql php php-mysql 
yum -y install mod_ssl mod_auth_mysql php-ldap php-mbstring 
# [vagrant@c6 ~]$ mysql_secure_installation 
# ....
# Reload privilege tables now? [Y/n] y
#  ... Success!
# Cleaning up...
# All done!  If you've completed all of the above steps, your MySQL
# installation should now be secure.
# Thanks for using MySQL!
service mysqld start
service httpd start

### 2, 测试使用
[vagrant@c6 html]$ pwd
/var/www/html
[vagrant@c6 html]$ ls
index.html  index.php  mysql.php

[vagrant@c6 html]$ cat index.html 
123
[vagrant@c6 html]$ curl localhost/index.html
123
[vagrant@c6 html]$ cat index.php 
<?php phpinfo(); ?>
[vagrant@c6 html]$ curl localhost/index.php |head -5
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 52083    0 52083    0     0  5015k      0 --:--:-- --:--:-- --:--:-- 5651k
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
<html><head>
<style type="text/css">
body {background-color: #ffffff; color: #000000;}
body, td, th, h1, h2 {font-family: sans-serif;}

[vagrant@c6 html]$ cat mysql.php 
<?php
 $res=mysql_connect("localhost","root","123");
if (!$res) echo "faild,mysql";
else echo "ok,mysql";
?>
[vagrant@c6 html]$ curl localhost/mysql.php
ok,mysql

b, 查看php编译参数

[vagrant@c6 ~]$ php -i |grep -i configure
Configure Command =>  ./configure  --build=x86_64-redhat-linux-gnu  \
--host=x86_64-redhat-linux-gnu --target=x86_64-redhat-linux-gnu  \
--program-prefix= --prefix=/usr --exec-prefix=/usr  \
--bindir=/usr/bin --sbindir=/usr/sbin --sysconfdir=/etc  \
--datadir=/usr/share --includedir=/usr/include --libdir=/usr/lib64  \
--libexecdir=/usr/libexec --localstatedir=/var  \
--sharedstatedir=/var/lib --mandir=/usr/share/man  \
--infodir=/usr/share/info --cache-file=../config.cache  \
--with-libdir=lib64 --with-config-file-path=/etc  \
--with-config-file-scan-dir=/etc/php.d --disable-debug  \
--with-pic --disable-rpath --without-pear --with-bz2  \
--with-exec-dir=/usr/bin --with-freetype-dir=/usr \
--with-png-dir=/usr --with-xpm-dir=/usr --enable-gd-native-ttf  \
--with-zlib --with-layout=GNU --without-gdbm --with-gettext --with-gmp  \
--with-iconv --with-jpeg-dir=/usr --with-openssl --with-pcre-regex=/usr  \
--enable-exif --enable-ftp --enable-magic-quotes --enable-sockets  \
--enable-sysvmsg --with-kerberos --enable-ucd-snmp-hack --enable-shmop  \
---enable-sysvsem --enable-sysvshm  -enable-calendar --without-sqlite \
 --with-libxml-dir=/usr --enable-xml --with-system-tzdata  \
 --enable-force-cgi-redirect --enable-pcntl  \
 --with-imap=shared --with-imap-ssl --enable-mbstring=shared --enable-mbregex \
 --with-gd=shared --enable-bcmath=shared  \
 --enable-dba=shared --with-db4=/usr --with-xmlrpc=shared --with-ldap=shared  \
 --with-ldap-sasl --with-mysql=shared,/usr  \
 --with-mysqli=shared,/usr/lib64/mysql/mysql_config --enable-dom=shared  \
 --with-pgsql=shared --enable-wddx=shared  \
 --with-snmp=shared,/usr --enable-soap=shared --with-xsl=shared,/usr  \
 --enable-xmlreader=shared --enable-xmlwriter=shared \
  --with-curl=shared,/usr --enable-fastcgi --enable-pdo=shared  \
  --with-pdo-odbc=shared,unixODBC,/usr  \
  --with-pdo-mysql=shared,/usr/lib64/mysql/mysql_config  \
  --with-pdo-pgsql=shared,/usr --with-pdo-sqlite=shared,/usr  \
  --with-sqlite3=shared,/usr --enable-json=shared --enable-zip=shared  \
  --without-readline --with-libedit --with-pspell=shared  \
  --enable-phar=shared --with-tidy=shared,/usr --enable-sysvmsg=shared  \
  --enable-sysvshm=shared --enable-sysvsem=shared  \
  --enable-posix=shared --with-unixODBC=shared,/usr --enable-fileinfo=shared  \
  --enable-intl=shared --with-icu-dir=/usr  \
  --with-enchant=shared,/usr --with-recode=shared,/usr 

c, 查看php模块化配置文件

[vagrant@c6 ~]$ cat /etc/httpd/conf.d/php.conf |grep -Ev "^#|^$"
<IfModule prefork.c>
  LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
  LoadModule php5_module modules/libphp5-zts.so
</IfModule>

AddHandler php5-script .php
AddType text/html .php
DirectoryIndex index.php

1, cent6: lamp (src编译安装)

参考博文:https://www.linuxidc.com/Linux/2015-08/121078.htm

a, httpd2.4

httpd2.4源码编译: https://blog.csdn.net/eyeofeagle/article/details/103754637

b, mysql5.7

mysql5.7二进制安装: https://blog.csdn.net/eyeofeagle/article/details/103363966

c, php5.5

##1, 编译安装php5.5
yum install libxml2-devel
yum -y install bzip2-devel
yum -y install libcurl-devel
yum -y install libpng-devel
yum install -y libmcrypt-devel
ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/local/mysql/lib/libmysqlclient_r.so

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/httpd2.4/bin/apxs \
--with-config-file-path=/usr/local/httpd2.4/conf --with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config --with-gd \
--enable-gd-native-ttf --with-zlib --with-mcrypt \
--with-pdo-mysql=/usr/local/mysql --enable-shmop --enable-soap \
--enable-sockets --enable-zip  --enable-fpm --enable-mbstring \
--with-zlib-dir --with-bz2 --with-curl

##2, 配置httpd支持php5.5
[root@c6 httpd2.4]# ls modules/ |grep php
libphp5.so

[root@c6 httpd2.4]# cat >>  /usr/local/httpd2.4/conf/httpd.conf <<EOF
LoadModule php5_module        modules/libphp5.so
<Directory "/usr/local/httpd2.4/htdocs">
    Options Indexes FollowSymLinks
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>

<IfModule dir_module>
   DirectoryIndex index.html index.php
</IfModule>

 <IfModule mime_module>
    AddType application/x-httpd-php .php .phtml
    AddType application/x-httpd-php-source .phps
</IfModule>
EOF

##3, 测试apache-php使用
[root@c6 httpd2.4]# ls htdocs/
index.html  index.php  mysql.php
[root@c6 httpd2.4]# cat htdocs/index.php
<?php phpinfo(); ?> 

[root@c6 httpd2.4]# cat htdocs/mysql.php 
<?php
	$link = mysqli_connect('localhost', 'root', '123');
	if (!$link) {
		die('Could not connect: ' . mysqli_error());
	}
	echo 'Connected successfully';
	mysqli_close($link);
?>

[root@c6 conf]# ps -ef |grep httpd
root      1026     1  0 Feb26 ?        00:00:05 /usr/local/httpd2.4/bin/httpd -k start
daemon   22326  1026  0 03:12 ?        00:00:00 /usr/local/httpd2.4/bin/httpd -k start
daemon   22327  1026  0 03:12 ?        00:00:00 /usr/local/httpd2.4/bin/httpd -k start
daemon   22328  1026  0 03:12 ?        00:00:00 /usr/local/httpd2.4/bin/httpd -k start
root     22415 21590  0 03:14 pts/3    00:00:00 grep httpd

service httpd restart
chown -R daemon. /usr/local/httpd2.4/htdocs/
chmod -R 770 /usr/local/httpd2.4/htdocs/

[root@c6 httpd2.4]# curl localhost/mysql.php
Connected successfully
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

根哥的博客

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值