编辑启动脚本,更改权限,并加入系统服务,设置开机启动;
[root@localhost apache2]# vi /etc/init.d/httpd
[root@localhost apache2]# chmod 755 /etc/init.d/httpd
[root@localhost apache2]# chkconfig --add httpd
[root@localhost apache2]# chkconfig httpd on
检查apache配置参数;-l 列出加载的静态模块 -M列出所有加载的模块;
[root@localhost ~]# apachectl -t
Syntax OK
[root@localhost ~]# apachectl -l
[root@localhost ~]# apachectl -M
编译安装php 5.6.8
[root@localhost src]# tar zxvf php-5.6.8.tar.gz
[root@localhost src]# cd php-5.6.8
[root@localhost php-5.6.8]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif --disable-ipv6
[root@localhost php-5.6.8]# make && make install
[root@localhost php-5.6.8]# echo $?
0
拷贝php配置文件
[root@localhost php-5.6.8]# cp /usr/local/src/php-5.6.8/php.ini-production /usr/local/php/etc/php.ini
修改时区
[root@localhost php-5.6.8]# vi /usr/local/php/etc/php.ini
date.timezone =Asia/Shanghai
配置php与apache
1、修改AddType参数,红色为新添加
[root@localhost php-5.6.8]# vi /usr/local/apache2/conf/httpd.conf
# AddType allows you to add to or override the MIME configuration
#AddType application/x-gzip .tgz
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
#AddType text/html .shtml
2、修改index.html,红色为新添加
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
3、修改severname,红色为新添加
#ServerName :80
ServerName localhost:80
4、测试解析php,在/usr/local/apache2/htdocs/目录下,写一个测试php文件
[root@localhost php-5.6.8]# cat /usr/local/apache2/htdocs/test.php
<?php
echo "PHP解析正常\n";
?>
[root@localhost htdocs]# /etc/init.d/httpd restart
[root@localhost htdocs]# curl localhost/test.php
PHP解析正常
或者写一个phpinfo();
至此LAMP环境搭建完毕。
LAMP平台安装Xcache和Memcached加速网站运行
CentOS 6.5系统安装配置LAMP(Apache+PHP5+MySQL)服务器环境
Ubuntu 14.04 配置 LAMP+phpMyAdmin PHP(5.5.9)开发环境