基于openVZ的CentOS6.X安装lamp环境

////////////////////2016/07/08/////////////

/////////////////环境 centos6.x//////////

//////////////by   xbw///////////////////////


由于VPS服务器内存256M,有点小,并且基于openVZ,开始想着直接用最熟悉的xampp,结果出现内存不足的情况,

然后,又自行编译安装php,mysql,apache,到了安装php时出现了如下问题,问题如下:

基于openVZ的CentOS6.X安装lamp环境_第1张图片

提示内存不足,也是内存不足,首先想到的挂swap, swap详情传送门。

以下的操作都要在root用户下进行,首先先建立一个分区,采用dd命令比如

dd if=/dev/zero of=/home/swap bs=1024 count=512000

这样就会创建/home/swap这么一个分区文件。文件的大小是512000个block,一般情况下1个block为1K,所以这里空间是512M。接着再把这个分区变成swap分区。

/sbin/mkswap /home/swap

再接着使用这个swap分区。使其成为有效状态。

/sbin/swapon /home/swap

现在再用free -m命令查看一下内存和swap分区大小,就发现增加了512M的空间了。不过当计算机重启了以后,发现swap还是原来那么大,新的swap没有自动启动,还要手动启动。那我们需要修改/etc/fstab文件,增加如下一行

/home/swap              swap                    swap    defaults        0 0
你就会发现你的机器自动启动以后swap空间也增大了。

然后发现我的VPS是基于openVZ的,要哭了,貌似没有权限添加swap,然后又搜到了一个方法,

在./configure脚本后面加上

--disable-fileinfo
这下真的可以了。

记录一下编译过程

安装编译环境

<span style="font-size:12px;">

</span><span style="font-size:14px;">yum install -y gcc gcc-c++  make zlib zlib-devel pcre pcre-devel  libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel openssl openssl-devel openldap openldap-devel nss_ldap openldap-clients openldap-servers</span>

进入php的解压目录


<span style="font-size:14px;">./configure --prefix=/usr/local/php --enable-fpm  --with-mcrypt=/usr/local/libmcrypt --with-zlib --enable-mbstring --with-openssl --with-mysql --with-mysqli --with-mysql-sock --with-gd --with-jpeg-dir=/usr/lib --enable-gd-native-ttf  </span><span style="font-family: 'Microsoft Yahei', 'Helvetica Neue', Helvetica, Arial, sans-serif;"><span style="font-size:12px;">--disable-fileinfo</span><span style="font-size:14px;"> </span></span><span style="font-size:14px;">--enable-pdo --with-pdo-mysql --with-gettext --with-curl --with-pdo-mysql --enable-sockets --enable-bcmath --enable-xml --with-bz2 --enable-zip --enable-freetype</span>
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
error 1
checking for xml2-config path... 
configure: error: xml2-config not found. Please check your libxml2 installation.
(看提示就明白 是一个lib库没装  先用 yum search 名字 看是否能搜到名字 ,找到名字后 把软件包 开发包装上)
解决办法
yum install libxml2-devel.x86_64
error 2
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>
这是ssl没装
解决办法
yum  install  openssl.x86_64 openssl-devel.x86_64 -y
error 3
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
这是bzip2软件包没有安装
解决办法
yum install bzip2-devel.x86_64 -y
error 4
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
curl和curl库文件没有安装
解决办法
yum install libcurl.x86_64 libcurl-devel.x86_64 -y
error 5
checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... yes
checking for floorf... yes
configure: error: jpeglib.h not found
GD库没有安装
解决办法
yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y
error 6
checking for stdarg.h... (cached) yes
checking for mcrypt support... yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
libmcrypt库没有安装 ,要是不能用yun安装的话  就要去下载个gz包 自己编译安装
(编译安装  ./configure --piefix=/usr/local/libmcrypt   make && make install)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
要是错误里面含有mysql的  那是mysql-devel 没有安装
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
出现
Generating files configure: creating ./config.status creating main/internal_functions.c creating main/internal_functions_cli.c
+--------------------------------------------------------------------+
| License:                                                           |
| This software is subject to the PHP License, available in this     |
| distribution in the file LICENSE.  By continuing this installation |
| process, you are bound by the terms of this license agreement.     |
| If you do not agree with the terms of this license, you must abort |
| the installation process at this point.                            |
+--------------------------------------------------------------------+
Thank you for using PHP.
config.status: creating php5.spec
config.status: creating main/build-defs.h
config.status: creating scripts/phpize
config.status: creating scripts/man1/phpize.1
config.status: creating scripts/php-config
config.status: creating scripts/man1/php-config.1
config.status: creating sapi/cli/php.1
config.status: creating sapi/fpm/php-fpm.conf
config.status: creating sapi/fpm/init.d.php-fpm
config.status: creating sapi/fpm/php-fpm.8
config.status: creating sapi/fpm/status.html
config.status: creating main/php_config.h
config.status: executing default commands
表示安装成功
 make  && make install
