• Home
  • Contact

Carlos Sura

Linux, Mail, Servers, Postfix, Interspire, PHP, PowerMTA

Upload files to Amazon S3 with S3 PHP Class

November 29, 2015 by Carlos Sura Leave a Comment

I was trying to create a file uploader to store the files in my Amazon S3 Bucket, so I managed to achieve this by using the S3 PHP CLASS.

Posted in: Amazon, PHP, S3 Tagged: amazon, class, code, file, php, s3, upload

Bash script to check if service is running and start it

August 10, 2015 by Carlos Sura Leave a Comment

I wanted to check every “X” minutes with a cron job if a service was running like: HTTPD, so, I came to use the following bash script:

Shell
1
2
3
4
5
6
7
8
#!/bin/sh
 
ps auxw | grep httpd | grep -v grep > /dev/null
 
if [ $? != 0 ]
then
        service httpd start > /dev/null
fi

Posted in: Bash, Linux Tagged: bash, centos, linux, running, script, service, start

Install PhantomJS 2.0 on Linux

June 10, 2015 by Carlos Sura Leave a Comment

In order to install PhantomJS 2.0 on linux from sources, we need to do the following steps:

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
cd /usr/local/share
 
# Download the file
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.0.0-source.zip
 
# Unzip it
unzip phantomjs-2.0.0-source.zip
 
# Access to the directory
cd phantomjs-2.0.0/
 
# Compile
time ./build.sh

Once is done, we need to create the symlinks following these steps:

Shell
1
2
3
ln -s /usr/local/share/phantomjs-2.0.0/bin/phantomjs /usr/local/share/phantomjs
ln -s /usr/local/share/phantomjs-2.0.0/bin/phantomjs /usr/local/bin/phantomjs
ln -s /usr/local/share/phantomjs-2.0.0/bin/phantomjs /usr/bin/phantomjs

We can verify that our installation is working, executing the following command:

Shell
1
2
root@gentoo-b0x # phantomjs -v
2.0.0

Posted in: CentOS, Linux, RedHat, Ubuntu Tagged: centos, install, linux, phantomjs, phantomjs 2.0, rhel, ubuntu

Instalar Phantomjs 2.0 en Linux

June 10, 2015 by Carlos Sura Leave a Comment

Para poder instalar PhantomJS 2.0 en Linux, seguimos los siguientes pasos

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Ingresamos y creamos el folder a donde lo instalaremos
cd /usr/local/share
 
# Descargamos el archivo
wget https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-2.0.0-source.zip
 
# Descrompimirlo
unzip phantomjs-2.0.0-source.zip
 
# Ingresamos al directorio
cd phantomjs-2.0.0/
 
# Compilar
time ./build.sh

Una vez compilado, nos resta crear los “symlink” de la siguiente forma:

Shell
1
2
3
ln -s /usr/local/share/phantomjs-2.0.0/bin/phantomjs /usr/local/share/phantomjs
ln -s /usr/local/share/phantomjs-2.0.0/bin/phantomjs /usr/local/bin/phantomjs
ln -s /usr/local/share/phantomjs-2.0.0/bin/phantomjs /usr/bin/phantomjs

Una vez hecho esto, podemos verificar que está funcionando:

Shell
1
2
root@gentoo-b0x # phantomjs -v
2.0.0

Posted in: CentOS, Linux, RedHat, Ubuntu Tagged: centos, instalar, linux, phantom, phantomjs, phantomjs 2.0, phantomjs20, rhel, ubuntu

Instalar Memcached en CentOS 7 / RedHat

April 22, 2015 by Carlos Sura Leave a Comment

Asumiendo que ya hemos instalado el repositorio: EPEL, continuamos: Instalamos:

Shell
1
yum install memcached php-pecl-memcache

Abrir el archivo a configurar:

Shell
1
vim /etc/sysconfig/memcached

Configuramos:

Shell
1
2
3
4
5
6
7
8
PORT="11211"
USER="memcached"
# máximo de conexiones
MAXCONN="2048"
# máximo de memoria para usar en cache
CACHESIZE="4096"
# opciones de seguridad, únicamente permitimos localhost
OPTIONS="-l 127.0.0.1"

Activamos e iniciamos:

Shell
1
2
systemctl enable memcached
systemctl start memcached

Revisar información general de memcached:

Shell
1
memcached-tool 127.0.0.1:11211 stats

Posted in: CentOS, Linux, RedHat Tagged: cache, caching, centos, linux, memcached, redHat

Install memcached on CentOS 7/RedHat

April 22, 2015 by Carlos Sura Leave a Comment

Assuming we have installed EPEL repo, we are going to proceed as follow: Use the following command to install it:

Shell
1
yum install memcached php-pecl-memcache

Open the configuration file:

Shell
1
vim /etc/sysconfig/memcached

Configure the basics:

Shell
1
2
3
4
5
6
7
8
PORT="11211"
USER="memcached"
# max connection
MAXCONN="2048"
# memory max to use for object storage; the default is 64 megabytes.
CACHESIZE="4096"
# important option to consider as there is no other way to secure the installation
OPTIONS="-l 127.0.0.1"

Enable and Start it:

Shell
1
2
systemctl enable memcached
systemctl start memcached

To check the general information:

Shell
1
memcached-tool 127.0.0.1:11211 stats

Posted in: CentOS, Linux, RedHat Tagged: cache, caching, centos, centos7, linux, memcached, redHat

