Centos安装lamp环境 PHP7.0

1.安装Apache

1 #一键安装apache
2 yum install httpd
3 
4 #启动apche
5 /etc/init.d/httpd start                     #方法1 
6 service httpd start                         #方法2
7 
8 #设置apache开机自动启动
9 chkconfig --levels 235 httpd on

2.安装PHP7

 1 #YUM安装所需开发包
 2 yum install wget make gcc gcc-c++ bison autoconf patch \
 3 pcre-devel zlib-devel openssl-devel net-snmp-devel \
 4 ncurses-devel libxml2-devel bzip2-devel gd-devel libcurl-devel \
 5 php-mysql
 6 
 7 yum install libmcrypt-devel 8 9 #下面安装libmcrypt-2.5.8 10 wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz 11 tar zxvf libmcrypt-2.5.8.tar.gz 12 cd libmcrypt-2.5.8 13 ./configure 14 make 15 make install 16 17 #下载PHP7.0 18 wget http://am1.php.net/distributions/php-7.0.5.tar.xz 19 xz -d php-7.0.5.tar.xz 20 tar xvf php-7.0.5.tar 21 cd php-7.0.5 22 23 #执行./configure配置 24 ./configure --prefix=/usr/local/php \ 25 --enable-fpm --enable-gd-native-ttf --enable-gd-jis-conv --enable-soap \ 26 --enable-zip --enable-pcntl --enable-sockets --enable-mbstring --enable-xml \ 27 --with-bz2 --with-openssl --with-iconv --with-zlib --with-curl \ 28 --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-mcrypt \ 29 --with-mysqli --with-pdo-mysql --enable-bcmath 30 31 32 #最后安装 33 make 34 make install

3.配置Apache配置文件

1 vi /etc/httpd/conf/httpd.conf #编辑文件
2 
3 #NameVirtualHost *:80  (大概990行,找到后把#去掉)
4 
5 #在402行 修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php Default.php index.html.var (设置默认首页文件,增加index.php)
6 
7 #保存退出
8 #重启Apache
9 service httpd restart

4.配置PHP配置文件

 1 vi /etc/php.ini #编辑
 2 
 3 date.timezone = PRC #在946行 把前面的分号去掉,改为date.timezone = PRC
 4 
 5 magic_quotes_gpc = On #在745行 打开magic_quotes_gpc来防止SQL注入
 6 
 7 short_open_tag = ON #在229行支持php短标签
 8 
 9 #保存退出
10 
11 #重启Apache
12 service httpd restart

猜你喜欢

转载自www.cnblogs.com/www-php/p/9121836.html