1.Linux CentOS服务器安装Python3.8环境
2.å¦ä½å¨CentOS6ä¸å®è£
Python2.7åPython3.3-Python
3.centos5 源码安装Nginx + mysql + apache + php的方法
4.å¦ä½å¨linuxä¸å®è£
python
Linux CentOS服务器安装Python3.8环境
在Linux CentOS服务器中安装Python3.8环境,对于脚本编写、大数据框架、数据分析和开源框架运行具有广泛用途。95的源码以下是详细的安装步骤:
### 安装前准备
在开始安装Python3.8之前,请确保您的系统中已安装以下开发工具:
<yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel gcc
接下来,进入Python3.8源码目录,并执行编译安装:
#cd python3.8/
./configure --prefix=/usr/local/python3
make && make install
### 配置环境变量
为了使Python3.8能够被系统识别,编辑/etc/profile文件以添加环境变量配置:
PYTHON_HOME=/usr/local/python3
PATH=$PATH:$JAVA_HOME/bin:$PYTHON_HOME/bin
export PATH JAVA_HOME CLASSPATH PYTHON_HOME
完成配置后,通过运行以下命令使环境变量配置立即生效:
source /etc/profile
至此,您已成功安装并配置了Python3.8环境。五端传奇源码
### 设置默认Python版本
为了将Python3.8设为默认版本,可以备份旧的Python2:
mv /usr/bin/python /usr/bin/python2.back
然后创建指向Python3的软链接:
ln -s /usr/local/python3/bin/python3 /usr/bin/python
若需要同时支持Python2和Python3,可以单独为Python3创建软链接:
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
这样,您便可以在不干扰现有Python2环境的情况下,直接使用Python3进行工作。全景云平台源码
å¦ä½å¨CentOS6ä¸å®è£ Python2.7åPython3.3-Python
å®è£ ååå¤
ç¼è¯Pythonä¹åæ¨æ好å å®è£ ä¸ç³»åçå¼åå·¥å ·åä¸äºæå±åºï¼è½ç¶ä¸æ¯å¿ é¡»çï¼ä½è¿æ ·Pythonæ
è½ä¾èµè¿äºå·¥å ·åæå±åºå±ç¤ºå®å¼ºæçåè½ãä¸é¢æ¯å©ç¨yumè¿è¡å·¥å ·åæå±åºå®è£ ç示ä¾å½ä»¤ï¼ç´æ¥copyæ§è¡å³å¯ï¼æ³¨æé¨åå½ä»¤æ¾ç¤ºä¸å ¨ï¼ä½å¯ä»¥éè¿ç§»
å¨å æ æ¥çåå¤å¶ï¼ã
yumgroupinstall"Development tools"
yuminstallzlib-develbzip2-developenssl-develncurses-develsqlite-develreadline-develtk-develgdbm-develdb4-devellibpcap-develxz-devel
该èèçå ç´
å¨æ¨ç¼è¯åå®è£ Pythonä¹åï¼æäºä¸è¥¿æ¨æ¯åºè¯¥ç¥éæèèçãå¦ä¸ã
Unicodeç¼ç
Python
ç¼ç é®é¢åå²æ ä¹ ï¼ä½ä¸ç¨è¿å¤å ³æ³¨ï¼ç¥éå®ç®åæ¯æUnicodeç¼ç å³å¯ï¼Python3ä¸é»è®¤çï¼ãèèå°å ¼å®¹æ§çåå ï¼é¤éæç¹æ®ççç±ï¼æ¨æ好é
ç½®ä¸Python 3.2åæ´æ©ççæ¬ï¼ä½¿å ¶æ¯æUTF-ç¼ç ï¼è½ç¶ä¼å¢å å°å°çå å代价ãå¨Python
2.7ä¸æ¨å¯ä»¥éè¿å¨configureæ¶æ·»å é项--enable-unicode=ucs4 è¿è¡é ç½®ï¼èå¨Python 3.2ä¸æ¯--with-wide-unicodeé项ã
Shared libraryï¼å¨æå ±äº«åºï¼
ç®
å大é¨åçLinuxç³»ç»èªå¸¦çPythoné½æ¯ä»¥å ±äº«åºçæ¹å¼ç¼è¯ç,
æ¤å¤ï¼æäºç¬¬ä¸æ¹å·¥å ·ä¾å¦mod_wsgiåBlenderï¼æ²¡æPythonçå ±äº«åºè¿è¿è¡ä¸äºï¼æ以ï¼æ¨æ好è¿æ¯æPythonç¼è¯æå¨æå ±äº«åºå§ã
为äºä»¥å ±äº«åºæ¹å¼ç¼è¯Pythonï¼æ¨å¿ é¡»ææå ±äº«åºçè·¯å¾ãæ¨æ两ç§éæ©ï¼
å¨configureå½ä»¤åé¢æ·»å :LDFLAGS="-Wl,-rpath /usr/local/lib"ä»èå°åºè·¯å¾ç´æ¥ç¼è¯è¿Pythonä¸ã
以记äºæ¬æ¹å¼æå¼ /etc/ld.so.conf ï¼ç¶åå¨æ件æåæ·»å æ°è¡ï¼/usr/local/lib ãç´§æ¥çè¿è¡å½ä»¤ /sbin/ldconfig æ´æ°å¨æé¾æ¥å¨ã æ·»å åçæ件å 容å¨CentOS 6.5 å¦ä¸:
/etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/lib
ä½¿ç¨ âmake altinstallâ èä¸æ¯make install
åè®°ï¼å¨å®è£ èªå®ä¹çæ¬çPythonæ¶ï¼make altinstallå½ä»¤æ¯å¿ é¡»çï¼å¦ææ¨ä½¿ç¨ä¸è¬ç make installå½ä»¤ï¼åµåµï¼æ¨å°ä¼å¨è§£åç¼è¯çç®å½ä¸çå°ä¸¤ä¸ªå½åä¸æ ·ä½çæ¬ä¸åçpythonï¼è¿æå¯è½ä¼å¯¼è´ä¸äºææ³ä¸å°çbugå¦ï¼å ·ä½æ¯ä»ä¹ä½è 没说ï¼æä¹ä¸ç¥éã
ä¸è½½ï¼ç¼è¯ï¼å®è£ Python
å¦ä¸å½ä»¤å¯ç¨äºä¸è½½ãç¼è¯åå®è£ Pythonã注æï¼å¦ææ¨æç®å®è£ åæå¨ä¿®æ¹/etc/ld.so.confæ件以æ´æ°å¨æé¾æ¥å¨ï¼é£ä¹ä¸é¢ç LDFLAGS åæ°æ¨å°±å¯ä»¥å»æäºã
# Python 2.7.6:
wgetblogs.com/
3] mhash库
复制代码
代码如下:
tar zxvf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
cd ../
4]mcrypt库
注意:因为该库和libmcrypt有依赖性,所以在安装前必须知道libmcrypt,否则的话会出现:
错误
复制代码
代码如下:
checking for libmcrypt – version = 2.5.0…
*** ‘libmcrypt-config –version’ returned 2.4.0, but LIBMCRYPT (2.5.8)
*** was found! If libmcrypt-config was correct, then it is best
*** to remove the old version of LIBMCRYPT. You may also be able to fix the error
*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing
*** /etc/ld.so.conf. Make sure you have run ldconfig if that is
*** required on your system.
*** If libmcrypt-config was wrong, set the environment variable LIBMCRYPT_CONFIG
*** to point to the correct copy of libmcrypt-config, and remove the file config.cache
*** before re-running configure
configure: error: *** libmcrypt was not found
是因为path的问题,所以执行:
复制代码
代码如下:
ln -s /usr/local/lib/libmcrypt.la /usr/lib/libmcrypt.la
ln -s /usr/local/lib/libmcrypt.so /usr/lib/libmcrypt.so
ln -s /usr/local/lib/libmcrypt.so.4 /usr/lib/libmcrypt.so.4
ln -s /usr/local/lib/libmcrypt.so.4.4.8 /usr/lib/libmcrypt.so.4.4.8
ln -s /usr/local/lib/libmhash.a /usr/lib/libmhash.a
ln -s /usr/local/lib/libmhash.la /usr/lib/libmhash.la
ln -s /usr/local/lib/libmhash.so /usr/lib/libmhash.so
ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2
ln -s /usr/local/lib/libmhash.so.2.0.1 /usr/lib/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
然后再安装:
复制代码
代码如下:
tar zxvf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
/sbin/ldconfig
./configure
make
make install
cd ../
二、安装mysql
复制代码
代码如下:
/usr/sbin/groupadd mysql
/usr/sbin/useradd -g mysql xxx
unzip mysql-5.1..zip
cd mysql-5.1./
./configure --prefix=/usr/local/webserver/mysql/ --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables
--with-readline --with-ssl --with-embedded-server --enable-local-infile --with-plugins=innobase
make
make install
make clean
make distclean
chmod +w /usr/local/webserver/mysql
chown -R xxx:mysql /usr/local/webserver/mysql
cp support-files/my-medium.cnf.sh /usr/local/webserver/mysql/my.cnf
cd ../
注意:这里编译./configure命令是直播购物app源码一行的而不能有换行符,如果是copy的时候,注意要去处该换行符
在最后一步拷贝的时候,我安装完在support-files下没有my-medium.cnf而只有my-medium.cnf.sh所以将这个文件拷贝过去。
@张宴原文:
附:以下为附加步骤,如果你想在这台服务器上运行MySQL数据库,付费下载系统源码则执行以下两步。如果你只是希望让PHP支持MySQL扩展库,能够连接其他服务器上的MySQL数据库,那么,以下两步无需执行。
①、以xxx用户帐号的身份建立数据表:
复制代码
代码如下:
/usr/local/webserver/mysql/bin/mysql_install_db --basedir=/usr/local/webserver/mysql --datadir=/usr/local/webserver/mysql/data --user=xxx
②、启动MySQL(最后的表示在后台运行)
复制代码
代码如下:
/bin/sh /usr/local/webserver/mysql/bin/mysqld_safe --defaults-file=/usr/local/webserver/mysql/my.cnf
3、编译安装PHP(FastCGI模式)
复制代码
代码如下:
tar zxvf php-5.2.8.tar.gz
gzip -cd php-5.2.8-fpm-0.5..diff.gz | patch -d php-5.2.8 -p1
cd php-5.2.8/
./configure --prefix=/usr/local/webserver/php --with-config-file-path=/usr/local/webserver/php/etc --with-mysql=/usr/local/webserver/mysql
--with-mysqli=/usr/local/webserver/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib
--with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem
--enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect
--enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap
--with-ldap-sasl
make ZEND_EXTRA_LIBS='-liconv'
make install
cp php.ini-dist /usr/local/webserver/php/etc/php.ini
cd ../
注意:这里./configure命令是一行的而不能有换行符,如果是copy的时候,注意要去处该换行符
4、编译安装PHP5扩展模块--可选安装
复制代码
代码如下:
tar zxvf memcache-2.2.5.tgz
cd memcache-2.2.5/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
make clean
make distclean
cd ../
tar jxvf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3/
/usr/local/webserver/php/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
make clean
make distclean
cd ../
tar zxvf PDO_MYSQL-1.0.2.tgz
cd PDO_MYSQL-1.0.2/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config --with-pdo-mysql=/usr/local/webserver/mysql
make
make install
make clean
make distclean
cd ../
tar zxvf ImageMagick.tar.gz
cd ImageMagick-6.5.1-2/
./configure
make
make install
make clean
make distclean
cd ../
tar zxvf imagick-2.2.2.tgz
cd imagick-2.2.2/
/usr/local/webserver/php/bin/phpize
./configure --with-php-config=/usr/local/webserver/php/bin/php-config
make
make install
make clean
make distclean
cd ../
5、修改php.ini文件
STRONG手工修改:/STRONG查找/usr/local/webserver/php/etc/php.ini中的extension_dir = "./"
修改为extension_dir = "/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-/"
并在此行后增加以下几行,然后保存:
extension = "memcache.so"
extension = "pdo_mysql.so"
extension = "imagick.so"
再查找output_buffering = Off
修改为output_buffering = On
6、配置eAccelerator加速PHP:
mkdir -p /usr/local/webserver/eaccelerator_cache
vi /usr/local/webserver/php/etc/php.ini
按shift+g键跳到配置文件的最末尾,加上以下配置信息:
复制代码
代码如下:
[eaccelerator]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-/eaccelerator.so"
eaccelerator.shm_size=""
eaccelerator.cache_dir="/usr/local/webserver/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl=""
eaccelerator.shm_prune_period=""
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
修改配置文件:
vi /etc/sysctl.conf
kernel.shmmax =
然后执行以下命令使配置生效:/sbin/sysctl -p
以下的步骤和张宴步骤中一样配置,不再赘诉
å¦ä½å¨linuxä¸å®è£ python
ä¸è¬linuxç³»ç»é½èªå¸¦python2ï¼ä½ æ¯è¦è£ python3ï¼
ç»ä½ centosä¸æºç å®è£ py3 çä¾åæã
å¦æå·²ç»å®è£ 好äºpython
sudo yum remove python
ç¼è¯å®è£
pythonå®ç½åªä¸ºLinuxæä¾äºæºç ï¼å æ¤æä¸è½½python3.6.1çæºç å缩å
第ä¸æ¥ï¼CentOSè£ å¥½openssléæåº
é®å ¥ä»¥ä¸å½ä»¤ï¼ yum install -y openssl-static
è¥æªè£ 该éæåºä¼å¯¼è´python3èªå¸¦çpip3å®è£ 失败
第äºæ¥ï¼ç¼è¯python3æºç
0. CentOSå®è£ GCCåwget yum install -y gcc,wget
yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel
1. å 解åpython3çæºç å wget http://python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
tar xf Python-3.6.1.tar.xz
2. é ç½®å®è£ è·¯å¾ cd Python-3.6.1 //è¿å ¥python3æºç 解ååçæ件夹
./configure --prefix=/usr/local/python3 //é»è®¤é ç½®æ件并设置å®è£ è·¯å¾
3. ç¼è¯python3æºç make
4. å®è£ make install
æç»è¥æ é误æ示ï¼è¯´æå®è£ æå
5. æ·»å æ件é¾æ¥ å®è£ åé®å ¥å½ä»¤?python3?æ示ä¸åå¨è¯¥å½ä»¤ï¼è¿æ¯å 为æ们èªå®ä¹äºå®è£ ç®å½ï¼å æ¤éè¦æ·»å æ件é¾æ¥ï¼å½ä»¤å¦ä¸ï¼
ln -s /usr/local/python3/bin/python3 /usr/bin/python3
6. æµè¯ é®å ¥å½ä»¤ï¼
python3 -V
ä¼è¾åºpython3çæ¬ä¿¡æ¯ï¼è¯´æpython3å®è£ å®æ
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3