make完成之后  到php的解压目录 找出php.ini-production 复制到 /usr/local/php/lib/ 下 文件名改成php.ini
cp php.ini-production /usr/local/php/lib/php.ini 
完成..

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

解决configure: error: Please reinstall the libcurl distribution
让server服务器的php环境支持curl的时候, 在编译时出现如下报错
checking for cURL in default path... not found
configure: error: Please reinstall the libcurl distribution -
easy.h should be in /include/curl/
其实就是curl的dev包没有安装, 解决方案:
# yum -y install curl-devel
再重新编译OK。

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

解决后
make && make install
apache配置文件httpd.conf相关修改以支持PHP
vim /usr/local/apache/conf/httpd.conf
1. 添加php支持。
AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps
2. 添加默认索引页面index.php,再找到“DirectoryIndex”,在index.html后面加上“ index.php”
DirectoryIndex index.html index.php
3. 不显示目录结构,找到“Options Indexes FollowSymLinks”,修改为
Options FollowSymLinks
4. 开启Apache支持伪静态,找到“AllowOverride None”,修改为
AllowOverride All
保存httpd.conf配置,然后再执行以下两行命令
 chown -R nobody. /usr/local/apache/htdocs/
chmod -R 777 /usr/local/apache/htdocs/
 service httpd restart

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

centos源不能安装libmcrypt-devel,由于版权的原因没有自带mcrypt的包
有两种方法解决,一种是使用第三方源,这样还可以使用yum来安装,简单方便,坏处是第三方源多少有中不可靠的感觉。
解决办法一
1、安装第三方yum源
wget http://www.atomicorp.com/installers/atomic
sh ./atomic
2、使用yum命令安装
yum  install  php-mcrypt  libmcrypt  libmcrypt-devel

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

在虚拟机中编译PHP出现make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1错误
编译PHP5.5 make 时出现错误
make: *** [ext/fileinfo/libmagic/apprentice.lo] Error 1
解决办法
这是由于内存小于1G所导致.
在./configure加上选项:
--disable-fileinfo
Disable fileinfo support 禁用 fileinfo

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


-bash: php: command not found 命令找不到
Linux命令找不到?(找不到命令)
这个问题其实很简单,如果你在终端输入一个命令,而系统提示你说命令没有找到(Command not found)的话,要么是因为你没有装相应的软件包,要么就是因为路径设置的问题。如果是因为软件包的问题,那没有别的好说的,安装相应的软件包就好了。而另外一种情况,则需要对用户的路径进行设置。
-bash: ls: command not found 或者 -bash: ll: command not found
原因:在设置环境变量时,编辑profile文件没有写正确,导致在命令行下 ls等命令不能够识别。
解决方案:
export PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
bash: php: command not found 
解决:
export PATH=$PATH:/usr/local/php/bin

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Can't Change to Run as User 'Mysql'. Please Check That the User Exists!
So you’ve recently made a change to your mysql installation and see the following in
 /var/lib/mysql/localhost.localdomain.err
080317 14:08:50 mysqld started
080317 14:08:50 [ERROR] Fatal error: Can't change to run as user 'mysql' ; Please check that the user exists!
080317 14:08:50 [ERROR] Aborting
080317 14:08:50 [Note] /usr/sbin/mysqld: Shutdown complete
080317 14:08:50 mysqld ended
 This is a problem that many a time spent on google has not found the result, so I am writing here what exactly to do in this situation …
 First off
 cd /var/lib/mysql
Now run
ls -la
 No doubt you will see something similar to this:
drwx--x--x   2 27 mysql     4096 Mar 17 14:05 mysql
Notice the “27 mysql”, the user no longer existsing in /etc/passwd.
This is fairly simple to fix.
adduser mysql
chown mysql:mysql -R /var/lib/mysql
Now start up Mysql i.e. “service start mysql” and everyhing should be fine.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


