centos soap centos7搭建apache服务器
centos系统编译安装nginx+php环境另加独立mysql教程
前端(nginx+php)ip:192.168.10.8
后端(独立mysql)ip:192.168.10.5
软件版本:libiconv-1.14.tar.gz mysql-5.1.63.tar.gz php-5.2.17.tar.gz php-5.2.17-fpm-0.5.14.diff.gz php-5.2.17-max-input-vars.patch
1.先在后端安装mysql
在192.168.10.5上只安装mysql.方法可以去看centos编译安装nginx+php-fpm+mysql里的mysql安装.
2.在前端安装php-fpm nginx和mysql-client
这里只说下安装mysql-client和php的编译安装.
代码如下 tar zxf mysql-5.1.63.tar.gz cd mysql-5.1.63
./configure--prefix=/usr/local/mysql--without-server
这里只需要加上--without-server就可以让mysql变成客户端了.
如果出现/bin/rm: cannot remove `libtoolt': No such file or directory,可以去看这篇文章Mysql安装:/bin/rm: cannot remove `libtoolt': No such file or directory.
没有问题后,执行命令:
代码如下 make make install
编译php的时候只需要加上--with-mysql=mysql客户端安装目录就可以了.这里我给出编译参数:
代码如下 ./configure--prefix=/usr/local/php--enable-fastcgi--enable-fpm--with-fpm-log=/var/log/php-fpm.log\
--with-fpm-conf=/etc/php-fpm.conf--with-fpm-pid=/var/run/php-fpm.pid--with-config-file-path=/etc\
--with-config-file-scan-dir=/etc/php.d--with-openssl--with-zlib--enable-bcmath--with-bz2--with-curl\
--enable-ftp--with-gd--enable-gd-native-ttf--with-jpeg-dir--with-png-dir--with-gettext--with-mhash\
--enable-mbstring--with-mcrypt--enable-soap--enable-zip--with-iconv=/usr/local/libiconv\
--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--without-pear
nginx的编译没有什么好说的了,我前面centos编译安装nginx+php-fpm+mysql这篇文章里已经有讲过了.
3.进行测试验证
当上面的一切都安装好之后,在后端的mysql里给出远程权限,如下:
代码如下 GRANT ALL PRIVILEGES ON*.* TO'root'@'%' IDENTIFIED BY'123456';
然后iptables上只允许192.168.10.8访问mysql端口,其他都拒绝.如:
代码如下 iptables-A RH-Firewall-1-INPUT-s 192.168.10.8-p tcp-m tcp--dport 3306-j ACCEPT
iptables-A RH-Firewall-1-INPUT-p tcp--dport 3306-j DROP
services iptables save
services iptables restart
然后在192.168.10.8上进行测试,是否可以远程连上mysql
mysql-h 192.168.10.5-u root-p
如果可以连上,就继续下一步的操作,不能连上的话请检查上面是否有错误的地方.
现在我们加个php页面来测试php是否可以连上mysql,脚本如下:
代码如下 ?php
$link=mysql_connect("192.168.10.5","root","123456");
if(!$link) echo"bad!";
else echo"ok!";
mysql_close();
?
成功的话是ok!的输出,失败的话是bad!的输出,我这里是成功的
mysql 5.5.x的只安装客户端.
需要的软件:libiconv-1.14.tar.gz mysql-5.5.25a.tar.gz
1.安装前的准备
安装前的准备,可以去看这篇文章centos编译安装nginx+php-fpm+mysql
2.安装libiconv
代码如下 ./configure--prefix=/usr/local/libiconv
make make install
3.只安装mysql客户端
代码如下 cmake. make mysqlclient libmysql
make install
这样就只安装了mysql客户端,然后可以输入whereis mysql来查看mysql安装位置.
whereis mysql
好了,可以看到跟yum安装的差不多.
4.安装php
以前mysql是5.1的时候,只需要加上--with-mysql=mysql客户端安装目录就可以了,但在mysql 5.5.x这个参数就要改变下了,下面是php的编译参数:
代码如下 ./configure--prefix=/usr/local/php--enable-fastcgi--enable-fpm--with-fpm-log=/var/log/php-fpm.log--with-fpm-conf=/etc/php-fpm.conf\
--with-fpm-pid=/var/run/php-fpm.pid--with-config-file-path=/etc--with-config-file-scan-dir=/etc/php.d\
--with-openssl--with-zlib--enable-bcmath--with-bz2--with-curl--enable-ftp\
--with-gd--enable-gd-native-ttf--with-jpeg-dir--with-png-dir--with-gettext--with-mhash\
--enable-mbstring--with-mcrypt--enable-soap--enable-zip--with-iconv=/usr/local/libiconv\
--with-mysql=shared,/usr--with-mysqli=shared,/usr/bin/mysql_config
大家可以看最后一行,--with-mysql=shared,/usr--with-mysqli=shared,/usr/bin/mysql_config这就是跟以前不同的行.好了,剩下的就不写了
如何搭建lamp(CentOS7+Apache+MySQL+PHP)环境
在网上搜资料,自己在本地虚拟机上尝试搭建,弄了整整一天一夜,终于弄好了.网上的资料,虽然很多,但大多都是重复的,拿去试了之后,又很多都不能得到正确的结果.最终找到了适合我的linux环境的搭建方式;在这里贴出来:度娘真不给力啊,没搜出来靠谱的方法。最后用喜乐搜找到的靠谱的教程。
这里还是要总结一下我的LAMP环境的搭建步骤。我先在电脑里装了虚拟机,在虚拟机中测试了数次之后,再在服务器上搭建的。说说我的环境:虚拟机是:VMware® Workstation 12.1.1 Pro;Linux系统用的是:CentOS-7-x86_64-DVD-1511.iso;(阿里云上也是用的CentOS7-64bit)准备好这两个之后,就开始一步一步搭建我们的LAMP环境了。
一、安装虚拟机
二、安装CentOS7
注意:以下安装,我都是用的root权限。
三、安装Apache1.安装yum-y install httpd2.开启apache服务systemctl start httpd.service3.设置apache服务开机启动systemctl enable httpd.service4.验证apache服务是否安装成功在本机浏览器中输入虚拟机的ip地址,CentOS7查看ip地址的方式为:ip addr(阿里云不需要用这种方式查看,外网ip已经在你主机列表那里给你写出来了的;)这里是访问不成功的(阿里云用外网访问,能成功,不需要做以下步骤)查了资料,说法是,CentOS7用的是Firewall-cmd,CentOS7之前用的是iptables防火墙;要想让外网能访问到apache主目录,就需要做以下的操作:firewall-cmd--permanent--zone=public--add-service=httpfirewall-cmd--permanent--zone=public--add-service=httpsfirewall-cmd--reload然后再访问外网ip,如果看到apache默认的页面--有Testing 123...字样,便是成功安装了apache服务了;
四、安装PHP1.安装yum-y install php2.重启apache服务systemctl restart httpd或者systemctl restart httpd.service然后,你可以写一个php文件在浏览器中运行一下了;eg:vi/var/www/html/info.phpi<?php phpinfo();?>Esc:wq然后,在自己电脑浏览器输入 192.168.1.1/info.php运行,会出现php的一些信息
五、安装MySQL我这里根据所学的那个教程,也安装了MariaDB1.安装
yum-y install mariadb*
2.开启MySQL服务systemctl start mariadb.service3.设置开机启动MySQL服务systemctl enable mariadb.service4.设置root帐户的密码mysql_secure_installation然后会出现一串东西,可以仔细读一下,如果你懒得读,就在提示出来的时候,按Enter就好了,让你设置密码的时候,你就输入你想要的密码就行,然后继续在让你选择y/n是,Enter就好了;当一切结束的时候,你可以输入mysql-uroot-p的方式,验证一下;
六、将PHP和MySQL关联起来yum search php,选择你需要的安装:yum-y install php-mysql
七、安装常用的PHP模块例如,GD库,curl,mbstring,...1.安装:yum-y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel2.重启apache服务systemctl restart httpd.service然后,再次在浏览器中运行info.php,你会看到安装的模块的信息;
至此,LAMP环境就搭建好了。
如何搭建lamp(CentOS7+Apache+MySQL+PHP)环境
标签:
Centos7如何安装PHP7最新版
方法一、简单安装(通过yum)
1.安装epel-release
rpm-ivh
2.安装PHP7的rpm源
rpm-Uvh
3.安装PHP7
yum install php70w
方法二、编译安装
1.下载php7
wget-O php7.tar.gz
2.解压php7
tar-xvf php7.tar.gz
3.进入php目录
cd php-7.0.4
4.安装依赖包
#直接复制下面一行(不包括本行)
yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
5.编译配置(如果出现错误,基本都是上一步的依赖文件没有安装所致)
嫌麻烦的可以从这一步起参考PHP官方安装说明:
./configure\
--prefix=/usr/local/php\
--with-config-file-path=/etc\
--enable-fpm\
--with-fpm-user=nginx\
--with-fpm-group=nginx\
--enable-inline-optimization\
--disable-debug\
--disable-rpath\
--enable-shared\
--enable-soap\
--with-libxml-dir\
--with-xmlrpc\
--with-openssl\
--with-mcrypt\
--with-mhash\
--with-pcre-regex\
--with-sqlite3\
--with-zlib\
--enable-bcmath\
--with-iconv\
--with-bz2\
--enable-calendar\
--with-curl\
--with-cdb\
--enable-dom\
--enable-exif\
--enable-fileinfo\
--enable-filter\
--with-pcre-dir\
--enable-ftp\
--with-gd\
--with-openssl-dir\
--with-jpeg-dir\
--with-png-dir\
--with-zlib-dir\
--with-freetype-dir\
--enable-gd-native-ttf\
--enable-gd-jis-conv\
--with-gettext\
--with-gmp\
--with-mhash\
--enable-json\
--enable-mbstring\
--enable-mbregex\
--enable-mbregex-backtrack\
--with-libmbfl\
--with-onig\
--enable-pdo\
--with-mysqli=mysqlnd\
--with-pdo-mysql=mysqlnd\
--with-zlib-dir\
--with-pdo-sqlite\
--with-readline\
--enable-session\
--enable-shmop\
--enable-simplexml\
--enable-sockets\
--enable-sysvmsg\
--enable-sysvsem\
--enable-sysvshm\
--enable-wddx\
--with-libxml-dir\
--with-xsl\
--enable-zip\
--enable-mysqlnd-compression-support\
--with-pear\
--enable-opcache
6.正式安装
make make install
7.配置环境变量
vi/etc/profile
在末尾追加
PATH=$PATH:/usr/local/php/bin
export PATH
执行命令使得改动立即生效
source/etc/profile
8.配置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
9.启动php-fpm
/etc/init.d/php-fpm start