Remover clave de usuario root en MySQL

April 22, 2015 by Carlos Sura Leave a Comment

Me preguntaba si podía remover la contraseña de MySQL para el usuario root, después de asignarla; luego de una pequeña búsqueda, encontré la manera de hacerlo: MySQL command:

MySQL
1
SET PASSWORD FOR [email protected]=PASSWORD('');

Command Line:

Shell
1
mysqladmin -u root -pLACLAVE password ''

Posted in: CentOS, Funtoo, Gentoo, Linux, MySQL, RedHat Tagged: clave, linux, mysql, password, remover, root

Remove MySQL root password

April 22, 2015 by Carlos Sura Leave a Comment

I was wondering if I was able to remove MySQL root password, so after a little search I managed to do it, here is how to: MySQL command:

MySQL
1
SET PASSWORD FOR [email protected]=PASSWORD('');

Command Line:

Shell
1
mysqladmin -u root -pYOURPASSWORD password ''

Posted in: CentOS, Funtoo, Gentoo, Linux, MySQL, RedHat Tagged: linux, mariadb, mysql, mysqladmin, password, remove, root

HTTP request length 132092 (so far) exceeds MaxRequestLen

February 5, 2015 by Carlos Sura Leave a Comment

El error es causado al subir una imagen a wordpress en mi caso.

Shell
1
2
3
4
5
6
7
8
cd /etc/httpd/conf.d
 
vim fcgid.conf
 
# Agregamos las siguientes líneas
# En mi caso estoy usando un máximo de 15MB
FcgidConnectTimeout 20
MaxRequestLen 15728640

 

Posted in: Apache, CentOS, fcgid, Linux, RedHat, suEXEC Tagged: apache, centos, debian, exceeds, http, length, maxrequestlen, request, rhel, suexec, ubuntu

Apache + mod_fcgid + PHP + SuEXEC RHEL7/CentOS7

January 27, 2015 by Carlos Sura Leave a Comment

To avoid permission issues with our vhosts we are going to install and configure: Apache + mod_fcgid + PHP + SuEXEC.

Shell
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Let's install basics
yum install php-common php-cli mod_fcgid httpd httpd-devel
 
# Create the following directories and files
mkdir -p /var/www/cgi-bin/domain.com
vim /var/www/cgi-bin/domain.com/php-domain.com
 
# Let's add the follwing
 
#!/bin/sh
export PHPRC=/home/dominio
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=1
exec /usr/bin/php-cgi
 
# Assing permissions to the files and folders
chmod 755 /var/www/cgi-bin/domain.com/php-domain.com
chown -R domain.com:domain.com /var/www/cgi-bin/test.domain.com
 
# Modify the following file
vim /var/www/cgi-bin/php-fcgi
 
# Add the following
 
#!/bin/sh
export PHPRC=/etc
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=1
exec /usr/bin/php-cgi
 
# Assign permissions
chmod 755 /var/www/cgi-bin/php-fcgi
 
# If we want a different configuration for each site, we can copy the php.ini file
cp /etc/php.ini /home/domain.com/
chown domain.com:domain.com /home/domain.com/php.ini
 
# Find and assign permissions to files and folders
find /home/domain.com/public_html/ -type d -exec chmod 755 {} \;
find /home/domain.com/public_html/ -type f -exec chmod 644 {} \;
 
# In case we use an .htaccess file we might want to run:
find /home -name .htaccess -exec grep -nH php_ {} \;
 
# This is option, but if php/apache is complaining about this, you might want to do the following:
chown 1777 /var/lib/php/session
 
# This is how apache vhost config should looks like
# Do not forget to change the line: SuexecUserGroup "#503" "#503"  (use your own username)
<VirtualHost *:80>
ServerName domain.com
ServerAlias www.domain.com
DocumentRoot /home/domain.com/public_html
ErrorLog /var/log/httpd/domain.com-error_log
CustomLog /var/log/httpd/domain.com-access_log common
ScriptAlias /cgi-bin/ /home/domain.com/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<IfModule mod_fcgid.c>
Alias /fcgi-bin/ /var/www/cgi-bin/
<Location /fcgi-bin/>
   SetHandler fcgid-script
   Options +ExecCGI
</Location>
   SuexecUserGroup "#503" "#503"
<Directory /home/domain.com/public_html>
Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI
   AddHandler php-fcgi .php
   Action php-fcgi /fcgi-bin/domain.com/php-domain.com
   FCGIWrapper /var/www/cgi-bin/domain.com/php-domain.com .php
allow from all
AllowOverride All
</Directory>
</IfModule>
<Directory /home/domain.com/cgi-bin>
Options ExecCGI
Allow from all
</Directory>
</VirtualHost>

Posted in: CentOS, Linux, RedHat Tagged: apache, centos, fcgid, mod_fcgid, php, rhel7, suexec
« Previous 1 2 3 … 7 Next »

Frase del Día

ADS

ADS

Domain Registrations from just $3.98/Year

ADS

Ads

HideMyAss.com

Etiquetas / Tags

amazon apache backup base de datos bash bind cambiar centos clave database ehlo error folder gentoo hostname http ips lamp linux local mail multiples mysql password perl php postfix redHat redireccion redirect respaldo rhel rhel7 root script sql ssl suexec timezone ubuntu vsftpd webmail windows yahoo zona horaria

Copyright © 2018 Carlos Sura.

Omega WordPress Theme by ThemeHall