MySQL: Starting MySQL….. ERROR! The server quit without updating PID file解决办法
1 问题
[root@localhost mysql]# /etc/rc.d/init.d/mysql status
MySQL is not running, but lock file (/var/lock/subsys/mysql[FAILED]
[root@localhost mysql]# /etc/rc.d/init.d/mysql start
Starting MySQL...The server quit without updating PID file (/usr/local/mysql/data/localhost.localdomain.pid).                              [FAILED]
2 原因
没有初始化权限表
3 解决办法
#cd /usr/local/mysql(进入mysql安装目录)
#chown -R mysql.mysql .
#su - mysql
$cd server
$scripts/mysql_install_db
4 本人解决过程
[root@localhost ~]# cd /usr/local/mysql
[root@localhost mysql]# chown -R mysql.mysql .
[root@localhost mysql]# su - mysql
[mysql@localhost ~]$ cd /usr/local/mysql
[mysql@localhost mysql]$ scripts/mysql_install_db
Installing MySQL system tables...
OK
Filling help tables...
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h localhost.localdomain password 'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
[mysql@localhost mysql]$ /usr/local/mysql/bin/mysqld_safe --user=mysql &
[1] 11767
[mysql@localhost mysql]$ 120502 07:01:17 mysqld_safe Logging to '/usr/local/mysql/data/localhost.localdomain.err'.
120502 07:01:17 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql status
MySQL running (11830)                                      [  OK  ]
[mysql@localhost mysql]$ /etc/rc.d/init.d/mysql start
Starting MySQL                                             [  OK  ]


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


19.恢复数据库
  mysql -u root -p [数据库名]< mysql-all.sql
20.授予用户权限
  GRANT 权限列表 ON 数据库名.表名 TO 用户名@来源地址 [IDENTIFIED BY '密码']
 GRANT ALL PRIVILEGES ON *.* TO ‘myuser’@'%’ IDENTIFIED BY ‘mypassword’ WITH GRANT OPTION;

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

ssh输错了命令回车成了换行  ctrl+c

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Curses library not found. Please install appropriate package
 今天安装mysql-5.5.3-m3的时候,报下面的错误:
-- Could NOT find OpenSSL (missing: OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR) 
-- Could NOT find Curses (missing: CURSES_LIBRARY CURSES_INCLUDE_PATH) 
CMake Error at cmake/readline.cmake:83 (MESSAGE):
Curses library not found. Please install appropriate package,
remove CMakeCache.txt and rerun cmake.On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-devel.
Call Stack (most recent call first):
cmake/readline.cmake:118 (FIND_CURSES)
cmake/readline.cmake:214 (MYSQL_USE_BUNDLED_READLINE)
CMakeLists.txt:257 (MYSQL_CHECK_READLINE)
-- Configuring incomplete, errors occurred!
解决办法:
rm -f CMakeCache.txt
yum -y install ncurses-devel
然后再使用cmake编译就可以了.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


configure: error: no acceptable C compiler found in $PATH
configure: error: no acceptable C compiler found in $PATH See `c
configure: error: no acceptable C compiler found in $PATH See `config.log' for more details.你的机器里没有安装任何C语言编译器,可以安装gcc。 可以在安装盘里找到gcc相关的包进行安装,不过会比较繁琐,因为关联的包会比较多。 如果可以上网,使用yum安装是比较好的选择: yum install gcc


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

linux下安装安装pcre-8.32 configure: error: You need a C++ compiler for C++ support
linux下安装安装pcre-8.32

./configure --prefix=/usr/local/pcre 出现以下错误
configure: error: You need a C++ compiler for C++ support
正解
yum install -y gcc gcc-c++

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


linux下重命名文件或文件夹使用mv既可实现。
例子:
①将一个名为abc.txt的文件重命名为1234.txt
1
[root@station90 root]#mv abc.txt 1234.txt
②将目录A重命名为B
1
[root@station90 root]#mv A B
③将a.txt移动到/b下,并重命名为c.txt
1
[root@station90 root]#mv a.txt /b/c.txt

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


centos7.0 没有netstat 和 ifconfig命令问题
yum install wget
运行  yum install net-tools  就OK了

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

.tar.gz     格式解压为          tar   -zxvf   xx.tar.gz
.tar.bz2   格式解压为          tar   -jxvf    xx.tar.bz2

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

装了不行然后重装系统,来来回回五六遍,最后终于发现了宝贝一键安装的宝贝。

yum -y install wget && wget https://vpssim.com/install  && sh install      lnmp一键安装成功

一个命令,几分钟就完事,真特么心痛啊,唉。。。。。。。。。。


你可能感兴趣的:(基于openVZ的CentOS6.X安装lamp环境)