Upload files to Amazon S3 with S3 PHP Class
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.
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.
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:
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 |
In order to install PhantomJS 2.0 on linux from sources, we need to do the following steps:
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:
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:
1 2 |
root@gentoo-b0x # phantomjs -v 2.0.0 |
Para poder instalar PhantomJS 2.0 en Linux, seguimos los siguientes pasos
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:
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:
1 2 |
root@gentoo-b0x # phantomjs -v 2.0.0 |
Asumiendo que ya hemos instalado el repositorio: EPEL, continuamos: Instalamos:
1 |
yum install memcached php-pecl-memcache |
Abrir el archivo a configurar:
1 |
vim /etc/sysconfig/memcached |
Configuramos:
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:
1 2 |
systemctl enable memcached systemctl start memcached |
Revisar información general de memcached:
1 |
memcached-tool 127.0.0.1:11211 stats |
Assuming we have installed EPEL repo, we are going to proceed as follow: Use the following command to install it:
1 |
yum install memcached php-pecl-memcache |
Open the configuration file:
1 |
vim /etc/sysconfig/memcached |
Configure the basics:
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:
1 2 |
systemctl enable memcached systemctl start memcached |
To check the general information:
1 |
memcached-tool 127.0.0.1:11211 stats |
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:
1 |
Command Line:
1 |
mysqladmin -u root -pLACLAVE password '' |
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:
1 |
Command Line:
1 |
mysqladmin -u root -pYOURPASSWORD password '' |
El error es causado al subir una imagen a wordpress en mi caso.
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 |
To avoid permission issues with our vhosts we are going to install and configure: Apache + mod_fcgid + PHP + SuEXEC.
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> |